@polymeshassociation/polymesh-sdk 31.1.0-beta.20 → 31.1.0-beta.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/.yarn/install-state.gz +0 -0
- package/CHANGELOG.md +8 -4
- package/api/entities/Asset/Base/Settlements/index.js +3 -3
- package/api/entities/types.d.ts +10 -4
- package/api/entities/types.d.ts.map +1 -1
- package/api/entities/types.js.map +1 -1
- package/api/procedures/acceptSubsidy.d.ts.map +1 -1
- package/api/procedures/acceptSubsidy.js +6 -0
- package/api/procedures/acceptSubsidy.js.map +1 -1
- package/api/procedures/addInstruction.d.ts.map +1 -1
- package/api/procedures/addInstruction.js +6 -5
- package/api/procedures/addInstruction.js.map +1 -1
- package/api/procedures/investInOffering.d.ts +2 -2
- package/api/procedures/investInOffering.d.ts.map +1 -1
- package/api/procedures/investInOffering.js +36 -0
- package/api/procedures/investInOffering.js.map +1 -1
- package/api/procedures/inviteAccount.d.ts.map +1 -1
- package/api/procedures/inviteAccount.js +0 -7
- package/api/procedures/inviteAccount.js.map +1 -1
- package/api/procedures/modifyInstructionAffirmation.d.ts +3 -3
- package/api/procedures/modifyInstructionAffirmation.d.ts.map +1 -1
- package/api/procedures/modifyInstructionAffirmation.js +9 -9
- package/api/procedures/modifyInstructionAffirmation.js.map +1 -1
- package/base/PolymeshTransactionBase.d.ts +7 -4
- package/base/PolymeshTransactionBase.d.ts.map +1 -1
- package/base/PolymeshTransactionBase.js +4 -2
- package/base/PolymeshTransactionBase.js.map +1 -1
- package/npm-package/{polymeshassociation-polymesh-sdk-31.1.0-beta.20.tgz → polymeshassociation-polymesh-sdk-31.1.0-beta.22.tgz} +0 -0
- package/package.json +1 -1
- package/types/internal.d.ts +7 -4
- package/types/internal.d.ts.map +1 -1
- package/types/internal.js.map +1 -1
- package/utils/conversion.d.ts.map +1 -1
- package/utils/conversion.js +28 -63
- package/utils/conversion.js.map +1 -1
package/utils/conversion.js
CHANGED
|
@@ -805,8 +805,11 @@ function splitTag(tag) {
|
|
|
805
805
|
}
|
|
806
806
|
/**
|
|
807
807
|
* @hidden
|
|
808
|
+
*
|
|
809
|
+
* Group transaction tags by pallet. A pallet named whole maps to `null`, and a pallet named by
|
|
810
|
+
* some of its transactions maps to their dispatchable names
|
|
808
811
|
*/
|
|
809
|
-
function initExtrinsicDict(txValues
|
|
812
|
+
function initExtrinsicDict(txValues) {
|
|
810
813
|
const extrinsicDict = {};
|
|
811
814
|
[...new Set(txValues)]
|
|
812
815
|
.sort((a, b) => a.localeCompare(b))
|
|
@@ -817,7 +820,7 @@ function initExtrinsicDict(txValues, message) {
|
|
|
817
820
|
if (pallet === null) {
|
|
818
821
|
throw new internal_1.PolymeshError({
|
|
819
822
|
code: types_3.ErrorCode.ValidationError,
|
|
820
|
-
message,
|
|
823
|
+
message: 'Attempting to add permissions for specific transactions as well as the entire module',
|
|
821
824
|
data: {
|
|
822
825
|
module: palletName,
|
|
823
826
|
transactions: [dispatchableName],
|
|
@@ -825,8 +828,8 @@ function initExtrinsicDict(txValues, message) {
|
|
|
825
828
|
});
|
|
826
829
|
}
|
|
827
830
|
else
|
|
828
|
-
pallet !== null && pallet !== void 0 ? pallet : (pallet = extrinsicDict[palletName] =
|
|
829
|
-
pallet.
|
|
831
|
+
pallet !== null && pallet !== void 0 ? pallet : (pallet = extrinsicDict[palletName] = []);
|
|
832
|
+
pallet.push(dispatchableName);
|
|
830
833
|
}
|
|
831
834
|
else {
|
|
832
835
|
extrinsicDict[(0, util_1.stringUpperFirst)(tag)] = null;
|
|
@@ -834,71 +837,33 @@ function initExtrinsicDict(txValues, message) {
|
|
|
834
837
|
});
|
|
835
838
|
return extrinsicDict;
|
|
836
839
|
}
|
|
840
|
+
/**
|
|
841
|
+
* @hidden
|
|
842
|
+
*
|
|
843
|
+
* Throw for transaction permissions that exclude transactions. The chain refuses `Except` extrinsic
|
|
844
|
+
* permissions, at the pallet and the extrinsic level, because a new extrinsic would silently widen
|
|
845
|
+
* them. Secondary keys have refused them since Polymesh 8.0, and agent groups and MultiSigs since 8.1.2
|
|
846
|
+
*/
|
|
847
|
+
function assertTransactionsNotExcluded({ type, exceptions = [] }) {
|
|
848
|
+
if (type === types_3.PermissionType.Exclude || exceptions.length) {
|
|
849
|
+
throw new internal_1.PolymeshError({
|
|
850
|
+
code: types_3.ErrorCode.ValidationError,
|
|
851
|
+
message: 'Transaction permissions cannot exclude transactions. List the transactions to allow instead',
|
|
852
|
+
data: { type, exceptions },
|
|
853
|
+
});
|
|
854
|
+
}
|
|
855
|
+
}
|
|
837
856
|
/**
|
|
838
857
|
* @hidden
|
|
839
858
|
*/
|
|
840
859
|
function buildPalletPermissions(transactions) {
|
|
841
|
-
|
|
842
|
-
const
|
|
843
|
-
const { values: txValues, exceptions = [], type } = transactions;
|
|
844
|
-
const extrinsicDict = initExtrinsicDict(txValues, message);
|
|
845
|
-
exceptions.forEach(exception => {
|
|
846
|
-
const { palletName, dispatchableName } = splitTag(exception);
|
|
847
|
-
const pallet = extrinsicDict[palletName];
|
|
848
|
-
if (pallet === undefined) {
|
|
849
|
-
throw new internal_1.PolymeshError({
|
|
850
|
-
code: types_3.ErrorCode.ValidationError,
|
|
851
|
-
message: 'Attempting to add a transaction permission exception without its corresponding module being included/excluded',
|
|
852
|
-
});
|
|
853
|
-
}
|
|
854
|
-
else if (pallet === null) {
|
|
855
|
-
extrinsicDict[palletName] = { tx: [dispatchableName], exception: true };
|
|
856
|
-
}
|
|
857
|
-
else if (pallet.exception) {
|
|
858
|
-
pallet.tx.push(dispatchableName);
|
|
859
|
-
}
|
|
860
|
-
else {
|
|
861
|
-
throw new internal_1.PolymeshError({
|
|
862
|
-
code: types_3.ErrorCode.ValidationError,
|
|
863
|
-
message: 'Cannot simultaneously include and exclude transactions belonging to the same module',
|
|
864
|
-
});
|
|
865
|
-
}
|
|
866
|
-
});
|
|
867
|
-
const getDispatchables = (val) => {
|
|
868
|
-
let dispatchables;
|
|
869
|
-
if (val === null) {
|
|
870
|
-
dispatchables = 'Whole';
|
|
871
|
-
}
|
|
872
|
-
else {
|
|
873
|
-
const { tx, exception } = val;
|
|
874
|
-
if (exception) {
|
|
875
|
-
dispatchables = {
|
|
876
|
-
Except: tx,
|
|
877
|
-
};
|
|
878
|
-
}
|
|
879
|
-
else {
|
|
880
|
-
dispatchables = {
|
|
881
|
-
These: tx,
|
|
882
|
-
};
|
|
883
|
-
}
|
|
884
|
-
}
|
|
885
|
-
return dispatchables;
|
|
886
|
-
};
|
|
860
|
+
assertTransactionsNotExcluded(transactions);
|
|
861
|
+
const extrinsicDict = initExtrinsicDict(transactions.values);
|
|
887
862
|
const pallets = new Map();
|
|
888
|
-
(0, lodash_1.forEach)(extrinsicDict, (
|
|
889
|
-
pallets.set(
|
|
863
|
+
(0, lodash_1.forEach)(extrinsicDict, (tx, palletName) => {
|
|
864
|
+
pallets.set(palletName, { extrinsics: tx === null ? 'Whole' : { These: tx } });
|
|
890
865
|
});
|
|
891
|
-
|
|
892
|
-
extrinsic = {
|
|
893
|
-
These: pallets,
|
|
894
|
-
};
|
|
895
|
-
}
|
|
896
|
-
else {
|
|
897
|
-
extrinsic = {
|
|
898
|
-
Except: pallets,
|
|
899
|
-
};
|
|
900
|
-
}
|
|
901
|
-
return extrinsic;
|
|
866
|
+
return { These: pallets };
|
|
902
867
|
}
|
|
903
868
|
/**
|
|
904
869
|
* @hidden
|