@polymeshassociation/polymesh-sdk 27.5.1 → 27.6.0-beta.1

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 (68) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/api/entities/Asset/Fungible/CorporateActions/Ballots.d.ts +30 -0
  3. package/api/entities/Asset/Fungible/CorporateActions/Ballots.d.ts.map +1 -0
  4. package/api/entities/Asset/Fungible/CorporateActions/Ballots.js +80 -0
  5. package/api/entities/Asset/Fungible/CorporateActions/Ballots.js.map +1 -0
  6. package/api/entities/Asset/Fungible/CorporateActions/index.d.ts +5 -2
  7. package/api/entities/Asset/Fungible/CorporateActions/index.d.ts.map +1 -1
  8. package/api/entities/Asset/Fungible/CorporateActions/index.js +4 -0
  9. package/api/entities/Asset/Fungible/CorporateActions/index.js.map +1 -1
  10. package/api/entities/CorporateBallot/index.d.ts +84 -0
  11. package/api/entities/CorporateBallot/index.d.ts.map +1 -0
  12. package/api/entities/CorporateBallot/index.js +190 -0
  13. package/api/entities/CorporateBallot/index.js.map +1 -0
  14. package/api/entities/CorporateBallot/types.d.ts +119 -0
  15. package/api/entities/CorporateBallot/types.d.ts.map +1 -0
  16. package/api/entities/CorporateBallot/types.js +10 -0
  17. package/api/entities/CorporateBallot/types.js.map +1 -0
  18. package/api/entities/types.d.ts +6 -1
  19. package/api/entities/types.d.ts.map +1 -1
  20. package/api/entities/types.js.map +1 -1
  21. package/api/procedures/castBallotVote.d.ts +46 -0
  22. package/api/procedures/castBallotVote.d.ts.map +1 -0
  23. package/api/procedures/castBallotVote.js +151 -0
  24. package/api/procedures/castBallotVote.js.map +1 -0
  25. package/api/procedures/createBallot.d.ts +33 -0
  26. package/api/procedures/createBallot.d.ts.map +1 -0
  27. package/api/procedures/createBallot.js +92 -0
  28. package/api/procedures/createBallot.js.map +1 -0
  29. package/api/procedures/initiateCorporateAction.d.ts +31 -0
  30. package/api/procedures/initiateCorporateAction.d.ts.map +1 -0
  31. package/api/procedures/initiateCorporateAction.js +137 -0
  32. package/api/procedures/initiateCorporateAction.js.map +1 -0
  33. package/api/procedures/modifyBallot.d.ts +40 -0
  34. package/api/procedures/modifyBallot.d.ts.map +1 -0
  35. package/api/procedures/modifyBallot.js +157 -0
  36. package/api/procedures/modifyBallot.js.map +1 -0
  37. package/api/procedures/modifyCaCheckpoint.d.ts.map +1 -1
  38. package/api/procedures/modifyCaCheckpoint.js +16 -1
  39. package/api/procedures/modifyCaCheckpoint.js.map +1 -1
  40. package/api/procedures/removeBallot.d.ts +23 -0
  41. package/api/procedures/removeBallot.d.ts.map +1 -0
  42. package/api/procedures/removeBallot.js +53 -0
  43. package/api/procedures/removeBallot.js.map +1 -0
  44. package/api/procedures/types.d.ts +79 -2
  45. package/api/procedures/types.d.ts.map +1 -1
  46. package/api/procedures/types.js.map +1 -1
  47. package/api/procedures/utils.d.ts +4 -0
  48. package/api/procedures/utils.d.ts.map +1 -1
  49. package/api/procedures/utils.js +41 -1
  50. package/api/procedures/utils.js.map +1 -1
  51. package/internal.d.ts +1 -0
  52. package/internal.d.ts.map +1 -1
  53. package/internal.js +3 -1
  54. package/internal.js.map +1 -1
  55. package/npm-package/polymeshassociation-polymesh-sdk-27.6.0-beta.1.tgz +0 -0
  56. package/package.json +2 -2
  57. package/utils/constants.d.ts +1 -0
  58. package/utils/constants.d.ts.map +1 -1
  59. package/utils/constants.js +2 -1
  60. package/utils/constants.js.map +1 -1
  61. package/utils/conversion.d.ts +41 -3
  62. package/utils/conversion.d.ts.map +1 -1
  63. package/utils/conversion.js +561 -412
  64. package/utils/conversion.js.map +1 -1
  65. package/utils/internal.d.ts +29 -1
  66. package/utils/internal.d.ts.map +1 -1
  67. package/utils/internal.js +106 -1
  68. package/utils/internal.js.map +1 -1
package/CHANGELOG.md ADDED
@@ -0,0 +1,17 @@
1
+ # [27.6.0-beta.1](https://github.com/PolymeshAssociation/polymesh-sdk/compare/v27.5.1...v27.6.0-beta.1) (2025-05-15)
2
+
3
+
4
+ ### Features
5
+
6
+ * 🎸 CorporateBallot entity ([a771485](https://github.com/PolymeshAssociation/polymesh-sdk/commit/a771485f2a1377ecb710f996124eba96c61eb4d3))
7
+ * 🎸 create ballots namespace ([6f27bab](https://github.com/PolymeshAssociation/polymesh-sdk/commit/6f27bab0d65fdb9bf611cec7576c5543483f6c46))
8
+ * 🎸 createBallot procedure ([6bc3590](https://github.com/PolymeshAssociation/polymesh-sdk/commit/6bc359002261ba1f22040d5952d900893dce283a))
9
+ * 🎸 did participation in CorporateBallot ([c58c4d3](https://github.com/PolymeshAssociation/polymesh-sdk/commit/c58c4d3fc4482c8fe0fc6641ba21769d94ecc26b))
10
+ * 🎸 get all CorporateBallots for an Asset ([eac0d46](https://github.com/PolymeshAssociation/polymesh-sdk/commit/eac0d46e2fb68b1fd096e93941e703dc715b6860))
11
+ * 🎸 get ballot results ([1cfa23d](https://github.com/PolymeshAssociation/polymesh-sdk/commit/1cfa23d5343bc746e16fa7989ef82ad3d0ccac48))
12
+ * 🎸 get ballot status ([c19e61a](https://github.com/PolymeshAssociation/polymesh-sdk/commit/c19e61a9064bf22b0bd6d79bfe507280a54226ea))
13
+ * 🎸 get one existent ballot ([aaaf045](https://github.com/PolymeshAssociation/polymesh-sdk/commit/aaaf0459462a1356bb33447161037bd09b337de7))
14
+ * 🎸 init CorporateAction ([ec3856a](https://github.com/PolymeshAssociation/polymesh-sdk/commit/ec3856a74909516ca1d8a9a104bf16b9971a3d5d))
15
+ * 🎸 modify CorporateBallot ([fdaa0c7](https://github.com/PolymeshAssociation/polymesh-sdk/commit/fdaa0c7d372db3fe99b619da46a0724d54f3a060))
16
+ * 🎸 remove CorporateBallot ([eb91e62](https://github.com/PolymeshAssociation/polymesh-sdk/commit/eb91e62e5c3d42d9efd399e876dc5a6c70de2559))
17
+ * 🎸 vote on CorporateBallot ([0c58fc9](https://github.com/PolymeshAssociation/polymesh-sdk/commit/0c58fc93fccc1126cfaec78c900db0ef4df5445b))
@@ -0,0 +1,30 @@
1
+ import BigNumber from 'bignumber.js';
2
+ import { Context, FungibleAsset, Namespace } from "../../../../../internal";
3
+ import { CorporateBallotWithDetails, CreateBallotParams, ProcedureMethod } from "../../../../../types";
4
+ /**
5
+ * Handles all Asset Ballots related functionality
6
+ */
7
+ export declare class Ballots extends Namespace<FungibleAsset> {
8
+ /**
9
+ * Create a Ballot for an Asset
10
+ */
11
+ create: ProcedureMethod<CreateBallotParams, CorporateBallotWithDetails>;
12
+ /**
13
+ * @hidden
14
+ */
15
+ constructor(parent: FungibleAsset, context: Context);
16
+ /**
17
+ * Retrieve a single Ballot associated to this Asset by its ID
18
+ *
19
+ * @throws if there is no Ballot assigned to the provided Corporate Action with the passed ID
20
+ * @throws if the provided Corporate Action does not exist
21
+ */
22
+ getOne(args: {
23
+ id: BigNumber;
24
+ }): Promise<CorporateBallotWithDetails>;
25
+ /**
26
+ * Retrieve all Ballots associated to this Asset
27
+ */
28
+ get(): Promise<CorporateBallotWithDetails[]>;
29
+ }
30
+ //# sourceMappingURL=Ballots.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Ballots.d.ts","sourceRoot":"","sources":["../../../../../../src/api/entities/Asset/Fungible/CorporateActions/Ballots.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AAGrC,OAAO,EAAE,OAAO,EAAmB,aAAa,EAAE,SAAS,EAAE,gCAAmB;AAChF,OAAO,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,eAAe,EAAE,6BAAgB;AAa1F;;GAEG;AACH,qBAAa,OAAQ,SAAQ,SAAS,CAAC,aAAa,CAAC;IACnD;;OAEG;IACI,MAAM,EAAE,eAAe,CAAC,kBAAkB,EAAE,0BAA0B,CAAC,CAAC;IAE/E;;OAEG;gBACS,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,OAAO;IASnD;;;;;OAKG;IACU,MAAM,CAAC,IAAI,EAAE;QAAE,EAAE,EAAE,SAAS,CAAA;KAAE,GAAG,OAAO,CAAC,0BAA0B,CAAC;IAwBjF;;OAEG;IACU,GAAG,IAAI,OAAO,CAAC,0BAA0B,EAAE,CAAC;CAuD1D"}
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.Ballots = void 0;
13
+ const createBallot_1 = require("../../../../procedures/createBallot");
14
+ const internal_1 = require("../../../../../internal");
15
+ const conversion_1 = require("../../../../../utils/conversion");
16
+ const internal_2 = require("../../../../../utils/internal");
17
+ /**
18
+ * Handles all Asset Ballots related functionality
19
+ */
20
+ class Ballots extends internal_1.Namespace {
21
+ /**
22
+ * @hidden
23
+ */
24
+ constructor(parent, context) {
25
+ super(parent, context);
26
+ this.create = (0, internal_2.createProcedureMethod)({ getProcedureAndArgs: args => [createBallot_1.createBallot, Object.assign({ asset: parent }, args)] }, context);
27
+ }
28
+ /**
29
+ * Retrieve a single Ballot associated to this Asset by its ID
30
+ *
31
+ * @throws if there is no Ballot assigned to the provided Corporate Action with the passed ID
32
+ * @throws if the provided Corporate Action does not exist
33
+ */
34
+ getOne(args) {
35
+ return __awaiter(this, void 0, void 0, function* () {
36
+ const { parent, context } = this;
37
+ const { id } = args;
38
+ const details = yield (0, internal_2.getCorporateBallotDetailsOrThrow)(parent, id, context);
39
+ const { corporateAction, description } = yield (0, internal_2.getCorporateActionWithDescription)(parent, id, context);
40
+ return {
41
+ ballot: new internal_1.CorporateBallot(Object.assign({ id, assetId: parent.id }, (0, conversion_1.meshCorporateActionToCorporateActionParams)(corporateAction, description, context)), context),
42
+ details,
43
+ };
44
+ });
45
+ }
46
+ /**
47
+ * Retrieve all Ballots associated to this Asset
48
+ */
49
+ get() {
50
+ return __awaiter(this, void 0, void 0, function* () {
51
+ const { parent, context: { polymeshApi: { query }, }, context, } = this;
52
+ const rawEntries = yield query.corporateAction.corporateActions.entries((0, conversion_1.assetToMeshAssetId)(parent, context));
53
+ const corporateActions = rawEntries
54
+ .map(([rawCaId, rawCorporateAction]) => ({
55
+ rawCaId,
56
+ id: (0, conversion_1.u32ToBigNumber)(rawCaId.args[1]),
57
+ corporateAction: rawCorporateAction.unwrap(),
58
+ }))
59
+ .filter(({ corporateAction }) => corporateAction.kind.isIssuerNotice);
60
+ const caDetailsPromises = corporateActions.map(ca => query.corporateAction.details(ca.rawCaId));
61
+ const ballotDetailsPromises = corporateActions.map(ca => (0, internal_2.getCorporateBallotDetailsOrNull)(parent, ca.id, context));
62
+ const [caDetails, ballotDetails] = yield Promise.all([
63
+ Promise.all(caDetailsPromises),
64
+ Promise.all(ballotDetailsPromises),
65
+ ]);
66
+ const result = [];
67
+ ballotDetails.forEach((details, index) => {
68
+ if (details) {
69
+ result.push({
70
+ ballot: new internal_1.CorporateBallot(Object.assign({ id: corporateActions[index].id, assetId: parent.id }, (0, conversion_1.meshCorporateActionToCorporateActionParams)(corporateActions[index].corporateAction, caDetails[index], context)), context),
71
+ details,
72
+ });
73
+ }
74
+ });
75
+ return result;
76
+ });
77
+ }
78
+ }
79
+ exports.Ballots = Ballots;
80
+ //# sourceMappingURL=Ballots.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Ballots.js","sourceRoot":"","sources":["../../../../../../src/api/entities/Asset/Fungible/CorporateActions/Ballots.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,sEAA6D;AAC7D,sDAAgF;AAEhF,gEAI4B;AAC5B,4DAK0B;AAE1B;;GAEG;AACH,M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R,CAAC,CAAC;iBACJ;YACH,CAAC,CAAC,CAAC;YAEH,OAAO,MAAM,CAAC;QAChB,CAAC;KAAA;CACF;AA1GD,0BA0GC"}
@@ -1,5 +1,6 @@
1
- import { Context, FungibleAsset, Identity, Namespace } from "../../../../../internal";
2
- import { ModifyCaDefaultConfigParams, ProcedureMethod, RemoveCorporateActionParams } from "../../../../../types";
1
+ import { Context, CorporateAction, FungibleAsset, Identity, Namespace } from "../../../../../internal";
2
+ import { InitiateCorporateActionParams, ModifyCaDefaultConfigParams, ProcedureMethod, RemoveCorporateActionParams } from "../../../../../types";
3
+ import { Ballots } from './Ballots';
3
4
  import { Distributions } from './Distributions';
4
5
  import { CorporateActionDefaultConfig } from './types';
5
6
  /**
@@ -7,6 +8,7 @@ import { CorporateActionDefaultConfig } from './types';
7
8
  */
8
9
  export declare class CorporateActions extends Namespace<FungibleAsset> {
9
10
  distributions: Distributions;
11
+ ballots: Ballots;
10
12
  /**
11
13
  * @hidden
12
14
  */
@@ -36,5 +38,6 @@ export declare class CorporateActions extends Namespace<FungibleAsset> {
36
38
  * When creating a Corporate Action, values passed explicitly will override this default config
37
39
  */
38
40
  getDefaultConfig(): Promise<CorporateActionDefaultConfig>;
41
+ initiate: ProcedureMethod<InitiateCorporateActionParams, CorporateAction>;
39
42
  }
40
43
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/api/entities/Asset/Fungible/CorporateActions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,aAAa,EACb,QAAQ,EAER,SAAS,EAEV,gCAAmB;AACpB,OAAO,EAAE,2BAA2B,EAAE,eAAe,EAAE,2BAA2B,EAAE,6BAAgB;AASpG,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,4BAA4B,EAAE,MAAM,SAAS,CAAC;AAEvD;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,SAAS,CAAC,aAAa,CAAC;IACrD,aAAa,EAAE,aAAa,CAAC;IAEpC;;OAEG;gBACS,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,OAAO;IAgBnD;;;;;;OAMG;IACI,gBAAgB,EAAE,eAAe,CAAC,2BAA2B,EAAE,IAAI,CAAC,CAAC;IAE5E;;OAEG;IACI,MAAM,EAAE,eAAe,CAAC,2BAA2B,EAAE,IAAI,CAAC,CAAC;IAElE;;OAEG;IACU,SAAS,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;IA4B7C;;;;;;;OAOG;IACU,gBAAgB,IAAI,OAAO,CAAC,4BAA4B,CAAC;CAkCvE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/api/entities/Asset/Fungible/CorporateActions/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,OAAO,EACP,eAAe,EACf,aAAa,EACb,QAAQ,EAER,SAAS,EAEV,gCAAmB;AACpB,OAAO,EACL,6BAA6B,EAC7B,2BAA2B,EAC3B,eAAe,EACf,2BAA2B,EAC5B,6BAAgB;AASjB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,4BAA4B,EAAE,MAAM,SAAS,CAAC;AAEvD;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,SAAS,CAAC,aAAa,CAAC;IACrD,aAAa,EAAE,aAAa,CAAC;IAC7B,OAAO,EAAE,OAAO,CAAC;IAExB;;OAEG;gBACS,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,OAAO;IAsBnD;;;;;;OAMG;IACI,gBAAgB,EAAE,eAAe,CAAC,2BAA2B,EAAE,IAAI,CAAC,CAAC;IAE5E;;OAEG;IACI,MAAM,EAAE,eAAe,CAAC,2BAA2B,EAAE,IAAI,CAAC,CAAC;IAElE;;OAEG;IACU,SAAS,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;IA4B7C;;;;;;;OAOG;IACU,gBAAgB,IAAI,OAAO,CAAC,4BAA4B,CAAC;IAmC/D,QAAQ,EAAE,eAAe,CAAC,6BAA6B,EAAE,eAAe,CAAC,CAAC;CAClF"}
@@ -10,9 +10,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.CorporateActions = void 0;
13
+ const initiateCorporateAction_1 = require("../../../../procedures/initiateCorporateAction");
13
14
  const internal_1 = require("../../../../../internal");
14
15
  const conversion_1 = require("../../../../../utils/conversion");
15
16
  const internal_2 = require("../../../../../utils/internal");
17
+ const Ballots_1 = require("./Ballots");
16
18
  const Distributions_1 = require("./Distributions");
17
19
  /**
18
20
  * Handles all Asset Corporate Actions related functionality
@@ -24,8 +26,10 @@ class CorporateActions extends internal_1.Namespace {
24
26
  constructor(parent, context) {
25
27
  super(parent, context);
26
28
  this.distributions = new Distributions_1.Distributions(parent, context);
29
+ this.ballots = new Ballots_1.Ballots(parent, context);
27
30
  this.setDefaultConfig = (0, internal_2.createProcedureMethod)({ getProcedureAndArgs: args => [internal_1.modifyCaDefaultConfig, Object.assign({ asset: parent }, args)] }, context);
28
31
  this.remove = (0, internal_2.createProcedureMethod)({ getProcedureAndArgs: args => [internal_1.removeCorporateAction, Object.assign({ asset: parent }, args)] }, context);
32
+ this.initiate = (0, internal_2.createProcedureMethod)({ getProcedureAndArgs: args => [initiateCorporateAction_1.initiateCorporateAction, Object.assign({ asset: parent }, args)] }, context);
29
33
  }
30
34
  /**
31
35
  * Retrieve a list of agent Identities
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/api/entities/Asset/Fungible/CorporateActions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,sDAOoB;AAEpB,gEAK4B;AAC5B,4DAAuE;AAEvE,mDAAgD;AAGhD;;GAEG;AACH,MAAa,gBAAiB,SAAQ,oBAAw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,OAAO,CAAC,CACvE,CAAC;iBACH;YACH,CAAC,CAAC,CAAC;YAEH,OAAO,eAAe,CAAC;QACzB,CAAC;KAAA;IAED;;;;;;;OAOG;IACU,gBAAgB;;YAC3B,MAAM,EACJ,MAAM,EACN,OAAO,EAAE,EACP,WAAW,EAAE,EACX,KAAK,EAAE,EAAE,eAAe,EAAE,GAC3B,GACF,EACD,OAAO,GACR,GAAG,IAAI,CAAC;YAET,MAAM,UAAU,GAAG,IAAA,+BAAkB,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YAEvD,MAAM,CAAC,OAAO,EAAE,qBAAqB,EAAE,eAAe,CAAC,GAAG,MAAM,IAAA,uBAAY,EAM1E,OAAO,EAAE;gBACT,CAAC,eAAe,CAAC,uBAAuB,EAAE,UAAU,CAAC;gBACrD,CAAC,eAAe,CAAC,qBAAqB,EAAE,UAAU,CAAC;gBACnD,CAAC,eAAe,CAAC,iBAAiB,EAAE,UAAU,CAAC;aAChD,CAAC,CAAC;YAEH,OAAO;gBACL,OAAO,EAAE,IAAA,qDAAwC,EAAC,OAAO,EAAE,OAAO,CAAC;gBACnE,qBAAqB,EAAE,IAAA,+BAAkB,EAAC,qBAAqB,CAAC;gBAChE,eAAe,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;oBACzD,QAAQ,EAAE,IAAI,mBAAQ,CAAC,EAAE,GAAG,EAAE,IAAA,+BAAkB,EAAC,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;oBACtE,UAAU,EAAE,IAAA,+BAAkB,EAAC,GAAG,CAAC;iBACpC,CAAC,CAAC;aACJ,CAAC;QACJ,CAAC;KAAA;CACF;AA7GD,4CA6GC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/api/entities/Asset/Fungible/CorporateActions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4FAAmF;AACnF,sDAQoB;AAOp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,EAAE,IAAI,mBAAQ,CAAC,EAAE,GAAG,EAAE,IAAA,+BAAkB,EAAC,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;oBACtE,UAAU,EAAE,IAAA,+BAAkB,EAAC,GAAG,CAAC;iBACpC,CAAC,CAAC;aACJ,CAAC;QACJ,CAAC;KAAA;CAGF;AAtHD,4CAsHC"}
@@ -0,0 +1,84 @@
1
+ import BigNumber from 'bignumber.js';
2
+ import { CorporateBallotDetails, CorporateBallotMetaWithResults, CorporateBallotStatus, CorporateBallotWithParticipation } from "./types";
3
+ import { Context, CorporateActionBase } from "../../../internal";
4
+ import { CastBallotVoteParams, CorporateActionKind, CorporateActionTargets, Identity, InputCaCheckpoint, NoArgsProcedureMethod, ProcedureMethod, TaxWithholding } from "../../../types";
5
+ export interface UniqueIdentifiers {
6
+ id: BigNumber;
7
+ assetId: string;
8
+ }
9
+ export interface HumanReadable {
10
+ id: string;
11
+ assetId: string;
12
+ }
13
+ export interface Params {
14
+ kind: CorporateActionKind;
15
+ declarationDate: Date;
16
+ description: string;
17
+ targets: CorporateActionTargets;
18
+ defaultTaxWithholding: BigNumber;
19
+ taxWithholdings: TaxWithholding[];
20
+ }
21
+ /**
22
+ * Represents a Ballot
23
+ */
24
+ export declare class CorporateBallot extends CorporateActionBase {
25
+ /**
26
+ * @hidden
27
+ */
28
+ constructor(args: UniqueIdentifiers & Omit<Params, 'kind'>, context: Context);
29
+ /**
30
+ * Determine whether this Ballot exists on chain
31
+ */
32
+ exists(): Promise<boolean>;
33
+ /**
34
+ * Retrieve details associated with this Ballot
35
+ *
36
+ * @throws if the Ballot does not exist
37
+ */
38
+ details(): Promise<CorporateBallotDetails>;
39
+ /**
40
+ * Return the status of the Ballot
41
+ *
42
+ * @throws if the Ballot does not exist
43
+ */
44
+ status(): Promise<CorporateBallotStatus>;
45
+ /**
46
+ * Retrieve the results of the Ballot
47
+ *
48
+ * @throws if the Ballot does not exist
49
+ */
50
+ results(): Promise<CorporateBallotMetaWithResults>;
51
+ /**
52
+ * Retrieve the participation of the Ballot
53
+ *
54
+ * @throws if the Ballot does not exist
55
+ */
56
+ votesByIdentity(did: Identity | string): Promise<CorporateBallotWithParticipation>;
57
+ /**
58
+ * Remove the Ballot
59
+ *
60
+ * @note deletes the corporate action with the associated ballot if ballot has not started
61
+ * @throws if ballot has already started
62
+ * @throws if ballot is not found
63
+ */
64
+ remove: NoArgsProcedureMethod<void>;
65
+ /**
66
+ * Cast a vote on the Ballot
67
+ *
68
+ * @throws if the Ballot does not exist
69
+ * @throws if the Ballot voting is not active
70
+ * @throws if the number of votes does not match the sum of all choices of all motions
71
+ * @throws if fallback votes are provided for a non-RCV Ballot
72
+ * @throws if vote does not point to the correct choice in motion
73
+ * @throws if the fallback vote is the same as the choice
74
+ * @throws if the fallback vote is not pointing to a choice in the motion
75
+ */
76
+ vote: ProcedureMethod<CastBallotVoteParams, void>;
77
+ /**
78
+ * Modify the Corporate Ballot's Record Date
79
+ */
80
+ modifyCheckpoint: ProcedureMethod<{
81
+ checkpoint: InputCaCheckpoint;
82
+ }, void>;
83
+ }
84
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/api/entities/CorporateBallot/index.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC,OAAO,EAEL,sBAAsB,EACtB,8BAA8B,EAG9B,qBAAqB,EACrB,gCAAgC,EACjC,gBAA6C;AAG9C,OAAO,EACL,OAAO,EACP,mBAAmB,EAIpB,0BAAmB;AACpB,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,EAEtB,QAAQ,EACR,iBAAiB,EACjB,qBAAqB,EACrB,eAAe,EACf,cAAc,EACf,uBAAgB;AAgBjB,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,SAAS,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;CACjB;AACD,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,mBAAmB,CAAC;IAC1B,eAAe,EAAE,IAAI,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,sBAAsB,CAAC;IAChC,qBAAqB,EAAE,SAAS,CAAC;IACjC,eAAe,EAAE,cAAc,EAAE,CAAC;CACnC;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,mBAAmB;IACtD;;OAEG;gBACgB,IAAI,EAAE,iBAAiB,GAAG,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,OAAO;IAuCnF;;OAEG;IACmB,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC;IAgBhD;;;;OAIG;IACU,OAAO,IAAI,OAAO,CAAC,sBAAsB,CAAC;IAMvD;;;;OAIG;IACU,MAAM,IAAI,OAAO,CAAC,qBAAqB,CAAC;IAqBrD;;;;OAIG;IACU,OAAO,IAAI,OAAO,CAAC,8BAA8B,CAAC;IAuD/D;;;;OAIG;IACU,eAAe,CAAC,GAAG,EAAE,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC,gCAAgC,CAAC;IAiE/F;;;;;;OAMG;IACI,MAAM,EAAE,qBAAqB,CAAC,IAAI,CAAC,CAAC;IAE3C;;;;;;;;;;OAUG;IACI,IAAI,EAAE,eAAe,CAAC,oBAAoB,EAAE,IAAI,CAAC,CAAC;IAEzD;;OAEG;IACI,gBAAgB,EAAE,eAAe,CAAC;QAAE,UAAU,EAAE,iBAAiB,CAAA;KAAE,EAAE,IAAI,CAAC,CAAC;CACnF"}
@@ -0,0 +1,190 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.CorporateBallot = void 0;
16
+ const bignumber_js_1 = __importDefault(require("bignumber.js"));
17
+ const castBallotVote_1 = require("../../procedures/castBallotVote");
18
+ const removeBallot_1 = require("../../procedures/removeBallot");
19
+ const internal_1 = require("../../../internal");
20
+ const types_1 = require("../../../types");
21
+ const conversion_1 = require("../../../utils/conversion");
22
+ const internal_2 = require("../../../utils/internal");
23
+ /**
24
+ * Represents a Ballot
25
+ */
26
+ class CorporateBallot extends internal_1.CorporateActionBase {
27
+ /**
28
+ * @hidden
29
+ */
30
+ constructor(args, context) {
31
+ const argsWithDefaultParams = Object.assign(Object.assign({}, args), { kind: types_1.CorporateActionKind.IssuerNotice });
32
+ super(argsWithDefaultParams, context);
33
+ const { id, assetId } = args;
34
+ this.id = id;
35
+ this.asset = new internal_1.FungibleAsset({ assetId }, context);
36
+ this.remove = (0, internal_2.createProcedureMethod)({
37
+ getProcedureAndArgs: () => [removeBallot_1.removeBallot, { id: this.id, asset: this.asset }],
38
+ voidArgs: true,
39
+ }, context);
40
+ this.vote = (0, internal_2.createProcedureMethod)({
41
+ getProcedureAndArgs: params => [
42
+ castBallotVote_1.castBallotVote,
43
+ Object.assign({ asset: this.asset, ballot: this }, params),
44
+ ],
45
+ }, context);
46
+ this.modifyCheckpoint = (0, internal_2.createProcedureMethod)({
47
+ getProcedureAndArgs: params => [internal_1.modifyCaCheckpoint, Object.assign({ corporateAction: this }, params)],
48
+ }, context);
49
+ }
50
+ /**
51
+ * Determine whether this Ballot exists on chain
52
+ */
53
+ exists() {
54
+ return __awaiter(this, void 0, void 0, function* () {
55
+ const { id, asset, context: { polymeshApi: { query }, }, context, } = this;
56
+ const caId = (0, conversion_1.corporateActionIdentifierToCaId)({ localId: id, asset }, context);
57
+ const meta = yield query.corporateBallot.metas(caId);
58
+ return meta.isSome;
59
+ });
60
+ }
61
+ /**
62
+ * Retrieve details associated with this Ballot
63
+ *
64
+ * @throws if the Ballot does not exist
65
+ */
66
+ details() {
67
+ return __awaiter(this, void 0, void 0, function* () {
68
+ const { id, asset, context } = this;
69
+ return yield (0, internal_2.getCorporateBallotDetailsOrThrow)(asset, id, context);
70
+ });
71
+ }
72
+ /**
73
+ * Return the status of the Ballot
74
+ *
75
+ * @throws if the Ballot does not exist
76
+ */
77
+ status() {
78
+ return __awaiter(this, void 0, void 0, function* () {
79
+ const { id, asset, context, context: { polymeshApi: { query }, }, } = this;
80
+ const caId = (0, conversion_1.corporateActionIdentifierToCaId)({ localId: id, asset }, context);
81
+ const rawTimeRanges = yield query.corporateBallot.timeRanges(caId);
82
+ const timeRange = rawTimeRanges.unwrap();
83
+ const startDate = (0, conversion_1.momentToDate)(timeRange.start);
84
+ const endDate = (0, conversion_1.momentToDate)(timeRange.end);
85
+ return (0, conversion_1.ballotDetailsToBallotStatus)({ startDate, endDate });
86
+ });
87
+ }
88
+ /**
89
+ * Retrieve the results of the Ballot
90
+ *
91
+ * @throws if the Ballot does not exist
92
+ */
93
+ results() {
94
+ return __awaiter(this, void 0, void 0, function* () {
95
+ const { id, asset, context, context: { polymeshApi: { query }, }, } = this;
96
+ const caId = (0, conversion_1.corporateActionIdentifierToCaId)({ localId: id, asset }, context);
97
+ const [rawMetas, rawResults] = yield Promise.all([
98
+ query.corporateBallot.metas(caId),
99
+ query.corporateBallot.results(caId),
100
+ ]);
101
+ if (rawMetas.isNone) {
102
+ throw new internal_1.PolymeshError({
103
+ code: types_1.ErrorCode.ValidationError,
104
+ message: 'The CorporateBallot does not exist',
105
+ });
106
+ }
107
+ const { motions, title: ballotTitle } = (0, conversion_1.meshCorporateBallotMetaToCorporateBallotMeta)(rawMetas.unwrap());
108
+ let resultIndex = 0;
109
+ const motionsWithResults = motions.map(({ title, infoLink, choices }) => {
110
+ const motionWithResults = {
111
+ title,
112
+ infoLink,
113
+ choices: [],
114
+ total: new bignumber_js_1.default(0),
115
+ };
116
+ choices.forEach(choice => {
117
+ // when no votes have been cast the rawResults[resultIndex] is undefined
118
+ const choiceVoteTally = rawResults[resultIndex]
119
+ ? (0, conversion_1.u128ToBigNumber)(rawResults[resultIndex])
120
+ : new bignumber_js_1.default(0);
121
+ motionWithResults.choices.push({
122
+ choice,
123
+ votes: choiceVoteTally,
124
+ });
125
+ motionWithResults.total = motionWithResults.total.plus(choiceVoteTally);
126
+ resultIndex += 1;
127
+ });
128
+ return motionWithResults;
129
+ });
130
+ return {
131
+ title: ballotTitle,
132
+ motions: motionsWithResults,
133
+ };
134
+ });
135
+ }
136
+ /**
137
+ * Retrieve the participation of the Ballot
138
+ *
139
+ * @throws if the Ballot does not exist
140
+ */
141
+ votesByIdentity(did) {
142
+ return __awaiter(this, void 0, void 0, function* () {
143
+ const { id, asset, context, context: { polymeshApi: { query }, }, } = this;
144
+ const caId = (0, conversion_1.corporateActionIdentifierToCaId)({ localId: id, asset }, context);
145
+ const identityId = (0, conversion_1.stringToIdentityId)((0, internal_2.asIdentity)(did, context).did, context);
146
+ const [rawMetas, rawDidVotes] = yield Promise.all([
147
+ query.corporateBallot.metas(caId),
148
+ query.corporateBallot.votes(caId, identityId),
149
+ ]);
150
+ if (rawMetas.isNone) {
151
+ throw new internal_1.PolymeshError({
152
+ code: types_1.ErrorCode.ValidationError,
153
+ message: 'The CorporateBallot does not exist',
154
+ });
155
+ }
156
+ const { motions, title: ballotTitle } = (0, conversion_1.meshCorporateBallotMetaToCorporateBallotMeta)(rawMetas.unwrap());
157
+ let index = 0;
158
+ const motionsWithParticipation = motions.map(({ title, infoLink, choices }) => {
159
+ return {
160
+ title,
161
+ infoLink,
162
+ choices: choices.map(choice => {
163
+ var _a;
164
+ const { power: rawPower, fallback: rawFallback } = (_a = rawDidVotes[index]) !== null && _a !== void 0 ? _a : {
165
+ power: new bignumber_js_1.default(0),
166
+ fallback: undefined,
167
+ };
168
+ let fallback;
169
+ if (rawFallback === null || rawFallback === void 0 ? void 0 : rawFallback.isSome) {
170
+ fallback = (0, conversion_1.u16ToBigNumber)(rawFallback.unwrap());
171
+ }
172
+ const choiceWithParticipation = {
173
+ choice,
174
+ power: (0, conversion_1.u128ToBigNumber)(rawPower),
175
+ fallback,
176
+ };
177
+ index++;
178
+ return choiceWithParticipation;
179
+ }),
180
+ };
181
+ });
182
+ return {
183
+ title: ballotTitle,
184
+ motions: motionsWithParticipation,
185
+ };
186
+ });
187
+ }
188
+ }
189
+ exports.CorporateBallot = CorporateBallot;
190
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/api/entities/CorporateBallot/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,gEAAqC;AAWrC,oEAAiE;AACjE,gEAA6D;AAC7D,gDAMoB;AACpB,0CAUiB;AACjB,0DAQ4B;AAC5B,sDAI0B;AAoB1B;;GAEG;AACH,MAAa,eAAgB,SAAQ,8BAAmB;IACtD;;OAEG;IACH,YAAmB,IAA8C,EAAE,OAAgB;QACjF,MAAM,qBAAqB,mCACtB,IAAI,KACP,IAAI,EAAE,2BAAmB,CAAC,YAAY,GACvC,CAAC;QAEF,KAAK,CAAC,qBAAqB,EAAE,OAAO,CAAC,CAAC;QAEtC,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;QAE7B,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,KAAK,GAAG,IAAI,wBAAa,CAAC,EAAE,OAAO,EAAE,EAAE,OAAO,CAAC,CAAC;QAErD,IAAI,CAAC,MAAM,GAAG,IAAA,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CAAC;wBAEpC,IAAI,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,MAAM,EAAE;4BACvB,QAAQ,GAAG,IAAA,2BAAc,EAAC,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC;yBACjD;wBAED,MAAM,uBAAuB,GAA4B;4BACvD,MAAM;4BACN,KAAK,EAAE,IAAA,4BAAe,EAAC,QAAQ,CAAC;4BAChC,QAAQ;yBACT,CAAC;wBAEF,KAAK,EAAE,CAAC;wBAER,OAAO,uBAAuB,CAAC;oBACjC,CAAC,CAAC;iBACH,CAAC;YACJ,CAAC,CACF,CAAC;YACF,OAAO;gBACL,KAAK,EAAE,WAAW;gBAClB,OAAO,EAAE,wBAAwB;aAClC,CAAC;QACJ,CAAC;KAAA;CA4BF;AA/PD,0CA+PC"}
@@ -0,0 +1,119 @@
1
+ import BigNumber from 'bignumber.js';
2
+ export interface BallotMotion {
3
+ /**
4
+ * Title of the motion
5
+ */
6
+ title: string;
7
+ /**
8
+ * Link to more information about the motion
9
+ */
10
+ infoLink: string;
11
+ /**
12
+ * Choices for the motion excluding abstain.
13
+ * @note Voting power not used is considered abstained.
14
+ */
15
+ choices: string[];
16
+ }
17
+ export declare type BallotVote = {
18
+ /**
19
+ * The power of the vote.
20
+ */
21
+ power: BigNumber;
22
+ /**
23
+ * The fallback vote to be used if the choice is not found in the ballot.
24
+ * @note This is only allowed for RCV ballots.
25
+ * @note Must point to a choice in a motion (index of the choice in the motion choices array)
26
+ * @note Must not point to the same choice as the `vote` property (index != choiceIndex)
27
+ */
28
+ fallback?: BigNumber;
29
+ };
30
+ export interface BallotMeta {
31
+ /**
32
+ * Title of the Ballot
33
+ */
34
+ title: string;
35
+ /**
36
+ * All the motions of the Ballot, with their associated titles, choices, etc
37
+ */
38
+ motions: BallotMotion[];
39
+ }
40
+ export interface CorporateBallotDetails {
41
+ /**
42
+ * start date of the ballot
43
+ */
44
+ startDate: Date;
45
+ /**
46
+ * end date of the ballot
47
+ */
48
+ endDate: Date;
49
+ /**
50
+ * meta data for the ballot
51
+ */
52
+ meta: BallotMeta;
53
+ /**
54
+ * whether Ranked-Choice Voting (RCV) has been enabled
55
+ *
56
+ * Ranked-Choice Voting allows voters to select a fallback choice should their first
57
+ * preference fail to reach a certain threshold or e.g., be eliminated in the top-2 run-off. whether rcv voting has been enabled
58
+ */
59
+ rcv: boolean;
60
+ }
61
+ export declare enum CorporateBallotStatus {
62
+ Pending = "Pending",
63
+ Active = "Active",
64
+ Closed = "Closed"
65
+ }
66
+ declare type ChoiceWithVotes = {
67
+ /**
68
+ * The choice of the motion for which the votes are cast
69
+ */
70
+ choice: string;
71
+ /**
72
+ * The number of votes for the choice
73
+ */
74
+ votes: BigNumber;
75
+ };
76
+ export declare type CorporateBallotMotionWithResults = Pick<BallotMotion, 'title' | 'infoLink'> & {
77
+ /**
78
+ * The motion choices with their associated votes
79
+ */
80
+ choices: ChoiceWithVotes[];
81
+ /**
82
+ * The total number of votes cast on the motion
83
+ */
84
+ total: BigNumber;
85
+ };
86
+ export declare type CorporateBallotMetaWithResults = Omit<BallotMeta, 'motions'> & {
87
+ /**
88
+ * The motions with their associated choices and votes
89
+ */
90
+ motions: CorporateBallotMotionWithResults[];
91
+ };
92
+ export declare type ChoiceWithParticipation = {
93
+ /**
94
+ * The choice of the motion for which the votes are cast
95
+ */
96
+ choice: string;
97
+ /**
98
+ * The power of the vote
99
+ */
100
+ power: BigNumber;
101
+ /**
102
+ * The fallback choice for the vote
103
+ */
104
+ fallback?: BigNumber;
105
+ };
106
+ export declare type CorporateBallotMotionWithParticipation = Pick<BallotMotion, 'title' | 'infoLink'> & {
107
+ /**
108
+ * The choices with their associated votes and fallback choices
109
+ */
110
+ choices: ChoiceWithParticipation[];
111
+ };
112
+ export declare type CorporateBallotWithParticipation = Omit<BallotMeta, 'motions'> & {
113
+ /**
114
+ * The motions with their associated choices and votes
115
+ */
116
+ motions: CorporateBallotMotionWithParticipation[];
117
+ };
118
+ export {};
119
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/api/entities/CorporateBallot/types.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,oBAAY,UAAU,GAAG;IACvB;;OAEG;IACH,KAAK,EAAE,SAAS,CAAC;IAEjB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,CAAC;AAEF,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,OAAO,EAAE,YAAY,EAAE,CAAC;CACzB;AAED,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,SAAS,EAAE,IAAI,CAAC;IAEhB;;OAEG;IACH,OAAO,EAAE,IAAI,CAAC;IAEd;;OAEG;IACH,IAAI,EAAE,UAAU,CAAC;IAEjB;;;;;OAKG;IACH,GAAG,EAAE,OAAO,CAAC;CACd;AAED,oBAAY,qBAAqB;IAC/B,OAAO,YAAY;IACnB,MAAM,WAAW;IACjB,MAAM,WAAW;CAClB;AAED,aAAK,eAAe,GAAG;IACrB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,KAAK,EAAE,SAAS,CAAC;CAClB,CAAC;AAEF,oBAAY,gCAAgC,GAAG,IAAI,CAAC,YAAY,EAAE,OAAO,GAAG,UAAU,CAAC,GAAG;IACxF;;OAEG;IACH,OAAO,EAAE,eAAe,EAAE,CAAC;IAE3B;;OAEG;IACH,KAAK,EAAE,SAAS,CAAC;CAClB,CAAC;AAEF,oBAAY,8BAA8B,GAAG,IAAI,CAAC,UAAU,EAAE,SAAS,CAAC,GAAG;IACzE;;OAEG;IACH,OAAO,EAAE,gCAAgC,EAAE,CAAC;CAC7C,CAAC;AAEF,oBAAY,uBAAuB,GAAG;IACpC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,KAAK,EAAE,SAAS,CAAC;IAEjB;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,CAAC;AAEF,oBAAY,sCAAsC,GAAG,IAAI,CAAC,YAAY,EAAE,OAAO,GAAG,UAAU,CAAC,GAAG;IAC9F;;OAEG;IACH,OAAO,EAAE,uBAAuB,EAAE,CAAC;CACpC,CAAC;AAEF,oBAAY,gCAAgC,GAAG,IAAI,CAAC,UAAU,EAAE,SAAS,CAAC,GAAG;IAC3E;;OAEG;IACH,OAAO,EAAE,sCAAsC,EAAE,CAAC;CACnD,CAAC"}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CorporateBallotStatus = void 0;
4
+ var CorporateBallotStatus;
5
+ (function (CorporateBallotStatus) {
6
+ CorporateBallotStatus["Pending"] = "Pending";
7
+ CorporateBallotStatus["Active"] = "Active";
8
+ CorporateBallotStatus["Closed"] = "Closed";
9
+ })(CorporateBallotStatus = exports.CorporateBallotStatus || (exports.CorporateBallotStatus = {}));
10
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/api/entities/CorporateBallot/types.ts"],"names":[],"mappings":";;;AAwEA,IAAY,qBAIX;AAJD,WAAY,qBAAqB;IAC/B,4CAAmB,CAAA;IACnB,0CAAiB,CAAA;IACjB,0CAAiB,CAAA;AACnB,CAAC,EAJW,qBAAqB,GAArB,6BAAqB,KAArB,6BAAqB,QAIhC"}