@polymeshassociation/polymesh-sdk 29.1.0-beta.1 → 29.1.0-beta.11
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/.yarn/install-state.gz +0 -0
- package/CHANGELOG.md +2 -2
- package/api/entities/Asset/Base/Documents/index.d.ts +13 -2
- package/api/entities/Asset/Base/Documents/index.d.ts.map +1 -1
- package/api/entities/Asset/Base/Documents/index.js +7 -1
- package/api/entities/Asset/Base/Documents/index.js.map +1 -1
- package/api/entities/Asset/Fungible/TransferRestrictions/index.d.ts +24 -0
- package/api/entities/Asset/Fungible/TransferRestrictions/index.d.ts.map +1 -1
- package/api/entities/Asset/Fungible/TransferRestrictions/index.js +122 -82
- package/api/entities/Asset/Fungible/TransferRestrictions/index.js.map +1 -1
- package/api/entities/Asset/NonFungible/NftCollection.d.ts +12 -2
- package/api/entities/Asset/NonFungible/NftCollection.d.ts.map +1 -1
- package/api/entities/Asset/NonFungible/NftCollection.js +20 -0
- package/api/entities/Asset/NonFungible/NftCollection.js.map +1 -1
- package/api/entities/Asset/types.d.ts +9 -0
- package/api/entities/Asset/types.d.ts.map +1 -1
- package/api/entities/Asset/types.js.map +1 -1
- package/api/entities/CustomPermissionGroup.d.ts.map +1 -1
- package/api/entities/CustomPermissionGroup.js +3 -1
- package/api/entities/CustomPermissionGroup.js.map +1 -1
- package/api/entities/DefaultPortfolio.d.ts.map +1 -1
- package/api/entities/DefaultPortfolio.js +1 -5
- package/api/entities/DefaultPortfolio.js.map +1 -1
- package/api/entities/KnownPermissionGroup.d.ts.map +1 -1
- package/api/entities/KnownPermissionGroup.js +3 -1
- package/api/entities/KnownPermissionGroup.js.map +1 -1
- package/api/entities/types.d.ts +28 -4
- package/api/entities/types.d.ts.map +1 -1
- package/api/entities/types.js.map +1 -1
- package/api/procedures/addAssetDocuments.d.ts +22 -0
- package/api/procedures/addAssetDocuments.d.ts.map +1 -0
- package/api/procedures/addAssetDocuments.js +51 -0
- package/api/procedures/addAssetDocuments.js.map +1 -0
- package/api/procedures/createTransactionBatch.d.ts +3 -0
- package/api/procedures/createTransactionBatch.d.ts.map +1 -1
- package/api/procedures/createTransactionBatch.js +26 -8
- package/api/procedures/createTransactionBatch.js.map +1 -1
- package/api/procedures/issueNft.d.ts +10 -7
- package/api/procedures/issueNft.d.ts.map +1 -1
- package/api/procedures/issueNft.js +44 -32
- package/api/procedures/issueNft.js.map +1 -1
- package/api/procedures/modifyMultiSig.d.ts +3 -2
- package/api/procedures/modifyMultiSig.d.ts.map +1 -1
- package/api/procedures/modifyMultiSig.js +75 -42
- package/api/procedures/modifyMultiSig.js.map +1 -1
- package/api/procedures/removeAssetDocuments.d.ts +22 -0
- package/api/procedures/removeAssetDocuments.d.ts.map +1 -0
- package/api/procedures/removeAssetDocuments.js +51 -0
- package/api/procedures/removeAssetDocuments.js.map +1 -0
- package/api/procedures/setAssetStats.d.ts +15 -3
- package/api/procedures/setAssetStats.d.ts.map +1 -1
- package/api/procedures/setAssetStats.js +98 -30
- package/api/procedures/setAssetStats.js.map +1 -1
- package/api/procedures/setTransferRestrictions.d.ts +11 -4
- package/api/procedures/setTransferRestrictions.d.ts.map +1 -1
- package/api/procedures/setTransferRestrictions.js +115 -63
- package/api/procedures/setTransferRestrictions.js.map +1 -1
- package/api/procedures/transferPolyx.d.ts.map +1 -1
- package/api/procedures/transferPolyx.js +30 -17
- package/api/procedures/transferPolyx.js.map +1 -1
- package/api/procedures/types.d.ts +188 -68
- package/api/procedures/types.d.ts.map +1 -1
- package/api/procedures/types.js +98 -57
- package/api/procedures/types.js.map +1 -1
- package/base/PolymeshTransactionBase.d.ts +8 -0
- package/base/PolymeshTransactionBase.d.ts.map +1 -1
- package/base/PolymeshTransactionBase.js +10 -2
- package/base/PolymeshTransactionBase.js.map +1 -1
- package/internal.d.ts +5 -3
- package/internal.d.ts.map +1 -1
- package/internal.js +8 -3
- package/internal.js.map +1 -1
- package/middleware/queries/claims.d.ts.map +1 -1
- package/middleware/queries/claims.js +1 -1
- package/middleware/queries/claims.js.map +1 -1
- package/npm-package/{polymeshassociation-polymesh-sdk-29.1.0-beta.1.tgz → polymeshassociation-polymesh-sdk-29.1.0-beta.11.tgz} +0 -0
- package/package.json +2 -1
- package/types/index.d.ts +1 -0
- package/types/index.d.ts.map +1 -1
- package/types/index.js +1 -0
- package/types/index.js.map +1 -1
- package/types/internal.d.ts +8 -0
- package/types/internal.d.ts.map +1 -1
- package/types/internal.js.map +1 -1
- package/types/txGroupConstants.d.ts +318 -0
- package/types/txGroupConstants.d.ts.map +1 -0
- package/types/txGroupConstants.js +506 -0
- package/types/txGroupConstants.js.map +1 -0
- package/utils/conversion.d.ts +24 -1
- package/utils/conversion.d.ts.map +1 -1
- package/utils/conversion.js +88 -87
- package/utils/conversion.js.map +1 -1
- package/utils/internal.d.ts +3 -3
- package/utils/internal.d.ts.map +1 -1
- package/utils/internal.js +26 -3
- package/utils/internal.js.map +1 -1
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.setTransferRestrictions = void 0;
|
|
13
13
|
exports.prepareSetTransferRestrictions = prepareSetTransferRestrictions;
|
|
14
14
|
exports.getAuthorization = getAuthorization;
|
|
15
|
+
exports.prepareStorage = prepareStorage;
|
|
15
16
|
const internal_1 = require("../../internal");
|
|
16
17
|
const types_1 = require("../../types");
|
|
17
18
|
const conversion_1 = require("../../utils/conversion");
|
|
@@ -20,76 +21,113 @@ const internal_2 = require("../../utils/internal");
|
|
|
20
21
|
* @hidden
|
|
21
22
|
* Checks if the input restrictions are valid
|
|
22
23
|
*/
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
message: 'Duplicate Jurisdiction CountryCode found in input',
|
|
41
|
-
data: { countryCode: claim.countryCode },
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
seenJurisdictions.add((_a = claim.countryCode) !== null && _a !== void 0 ? _a : 'none');
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
// cannot add two ClaimType.Accredited or ClaimType.Affiliate restrictions will result in internal error
|
|
48
|
-
if (seenClaimTypes.has(claim.type)) {
|
|
49
|
-
throw new internal_1.PolymeshError({
|
|
50
|
-
code: types_1.ErrorCode.ValidationError,
|
|
51
|
-
message: 'Duplicate ClaimType found in input',
|
|
52
|
-
data: { claimType: claim.type },
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
seenClaimTypes.add(claim.type);
|
|
56
|
-
}
|
|
24
|
+
/**
|
|
25
|
+
* Ensure claim-count restrictions do not contain duplicate identifiers.
|
|
26
|
+
*/
|
|
27
|
+
function ensureClaimCountRestrictionIsUnique(restriction, seenJurisdictions, seenClaimTypes) {
|
|
28
|
+
var _a;
|
|
29
|
+
const { claim } = restriction;
|
|
30
|
+
/* istanbul ignore next */
|
|
31
|
+
if (!claim) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (claim.type === types_1.ClaimType.Jurisdiction) {
|
|
35
|
+
const key = (_a = claim.countryCode) !== null && _a !== void 0 ? _a : 'none';
|
|
36
|
+
if (seenJurisdictions.has(key)) {
|
|
37
|
+
throw new internal_1.PolymeshError({
|
|
38
|
+
code: types_1.ErrorCode.ValidationError,
|
|
39
|
+
message: 'Duplicate Jurisdiction CountryCode found in input',
|
|
40
|
+
data: { countryCode: claim.countryCode },
|
|
57
41
|
});
|
|
58
42
|
}
|
|
43
|
+
seenJurisdictions.add(key);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
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
|
+
/**
|
|
56
|
+
* Ensure there are no duplicate claim-based restrictions in the provided input.
|
|
57
|
+
*/
|
|
58
|
+
function assertInputValid(input) {
|
|
59
|
+
const seenJurisdictions = new Set();
|
|
60
|
+
const seenClaimTypes = new Set();
|
|
61
|
+
for (const restriction of input.restrictions) {
|
|
62
|
+
if (restriction.type === types_1.TransferRestrictionType.ClaimCount) {
|
|
63
|
+
ensureClaimCountRestrictionIsUnique(restriction, seenJurisdictions, seenClaimTypes);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Convert loose restriction input into a normalized transfer restriction.
|
|
69
|
+
*/
|
|
70
|
+
function toTransferRestriction(restriction) {
|
|
71
|
+
if ('count' in restriction) {
|
|
72
|
+
return {
|
|
73
|
+
type: types_1.TransferRestrictionType.Count,
|
|
74
|
+
value: restriction.count,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
if ('percentage' in restriction) {
|
|
78
|
+
return {
|
|
79
|
+
type: types_1.TransferRestrictionType.Percentage,
|
|
80
|
+
value: restriction.percentage,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
if (restriction.type === types_1.TransferRestrictionType.ClaimCount) {
|
|
84
|
+
const { min, max, claim, issuer } = restriction;
|
|
85
|
+
return {
|
|
86
|
+
type: types_1.TransferRestrictionType.ClaimCount,
|
|
87
|
+
value: {
|
|
88
|
+
min,
|
|
89
|
+
max,
|
|
90
|
+
claim,
|
|
91
|
+
issuer,
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
if (restriction.type === types_1.TransferRestrictionType.ClaimPercentage) {
|
|
96
|
+
const { min, max, claim, issuer } = restriction;
|
|
97
|
+
return {
|
|
98
|
+
type: types_1.TransferRestrictionType.ClaimPercentage,
|
|
99
|
+
value: {
|
|
100
|
+
min,
|
|
101
|
+
max,
|
|
102
|
+
claim,
|
|
103
|
+
issuer,
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
/* istanbul ignore next */
|
|
108
|
+
throw new internal_1.PolymeshError({
|
|
109
|
+
code: types_1.ErrorCode.UnexpectedError,
|
|
110
|
+
message: `Unexpected transfer restriction: "${JSON.stringify(restriction)}". Please report this to the Polymesh team`,
|
|
59
111
|
});
|
|
60
112
|
}
|
|
61
113
|
/**
|
|
62
114
|
* @hidden
|
|
63
115
|
*/
|
|
64
116
|
function prepareSetTransferRestrictions(args) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
else {
|
|
80
|
-
value = restriction;
|
|
81
|
-
}
|
|
82
|
-
const condition = { type: restriction.type, value };
|
|
83
|
-
const neededStat = (0, internal_2.neededStatTypeForRestrictionInput)(restriction, context);
|
|
84
|
-
(0, internal_2.assertStatIsSet)(currentStats, neededStat);
|
|
85
|
-
return (0, conversion_1.transferRestrictionToPolymeshTransferCondition)(condition, context);
|
|
86
|
-
});
|
|
87
|
-
const rawConditions = (0, conversion_1.complianceConditionsToBtreeSet)(conditions, context);
|
|
88
|
-
return {
|
|
89
|
-
transaction: statistics.setAssetTransferCompliance,
|
|
90
|
-
args: [rawAssetId, rawConditions],
|
|
91
|
-
resolver: undefined,
|
|
92
|
-
};
|
|
117
|
+
const { context: { polymeshApi: { tx: { statistics }, }, }, context, storage: { currentStats }, } = this;
|
|
118
|
+
const { restrictions, asset } = args;
|
|
119
|
+
const rawAssetId = (0, conversion_1.assetToMeshAssetId)(asset, context);
|
|
120
|
+
assertInputValid(args);
|
|
121
|
+
const conditions = restrictions.map(restriction => {
|
|
122
|
+
const condition = toTransferRestriction(restriction);
|
|
123
|
+
(0, internal_2.assertStatIsSet)(currentStats, condition);
|
|
124
|
+
return (0, conversion_1.transferRestrictionToPolymeshTransferCondition)(condition, context);
|
|
125
|
+
});
|
|
126
|
+
const rawConditions = (0, conversion_1.complianceConditionsToBtreeSet)(conditions, context);
|
|
127
|
+
return Promise.resolve({
|
|
128
|
+
transaction: statistics.setAssetTransferCompliance,
|
|
129
|
+
args: [rawAssetId, rawConditions],
|
|
130
|
+
resolver: undefined,
|
|
93
131
|
});
|
|
94
132
|
}
|
|
95
133
|
/**
|
|
@@ -107,6 +145,20 @@ function getAuthorization({ asset }) {
|
|
|
107
145
|
/**
|
|
108
146
|
* @hidden
|
|
109
147
|
*/
|
|
110
|
-
|
|
148
|
+
function prepareStorage(_a) {
|
|
149
|
+
return __awaiter(this, arguments, void 0, function* ({ asset }) {
|
|
150
|
+
const { context: { polymeshApi: { query: { statistics }, }, }, context, } = this;
|
|
151
|
+
const rawAssetId = (0, conversion_1.assetToMeshAssetId)(asset, context);
|
|
152
|
+
const rawCurrentStats = yield statistics.activeAssetStats(rawAssetId);
|
|
153
|
+
const currentStats = [...rawCurrentStats].map(stat => (0, conversion_1.assetStatToStat)(stat, context));
|
|
154
|
+
return {
|
|
155
|
+
currentStats,
|
|
156
|
+
};
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* @hidden
|
|
161
|
+
*/
|
|
162
|
+
const setTransferRestrictions = () => new internal_1.Procedure(prepareSetTransferRestrictions, getAuthorization, prepareStorage);
|
|
111
163
|
exports.setTransferRestrictions = setTransferRestrictions;
|
|
112
164
|
//# 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":"setTransferRestrict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,EAAE,CAAC,KAAK,CAAC;YACf,YAAY,EAAE,CAAC,cAAM,CAAC,UAAU,CAAC,0BAA0B,CAAC;YAC5D,UAAU,EAAE,EAAE;SACf;KACF,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAsB,cAAc;yDAElC,EAAE,KAAK,EAAU;QAEjB,MAAM,EACJ,OAAO,EAAE,EACP,WAAW,EAAE,EACX,KAAK,EAAE,EAAE,UAAU,EAAE,GACtB,GACF,EACD,OAAO,GACR,GAAG,IAAI,CAAC;QAET,MAAM,UAAU,GAAG,IAAA,+BAAkB,EAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QACtD,MAAM,eAAe,GAAG,MAAM,UAAU,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;QACtE,MAAM,YAAY,GAAG,CAAC,GAAG,eAAe,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAA,4BAAe,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;QAEtF,OAAO;YACL,YAAY;SACb,CAAC;IACJ,CAAC;CAAA;AAED;;GAEG;AACI,MAAM,uBAAuB,GAAG,GAIrC,EAAE,CAAC,IAAI,oBAAS,CAAC,8BAA8B,EAAE,gBAAgB,EAAE,cAAc,CAAC,CAAC;AAJxE,QAAA,uBAAuB,2BAIiD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transferPolyx.d.ts","sourceRoot":"","sources":["../../../src/api/procedures/transferPolyx.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"transferPolyx.d.ts","sourceRoot":"","sources":["../../../src/api/procedures/transferPolyx.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,SAAS,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAa,mBAAmB,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAQ5F;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,SAAS,CAAC,mBAAmB,CAAC,EACpC,IAAI,EAAE,mBAAmB,GACxB,OAAO,CACN,eAAe,CAAC,IAAI,EAAE,eAAe,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC,GAC9D,eAAe,CAAC,IAAI,EAAE,eAAe,CAAC,UAAU,EAAE,kBAAkB,CAAC,CAAC,CACzE,CAsDA;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,sBAAsB,CAIzD;AAED;;GAEG;AACH,eAAO,MAAM,aAAa,QAAO,SAAS,CAAC,mBAAmB,CACP,CAAC"}
|
|
@@ -19,33 +19,46 @@ const conversion_1 = require("../../utils/conversion");
|
|
|
19
19
|
* @hidden
|
|
20
20
|
*/
|
|
21
21
|
function prepareTransferPolyx(args) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
const { context: { polymeshApi: { tx }, }, context, } = this;
|
|
23
|
+
const { to, amount, memo } = args;
|
|
24
|
+
const rawAccountId = (0, conversion_1.stringToAccountId)((0, conversion_1.signerToString)(to), context);
|
|
25
|
+
const rawAmount = (0, conversion_1.bigNumberToBalance)(amount, context);
|
|
26
|
+
const preRunValidation = (_a) => __awaiter(this, [_a], void 0, function* ({ asProposal }) {
|
|
27
|
+
const signingAccount = context.getSigningAccount();
|
|
28
|
+
let fromAccount;
|
|
29
|
+
if (asProposal) {
|
|
30
|
+
// Running as proposal - use MultiSig account balance
|
|
31
|
+
fromAccount = yield context.getActingAccount();
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
// Running directly - use signing account balance
|
|
35
|
+
fromAccount = signingAccount;
|
|
36
|
+
}
|
|
37
|
+
const { free: freeBalance } = yield fromAccount.getBalance();
|
|
27
38
|
if (amount.isGreaterThan(freeBalance)) {
|
|
28
39
|
throw new internal_1.PolymeshError({
|
|
29
40
|
code: types_1.ErrorCode.InsufficientBalance,
|
|
30
41
|
message: 'Insufficient free balance',
|
|
31
42
|
data: {
|
|
32
43
|
freeBalance,
|
|
44
|
+
fromAccount: fromAccount.address,
|
|
33
45
|
},
|
|
34
46
|
});
|
|
35
47
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
resolver: undefined,
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
return {
|
|
45
|
-
transaction: tx.balances.transfer,
|
|
46
|
-
args: [rawAccountId, rawAmount],
|
|
48
|
+
});
|
|
49
|
+
if (memo) {
|
|
50
|
+
return Promise.resolve({
|
|
51
|
+
transaction: tx.balances.transferWithMemo,
|
|
52
|
+
args: [rawAccountId, rawAmount, (0, conversion_1.stringToMemo)(memo, context)],
|
|
47
53
|
resolver: undefined,
|
|
48
|
-
|
|
54
|
+
preRunValidation,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
return Promise.resolve({
|
|
58
|
+
transaction: tx.balances.transfer,
|
|
59
|
+
args: [rawAccountId, rawAmount],
|
|
60
|
+
resolver: undefined,
|
|
61
|
+
preRunValidation,
|
|
49
62
|
});
|
|
50
63
|
}
|
|
51
64
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transferPolyx.js","sourceRoot":"","sources":["../../../src/api/procedures/transferPolyx.ts"],"names":[],"mappings":";;;;;;;;;;;;AAaA,
|
|
1
|
+
{"version":3,"file":"transferPolyx.js","sourceRoot":"","sources":["../../../src/api/procedures/transferPolyx.ts"],"names":[],"mappings":";;;;;;;;;;;;AAaA,oDA4DC;AAKD,4CAIC;AAlFD,yCAA+D;AAC/D,mCAAyD;AAEzD,mDAK4B;AAE5B;;GAEG;AACH,SAAgB,oBAAoB,CAElC,IAAyB;IAKzB,MAAM,EACJ,OAAO,EAAE,EACP,WAAW,EAAE,EAAE,EAAE,EAAE,GACpB,EACD,OAAO,GACR,GAAG,IAAI,CAAC;IAET,MAAM,EAAE,EAAE,EA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