@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.
Files changed (35) hide show
  1. package/.yarn/install-state.gz +0 -0
  2. package/CHANGELOG.md +8 -4
  3. package/api/entities/Asset/Base/Settlements/index.js +3 -3
  4. package/api/entities/types.d.ts +10 -4
  5. package/api/entities/types.d.ts.map +1 -1
  6. package/api/entities/types.js.map +1 -1
  7. package/api/procedures/acceptSubsidy.d.ts.map +1 -1
  8. package/api/procedures/acceptSubsidy.js +6 -0
  9. package/api/procedures/acceptSubsidy.js.map +1 -1
  10. package/api/procedures/addInstruction.d.ts.map +1 -1
  11. package/api/procedures/addInstruction.js +6 -5
  12. package/api/procedures/addInstruction.js.map +1 -1
  13. package/api/procedures/investInOffering.d.ts +2 -2
  14. package/api/procedures/investInOffering.d.ts.map +1 -1
  15. package/api/procedures/investInOffering.js +36 -0
  16. package/api/procedures/investInOffering.js.map +1 -1
  17. package/api/procedures/inviteAccount.d.ts.map +1 -1
  18. package/api/procedures/inviteAccount.js +0 -7
  19. package/api/procedures/inviteAccount.js.map +1 -1
  20. package/api/procedures/modifyInstructionAffirmation.d.ts +3 -3
  21. package/api/procedures/modifyInstructionAffirmation.d.ts.map +1 -1
  22. package/api/procedures/modifyInstructionAffirmation.js +9 -9
  23. package/api/procedures/modifyInstructionAffirmation.js.map +1 -1
  24. package/base/PolymeshTransactionBase.d.ts +7 -4
  25. package/base/PolymeshTransactionBase.d.ts.map +1 -1
  26. package/base/PolymeshTransactionBase.js +4 -2
  27. package/base/PolymeshTransactionBase.js.map +1 -1
  28. package/npm-package/{polymeshassociation-polymesh-sdk-31.1.0-beta.20.tgz → polymeshassociation-polymesh-sdk-31.1.0-beta.22.tgz} +0 -0
  29. package/package.json +1 -1
  30. package/types/internal.d.ts +7 -4
  31. package/types/internal.d.ts.map +1 -1
  32. package/types/internal.js.map +1 -1
  33. package/utils/conversion.d.ts.map +1 -1
  34. package/utils/conversion.js +28 -63
  35. package/utils/conversion.js.map +1 -1
@@ -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, message) {
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] = { tx: [] });
829
- pallet.tx.push(dispatchableName);
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
- let extrinsic;
842
- const message = 'Attempting to add permissions for specific transactions as well as the entire module';
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, (val, key) => {
889
- pallets.set(key, { extrinsics: getDispatchables(val) });
863
+ (0, lodash_1.forEach)(extrinsicDict, (tx, palletName) => {
864
+ pallets.set(palletName, { extrinsics: tx === null ? 'Whole' : { These: tx } });
890
865
  });
891
- if (type === types_3.PermissionType.Include) {
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