@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.
Files changed (96) hide show
  1. package/.yarn/install-state.gz +0 -0
  2. package/CHANGELOG.md +2 -2
  3. package/api/entities/Asset/Base/Documents/index.d.ts +13 -2
  4. package/api/entities/Asset/Base/Documents/index.d.ts.map +1 -1
  5. package/api/entities/Asset/Base/Documents/index.js +7 -1
  6. package/api/entities/Asset/Base/Documents/index.js.map +1 -1
  7. package/api/entities/Asset/Fungible/TransferRestrictions/index.d.ts +24 -0
  8. package/api/entities/Asset/Fungible/TransferRestrictions/index.d.ts.map +1 -1
  9. package/api/entities/Asset/Fungible/TransferRestrictions/index.js +122 -82
  10. package/api/entities/Asset/Fungible/TransferRestrictions/index.js.map +1 -1
  11. package/api/entities/Asset/NonFungible/NftCollection.d.ts +12 -2
  12. package/api/entities/Asset/NonFungible/NftCollection.d.ts.map +1 -1
  13. package/api/entities/Asset/NonFungible/NftCollection.js +20 -0
  14. package/api/entities/Asset/NonFungible/NftCollection.js.map +1 -1
  15. package/api/entities/Asset/types.d.ts +9 -0
  16. package/api/entities/Asset/types.d.ts.map +1 -1
  17. package/api/entities/Asset/types.js.map +1 -1
  18. package/api/entities/CustomPermissionGroup.d.ts.map +1 -1
  19. package/api/entities/CustomPermissionGroup.js +3 -1
  20. package/api/entities/CustomPermissionGroup.js.map +1 -1
  21. package/api/entities/DefaultPortfolio.d.ts.map +1 -1
  22. package/api/entities/DefaultPortfolio.js +1 -5
  23. package/api/entities/DefaultPortfolio.js.map +1 -1
  24. package/api/entities/KnownPermissionGroup.d.ts.map +1 -1
  25. package/api/entities/KnownPermissionGroup.js +3 -1
  26. package/api/entities/KnownPermissionGroup.js.map +1 -1
  27. package/api/entities/types.d.ts +28 -4
  28. package/api/entities/types.d.ts.map +1 -1
  29. package/api/entities/types.js.map +1 -1
  30. package/api/procedures/addAssetDocuments.d.ts +22 -0
  31. package/api/procedures/addAssetDocuments.d.ts.map +1 -0
  32. package/api/procedures/addAssetDocuments.js +51 -0
  33. package/api/procedures/addAssetDocuments.js.map +1 -0
  34. package/api/procedures/createTransactionBatch.d.ts +3 -0
  35. package/api/procedures/createTransactionBatch.d.ts.map +1 -1
  36. package/api/procedures/createTransactionBatch.js +26 -8
  37. package/api/procedures/createTransactionBatch.js.map +1 -1
  38. package/api/procedures/issueNft.d.ts +10 -7
  39. package/api/procedures/issueNft.d.ts.map +1 -1
  40. package/api/procedures/issueNft.js +44 -32
  41. package/api/procedures/issueNft.js.map +1 -1
  42. package/api/procedures/modifyMultiSig.d.ts +3 -2
  43. package/api/procedures/modifyMultiSig.d.ts.map +1 -1
  44. package/api/procedures/modifyMultiSig.js +75 -42
  45. package/api/procedures/modifyMultiSig.js.map +1 -1
  46. package/api/procedures/removeAssetDocuments.d.ts +22 -0
  47. package/api/procedures/removeAssetDocuments.d.ts.map +1 -0
  48. package/api/procedures/removeAssetDocuments.js +51 -0
  49. package/api/procedures/removeAssetDocuments.js.map +1 -0
  50. package/api/procedures/setAssetStats.d.ts +15 -3
  51. package/api/procedures/setAssetStats.d.ts.map +1 -1
  52. package/api/procedures/setAssetStats.js +98 -30
  53. package/api/procedures/setAssetStats.js.map +1 -1
  54. package/api/procedures/setTransferRestrictions.d.ts +11 -4
  55. package/api/procedures/setTransferRestrictions.d.ts.map +1 -1
  56. package/api/procedures/setTransferRestrictions.js +115 -63
  57. package/api/procedures/setTransferRestrictions.js.map +1 -1
  58. package/api/procedures/transferPolyx.d.ts.map +1 -1
  59. package/api/procedures/transferPolyx.js +30 -17
  60. package/api/procedures/transferPolyx.js.map +1 -1
  61. package/api/procedures/types.d.ts +188 -68
  62. package/api/procedures/types.d.ts.map +1 -1
  63. package/api/procedures/types.js +98 -57
  64. package/api/procedures/types.js.map +1 -1
  65. package/base/PolymeshTransactionBase.d.ts +8 -0
  66. package/base/PolymeshTransactionBase.d.ts.map +1 -1
  67. package/base/PolymeshTransactionBase.js +10 -2
  68. package/base/PolymeshTransactionBase.js.map +1 -1
  69. package/internal.d.ts +5 -3
  70. package/internal.d.ts.map +1 -1
  71. package/internal.js +8 -3
  72. package/internal.js.map +1 -1
  73. package/middleware/queries/claims.d.ts.map +1 -1
  74. package/middleware/queries/claims.js +1 -1
  75. package/middleware/queries/claims.js.map +1 -1
  76. package/npm-package/{polymeshassociation-polymesh-sdk-29.1.0-beta.1.tgz → polymeshassociation-polymesh-sdk-29.1.0-beta.11.tgz} +0 -0
  77. package/package.json +2 -1
  78. package/types/index.d.ts +1 -0
  79. package/types/index.d.ts.map +1 -1
  80. package/types/index.js +1 -0
  81. package/types/index.js.map +1 -1
  82. package/types/internal.d.ts +8 -0
  83. package/types/internal.d.ts.map +1 -1
  84. package/types/internal.js.map +1 -1
  85. package/types/txGroupConstants.d.ts +318 -0
  86. package/types/txGroupConstants.d.ts.map +1 -0
  87. package/types/txGroupConstants.js +506 -0
  88. package/types/txGroupConstants.js.map +1 -0
  89. package/utils/conversion.d.ts +24 -1
  90. package/utils/conversion.d.ts.map +1 -1
  91. package/utils/conversion.js +88 -87
  92. package/utils/conversion.js.map +1 -1
  93. package/utils/internal.d.ts +3 -3
  94. package/utils/internal.d.ts.map +1 -1
  95. package/utils/internal.js +26 -3
  96. 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
- function assertInputValid(input) {
24
- input.restrictions.forEach(restriction => {
25
- const type = restriction.type;
26
- if (type === types_1.TransferRestrictionType.ClaimCount) {
27
- const seenJurisdictions = new Set();
28
- const seenClaimTypes = new Set();
29
- input.restrictions.forEach(rest => {
30
- var _a;
31
- const { claim } = rest;
32
- if (!claim) {
33
- return;
34
- }
35
- if (claim.type === types_1.ClaimType.Jurisdiction) {
36
- // cannot add two claims with same country code restrictions will result in internal error
37
- if (seenJurisdictions.has(claim.countryCode || 'none')) {
38
- throw new internal_1.PolymeshError({
39
- code: types_1.ErrorCode.ValidationError,
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
- return __awaiter(this, void 0, void 0, function* () {
66
- const { context: { polymeshApi: { query, tx: { statistics }, }, }, context, } = this;
67
- const { restrictions, asset } = args;
68
- const rawAssetId = (0, conversion_1.assetToMeshAssetId)(asset, context);
69
- assertInputValid(args);
70
- const currentStats = yield query.statistics.activeAssetStats(rawAssetId);
71
- const conditions = restrictions.map(restriction => {
72
- let value;
73
- if ('count' in restriction) {
74
- value = restriction.count;
75
- }
76
- else if ('percentage' in restriction) {
77
- value = restriction.percentage;
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
- const setTransferRestrictions = () => new internal_1.Procedure(prepareSetTransferRestrictions, getAuthorization);
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":";;;;;;;;;;;;AAuEA,wEA8CC;AAKD,4CAWC;AAnID,yCAAqE;AACrE,mCAUiB;AAEjB,mDAI4B;AAC5B,+CAAsF;AAItF;;;GAGG;AACH,SAAS,gBAAgB,CAAC,KAAgC;IACxD,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE;QACvC,MAAM,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC;QAC9B,IAAI,IAAI,KAAK,+BAAuB,CAAC,UAAU,EAAE,CAAC;YAChD,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAAU,CAAC;YAC5C,MAAM,cAAc,GAAG,IAAI,GAAG,EAAU,CAAC;YAEzC,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;;gBAChC,MAAM,EAAE,KAAK,EAAE,GAAG,IAA0C,CAAC;gBAE7D,IAAI,CAAC,KAAK,EAAE,CAAC;oBACX,OAAO;gBACT,CAAC;gBAED,IAAI,KAAK,CAAC,IAAI,KAAK,iBAAS,CAAC,YAAY,EAAE,CAAC;oBAC1C,0FAA0F;oBAC1F,IAAI,iBAAiB,CAAC,GAAG,CAAC,KAAK,CAAC,WAAW,IA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version":3,"file":"setTransferRestrictions.js","sourceRoot":"","sources":["../../../src/api/procedures/setTransferRestrictions.ts"],"names":[],"mappings":";;;;;;;;;;;;AAsJA,wEAgCC;AAKD,4CAWC;AAKD,wCAoBC;AA/ND,yCAAqE;AACrE,mCASiB;AAEjB,mDAK4B;AAC5B,+CAAmD;AAQnD;;;GAGG;AACH;;GAEG;AACH,SAAS,mCAAmC,CAC1C,WAA+C,EAC/C,iBAA8B,EAC9B,cAA8B;;IAE9B,MAAM,EAAE,KAAK,EAAE,GAAG,WAAW,CAAC;IAE9B,0BAA0B;IAC1B,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO;IACT,CAAC;IAED,IAAI,KAAK,CAAC,IAAI,KAAK,iBAAS,CAAC,YAAY,EAAE,CAAC;QAC1C,MAAM,GAAG,GAAG,MAAA,KAAK,CAAC,WAAW,mCAAI,MAAM,CAAC;QAExC,IAAI,iBAAiB,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YAC/B,MAAM,IAAI,wBAAa,CAAC;gBACtB,IAAI,EAAE,iBAAS,CAAC,eAAe;gBAC/B,OAAO,EAAE,mDAAmD;gBAC5D,IAAI,EAAE,EAAE,WAAW,EAAE,KAAK,CAAC,WAAW,EAAE;aACzC,CAAC,CAAC;QACL,CAAC;QAED,iBAAiB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAE3B,OAAO;IACT,CAAC;IAED,IAAI,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QACnC,MAAM,IAAI,wBAAa,CAAC;YACtB,IAAI,EAAE,iBAAS,CAAC,eAAe;YAC/B,OAAO,EAAE,oCAAoC;YAC7C,IAAI,EAAE,EAAE,SAAS,EAAE,KAAK,CAAC,IAAI,EAAE;SAChC,CAAC,CAAC;IACL,CAAC;IAED,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AACjC,CAAC;AAED;;GAEG;AACH,SAAS,gB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B,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,CAuCA;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,sBAAsB,CAIzD;AAED;;GAEG;AACH,eAAO,MAAM,aAAa,QAAO,SAAS,CAAC,mBAAmB,CACP,CAAC"}
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
- return __awaiter(this, void 0, void 0, function* () {
23
- const { context: { polymeshApi: { tx }, }, context, } = this;
24
- const { to, amount, memo } = args;
25
- const rawAccountId = (0, conversion_1.stringToAccountId)((0, conversion_1.signerToString)(to), context);
26
- const { free: freeBalance } = yield context.accountBalance();
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
- const rawAmount = (0, conversion_1.bigNumberToBalance)(amount, context);
37
- if (memo) {
38
- return {
39
- transaction: tx.balances.transferWithMemo,
40
- args: [rawAccountId, rawAmount, (0, conversion_1.stringToMemo)(memo, context)],
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":";;;;;;;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