-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.ts
831 lines (738 loc) · 24.9 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
import {
BigNumber,
FundRaiseType as Currency,
ContractVersion as Version,
ModuleName,
PolyResponse,
TransactionReceiptWithDecodedLogs,
} from '@polymathnetwork/contract-wrappers';
import { isPlainObject } from 'lodash';
import { PostTransactionResolver } from '../PostTransactionResolver';
/*
* External Types
*/
export { Currency };
export { Version };
export interface DividendShareholderStatus {
address: string;
paymentReceived: boolean;
excluded: boolean;
withheldTax: BigNumber;
amountReceived: BigNumber;
balance: BigNumber;
}
export enum StoType {
Simple = 'Simple',
Tiered = 'Tiered',
}
export function isStoType(type: any): type is StoType {
return typeof type === 'string' && (type === StoType.Tiered || type === StoType.Simple);
}
export interface TaxWithholdingEntry {
address: string;
percentage: number;
}
export interface IssuanceDataEntry {
address: string;
amount: BigNumber;
shareholderData?: Omit<ShareholderDataEntry, 'address'>;
}
export enum ErrorCode {
IncompatibleBrowser = 'IncompatibleBrowser',
FeatureNotEnabled = 'FeatureNotEnabled',
NonBrowserEnvironment = 'NonBrowserEnvironment',
MetamaskNotInstalled = 'MetamaskNotInstalled',
UserDeniedAccess = 'UserDeniedAccess',
WalletIsLocked = 'WalletIsLocked',
ProcedureValidationError = 'ProcedureValidationError',
FetcherValidationError = 'FetcherValidationError',
TransactionRejectedByUser = 'TransactionRejectedByUser',
TransactionReverted = 'TransactionReverted',
FatalError = 'FatalError',
UnexpectedReturnData = 'UnexpectedReturnData',
UnexpectedEventLogs = 'UnexpectedEventLogs',
InvalidUuid = 'InvalidUuid',
InvalidAddress = 'InvalidAddress',
InsufficientBalance = 'InsufficientBalance',
InexistentModule = 'InexistentModule',
IncorrectVersion = 'IncorrecVersion',
}
export interface ShareholderBalance {
address: string;
balance: BigNumber;
}
export enum ProcedureType {
UnnamedProcedure = 'UnnamedProcedure',
ApproveErc20 = 'ApproveErc20',
TransferErc20 = 'TransferErc20',
CreateCheckpoint = 'CreateCheckpoint',
EnableDividendManager = 'EnableDividendManager',
EnableGeneralPermissionManager = 'EnableGeneralPermissionManager',
EnableGeneralTransferManager = 'EnableGeneralTransferManager',
EnableCountTransferManager = 'EnableCountTransferManager',
EnablePercentageTransferManager = 'EnablePercentageTransferManager',
LaunchSimpleSto = 'LaunchSimpleSto',
LaunchTieredSto = 'LaunchTieredSto',
CreateDividendDistribution = 'CreateDividendDistribution',
CreateSecurityToken = 'CreateSecurityToken',
DisableFeature = 'DisableFeature',
FreezeIssuance = 'FreezeIssuance',
ReclaimFunds = 'ReclaimFunds',
ReserveSecurityToken = 'ReserveSecurityToken',
WithdrawTaxes = 'WithdrawTaxes',
UpdateDividendsTaxWithholdingList = 'UpdateDividendsTaxWithholdingList',
SetDividendsWallet = 'SetDividendsWallet',
PushDividendPayment = 'PushDividendPayment',
PullDividendPayment = 'PullDividendPayment',
ModifyDividendsDefaultExclusionList = 'ModifyDividendsDefaultExclusionList',
AssignSecurityTokenRole = 'AssignSecurityTokenRole',
AssignStoRole = 'AssignStoRole',
ControllerTransfer = 'ControllerTransfer',
ControllerRedeem = 'ControllerRedeem',
TogglePauseSto = 'PauseSto',
FinalizeSto = 'FinalizeSto',
SetController = 'SetController',
SetDocument = 'SetDocument',
RemoveDocument = 'RemoveDocument',
DisableController = 'DisableController',
ModifyShareholderData = 'ModifyShareholderData',
RevokeKyc = 'RevokeKyc',
IssueTokens = 'IssueTokens',
ToggleAllowPreIssuing = 'ToggleAllowPreIssuing',
ToggleAllowBeneficialInvestments = 'ToggleAllowBeneficialInvestments',
ModifyTieredStoData = 'ModifyTieredStoData',
InvestInTieredSto = 'InvestInTieredSto',
InvestInSimpleSto = 'InvestInSimpleSto',
ModifyMaxHolderCount = 'ModifyMaxHolderCount',
ModifyMaxHolderPercentage = 'ModifyMaxHolderPercentage',
ModifyPercentageExemptions = 'ModifyPercentageExemptions',
TransferSecurityTokens = 'TransferSecurityTokens',
ToggleFreezeTransfers = 'ToggleFreezeTransfers',
SignTransferData = 'SignTransferData',
SignDisableControllerAck = 'SignDisableControllerAck',
SignFreezeIssuanceAck = 'SignFreezeIssuanceAck',
TransferReservationOwnership = 'TransferReservationOwnership',
}
export enum PolyTransactionTag {
Any = 'Any',
GetTokens = 'GetTokens',
ApproveErc20 = 'ApproveErc20',
TransferErc20 = 'TransferErc20',
ReserveSecurityToken = 'ReserveSecurityToken',
CreateSecurityToken = 'CreateSecurityToken',
CreateCheckpoint = 'CreateCheckpoint',
CreateErc20DividendDistribution = 'CreateErc20DividendDistribution',
SetErc20TaxWithholding = 'SetErc20TaxWithholding',
SetEtherTaxWithholding = 'SetEtherTaxWithholding',
SetDefaultExcluded = 'SetDefaultExcluded',
EnableDividends = 'EnableDividends',
EnableCappedSto = 'EnableCappedSto',
EnableTieredSto = 'EnableTieredSto',
EnableGeneralPermissionManager = 'EnableGeneralPermissionManager',
EnableGeneralTransferManager = 'EnableGeneralTransferManager',
EnableCountTransferManager = 'EnableCountTransferManager',
EnablePercentageTransferManager = 'EnablePercentageTransferManager',
DisableController = 'DisableController',
FreezeIssuance = 'FreezeIssuance',
DisableFeature = 'DisableFeature',
ReclaimDividendFunds = 'ReclaimDividendFunds',
WithdrawTaxWithholdings = 'WithdrawTaxWithholdings',
PushDividendPayment = 'PushDividendPayment',
PullDividendPayment = 'PullDividendPayment',
SetDividendsWallet = 'SetDividendsWallet',
AddDelegate = 'AddDelegate',
ChangePermission = 'ChangePermission',
ControllerTransfer = 'ControllerTransfer',
ControllerRedeem = 'ControllerRedeem',
PauseSto = 'PauseSto',
UnpauseSto = 'UnpauseSto',
FinalizeSto = 'FinalizeSto',
SetController = 'SetController',
SetDocument = 'SetDocument',
RemoveDocument = 'RemoveDocument',
ModifyKycDataMulti = 'ModifyKycDataMulti',
ModifyInvestorFlagMulti = 'ModifyInvestorFlagMulti',
IssueMulti = 'IssueMulti',
AllowPreMinting = 'AllowPreMinting',
RevokePreMinting = 'RevokePreMinting',
ChangeAllowBeneficialInvestments = 'ChangeAllowBeneficialInvestments',
ModifyTimes = 'ModifyTimes',
ModifyFunding = 'ModifyFunding',
ModifyAddresses = 'ModifyAddresses',
ModifyTiers = 'ModifiyTiers',
ModifyLimits = 'ModifyLimits',
ModifyOracles = 'ModifyOracles',
BuyWithScRateLimited = 'BuyWithScRateLimited',
BuyWithPolyRateLimited = 'BuyWithPolyRateLimited',
BuyWithEthRateLimited = 'BuyWithEthRateLimited',
BuyTokens = 'BuyTokens',
BuyTokensWithPoly = 'BuyTokensWithPoly',
ChangeHolderCount = 'ChangeHolderCount',
ChangeHolderPercentage = 'ChangeHolderPercentage',
ModifyWhitelistMulti = 'ModifyWhitelistMulti',
SetAllowPrimaryIssuance = 'SetAllowPrimaryIssuance',
TransferSecurityTokens = 'TransferSecurityTokens',
UnfreezeTransfers = 'UnfreezeTransfers',
FreezeTransfers = 'FreezeTransfers',
Signature = 'Signature',
TransferReservationOwnership = 'TransferReservationOwnership',
}
// TODO @monitz87: remake this interface when contract-wrappers exports the tx arguments
// export interface TransactionArguments {
// [PolyTransactionTag.Any]: {};
// [PolyTransactionTag.SetErc20TaxWithholding]: Partial<SetWithholdingArgs>;
// [PolyTransactionTag.SetEtherTaxWithholding]: Partial<SetWithholdingArgs>;
// [PolyTransactionTag.ReclaimDividendFunds]: Partial<ReclaimDividendArgs>;
// [PolyTransactionTag.WithdrawTaxWithholdings]: Partial<WithdrawWithholdingArgs>;
// [PolyTransactionTag.CreateErc20DividendDistribution]: Partial<CreateErc20DividendArgs>;
// [PolyTransactionTag.GetTokens]: Partial<GetTokensArgs>;
// [PolyTransactionTag.ApprovePoly]: Partial<ApproveArgs>;
// [PolyTransactionTag.EnableDividends]: Partial<AddDividendsModuleArgs>;
// [PolyTransactionTag.ReserveSecurityToken]: Partial<RegisterTickerArgs>;
// [PolyTransactionTag.CreateSecurityToken]: Partial<GenerateNewSecurityTokenArgs>;
// [PolyTransactionTag.PushDividendPayment]: Partial<PushDividendPaymentArgs>;
// [PolyTransactionTag.SetDividendsWallet]: Partial<SetDividendsWalletArgs>;
// [PolyTransactionTag.CreateCheckpoint]: {};
// }
// Procedure arguments
export interface ApproveErc20ProcedureArgs {
amount: BigNumber;
spender: string;
tokenAddress?: string;
}
export interface TransferErc20ProcedureArgs {
amount: BigNumber;
receiver: string;
tokenAddress?: string;
}
export interface CreateCheckpointProcedureArgs {
symbol: string;
}
export interface CreateDividendDistributionProcedureArgs {
symbol: string;
maturityDate: Date;
expiryDate: Date;
erc20Address: string;
amount: BigNumber;
checkpointIndex: number;
name: string;
excludedAddresses?: string[];
taxWithholdings?: TaxWithholdingEntry[];
}
export interface PushDividendPaymentProcedureArgs {
symbol: string;
dividendIndex: number;
shareholderAddresses?: string[];
}
export interface PullDividendPaymentProcedureArgs {
symbol: string;
dividendIndex: number;
}
export interface CreateSecurityTokenProcedureArgs {
name: string;
symbol: string;
detailsUrl?: string;
divisible: boolean;
treasuryWallet?: string;
}
export interface EnableDividendManagerProcedureArgs {
symbol: string;
storageWalletAddress: string;
}
export interface EnableGeneralPermissionManagerProcedureArgs {
symbol: string;
}
export interface EnableGeneralTransferManagerProcedureArgs {
symbol: string;
}
export interface EnableCountTransferManagerProcedureArgs {
symbol: string;
maxHolderCount: number;
}
export interface EnablePercentageTransferManagerProcedureArgs {
symbol: string;
maxHolderPercentage: BigNumber;
allowPrimaryIssuance?: boolean;
}
export interface DisableFeatureProcedureArgs {
symbol: string;
moduleName: ModuleName;
}
export interface LaunchSimpleStoProcedureArgs {
symbol: string;
startDate: Date;
endDate: Date;
tokensOnSale: BigNumber;
rate: BigNumber;
currency: Currency.ETH | Currency.POLY;
raisedFundsWallet: string;
unsoldTokensWallet: string;
allowPreIssuing?: boolean;
}
export interface IssueTokensProcedureArgs {
symbol: string;
issuanceData: IssuanceDataEntry[];
}
export interface ToggleAllowPreIssuingProcedureArgs {
symbol: string;
stoAddress: string;
stoType: StoType;
allowPreIssuing: boolean;
}
export interface ToggleAllowBeneficialInvestmentsProcedureArgs {
symbol: string;
stoAddress: string;
stoType: StoType;
allowBeneficialInvestments: boolean;
}
export interface ModifyTieredStoDataProcedureArgs
extends Partial<Omit<LaunchTieredStoProcedureArgs, 'allowPreIssuing'>> {
stoAddress: string;
symbol: string;
}
interface InvestInTieredStoBaseProcedureArgs {
symbol: string;
stoAddress: string;
amount: BigNumber;
currency: Currency;
minTokens?: BigNumber;
beneficiary?: string;
}
export interface InvestWithStableCoinArgs extends InvestInTieredStoBaseProcedureArgs {
currency: Currency.StableCoin;
stableCoinAddress: string;
}
export type InvestInTieredStoProcedureArgs =
| InvestInTieredStoBaseProcedureArgs & {
currency: Currency.POLY | Currency.ETH;
stableCoinAddress?: undefined; // this is done this way on purpose for type safety
}
| InvestWithStableCoinArgs;
export interface InvestInSimpleStoProcedureArgs {
symbol: string;
stoAddress: string;
amount: BigNumber;
beneficiary?: string;
}
export function isInvestWithStableCoinArgs(args: any): args is InvestWithStableCoinArgs {
const { currency, stableCoinAddress } = args;
return currency === Currency.StableCoin && typeof stableCoinAddress === 'string';
}
export interface StoTier {
/**
* Amount of tokens to sell in this tier
*/
tokensOnSale: BigNumber;
/**
* Price of each token in this tier
*/
price: BigNumber;
/**
* Amount of tokens to sell at a discount if paid in POLY.
* Must be less than the amount of tokens on sale
*/
tokensWithDiscount?: BigNumber;
/**
* Price of tokens sold at a discount
*/
discountedPrice?: BigNumber;
}
/**
* Custom currency in which a Tiered STO can raise funds
*/
export interface CustomCurrency {
/**
* symbol of the custom currency (USD, CAD, EUR, etc. Default is USD)
*/
currencySymbol: string;
/**
* address of the oracle that states the price of ETH in the custom currency. Only required if raising funds in ETH
*/
ethOracleAddress: string;
/**
* address of the oracle that states the price of POLY in the custom currency. Only required if raising funds in POLY
*/
polyOracleAddress: string;
}
export interface LaunchTieredStoProcedureArgs {
symbol: string;
startDate: Date;
endDate: Date;
tiers: StoTier[];
nonAccreditedInvestmentLimit: BigNumber;
minimumInvestment: BigNumber;
currencies: Currency[];
raisedFundsWallet: string;
unsoldTokensWallet: string;
stableCoinAddresses?: string[];
customCurrency?: Partial<CustomCurrency>;
allowPreIssuing?: boolean;
}
export interface ReclaimFundsProcedureArgs {
symbol: string;
dividendIndex: number;
}
export interface ReserveSecurityTokenProcedureArgs {
symbol: string;
owner?: string;
}
export interface WithdrawTaxesProcedureArgs {
symbol: string;
dividendIndex: number;
}
export interface UpdateDividendsTaxWithholdingListProcedureArgs {
symbol: string;
shareholderAddresses: string[];
percentages: number[];
}
export interface SetDividendsWalletProcedureArgs {
symbol: string;
address: string;
}
export interface ModifyDividendsDefaultExclusionListProcedureArgs {
symbol: string;
shareholderAddresses: string[];
}
export interface AssignSecurityTokenRoleProcedureArgs {
symbol: string;
delegateAddress: string;
role: SecurityTokenRole;
assign: boolean;
description: string;
}
export interface AssignStoRoleProcedureArgs {
symbol: string;
delegateAddress: string;
stoAddress: string;
role: StoRole;
assign: boolean;
description?: string;
}
export interface ControllerTransferProcedureArgs {
from: string;
to: string;
symbol: string;
amount: BigNumber;
data?: string;
log?: string;
}
export interface ControllerRedeemProcedureArgs {
from: string;
symbol: string;
amount: BigNumber;
data?: string;
reason?: string;
}
export interface TogglePauseStoProcedureArgs {
symbol: string;
stoAddress: string;
stoType: StoType;
pause: boolean;
}
export interface FinalizeStoProcedureArgs {
symbol: string;
stoAddress: string;
stoType: StoType;
}
export interface SetControllerProcedureArgs {
symbol: string;
controller: string;
}
export interface SetDocumentProcedureArgs {
symbol: string;
name: string;
uri: string;
documentHash: string;
}
export interface RemoveDocumentProcedureArgs {
symbol: string;
name: string;
}
export interface FreezeIssuanceProcedureArgs {
symbol: string;
signature?: string;
}
export interface DisableControllerProcedureArgs {
symbol: string;
signature?: string;
}
export interface TransferReservationOwnershipProcedureArgs {
symbol: string;
newOwner: string;
}
export interface ShareholderDataEntry {
/**
* shareholder wallet address to whitelist
*/
address: string;
/**
* date from which the shareholder can transfer tokens
*/
canSendAfter: Date;
/**
* date from which the shareholder can receive tokens
*/
canReceiveAfter: Date;
/**
* date at which the shareholder's KYC expires
*/
kycExpiry: Date;
/**
* whether the shareholder is accredited
*/
isAccredited: boolean;
/**
* whether the shareholder is allowed to purchase tokens in an STO
*/
canBuyFromSto: boolean;
}
export interface ModifyShareholderDataProcedureArgs {
symbol: string;
shareholderData: ShareholderDataEntry[];
}
export interface RevokeKycProcedureArgs {
symbol: string;
shareholderAddresses: string[];
}
export interface ModifyMaxHolderCountProcedureArgs {
symbol: string;
maxHolderCount: number;
}
export interface ModifyMaxHolderPercentageProcedureArgs {
symbol: string;
maxHolderPercentage: BigNumber;
}
export interface PercentageWhitelistEntry {
address: string;
whitelisted: boolean;
}
export interface ModifyPercentageExemptionsProcedureArgs {
symbol: string;
whitelistEntries?: PercentageWhitelistEntry[];
allowPrimaryIssuance?: boolean;
}
export interface TransferSecurityTokensProcedureArgs {
symbol: string;
to: string;
amount: BigNumber;
data?: string;
from?: string;
}
export interface ToggleFreezeTransfersProcedureArgs {
symbol: string;
freeze: boolean;
}
export interface SignTransferDataProcedureArgs {
symbol: string;
kycData: Omit<Omit<ShareholderDataEntry, 'isAccredited'>, 'canBuyFromSto'>[];
validFrom: Date;
validTo: Date;
}
export interface SignDisableControllerAckProcedureArgs {
symbol: string;
}
export interface SignFreezeIssuanceAckProcedureArgs {
symbol: string;
}
export interface ProcedureArguments {
[ProcedureType.ApproveErc20]: ApproveErc20ProcedureArgs;
[ProcedureType.TransferErc20]: TransferErc20ProcedureArgs;
[ProcedureType.CreateCheckpoint]: CreateCheckpointProcedureArgs;
[ProcedureType.CreateDividendDistribution]: CreateDividendDistributionProcedureArgs;
[ProcedureType.CreateSecurityToken]: CreateSecurityTokenProcedureArgs;
[ProcedureType.EnableDividendManager]: EnableDividendManagerProcedureArgs;
[ProcedureType.EnableGeneralPermissionManager]: EnableGeneralPermissionManagerProcedureArgs;
[ProcedureType.EnableGeneralTransferManager]: EnableGeneralTransferManagerProcedureArgs;
[ProcedureType.EnableCountTransferManager]: EnableCountTransferManagerProcedureArgs;
[ProcedureType.EnablePercentageTransferManager]: EnablePercentageTransferManagerProcedureArgs;
[ProcedureType.ReclaimFunds]: ReclaimFundsProcedureArgs;
[ProcedureType.ReserveSecurityToken]: ReserveSecurityTokenProcedureArgs;
[ProcedureType.WithdrawTaxes]: WithdrawTaxesProcedureArgs;
[ProcedureType.UpdateDividendsTaxWithholdingList]: UpdateDividendsTaxWithholdingListProcedureArgs;
[ProcedureType.PushDividendPayment]: PushDividendPaymentProcedureArgs;
[ProcedureType.PullDividendPayment]: PullDividendPaymentProcedureArgs;
[ProcedureType.SetDividendsWallet]: SetDividendsWalletProcedureArgs;
// prettier-ignore
[ProcedureType.ModifyDividendsDefaultExclusionList]:
ModifyDividendsDefaultExclusionListProcedureArgs;
[ProcedureType.LaunchSimpleSto]: LaunchSimpleStoProcedureArgs;
[ProcedureType.LaunchTieredSto]: LaunchTieredStoProcedureArgs;
[ProcedureType.TogglePauseSto]: TogglePauseStoProcedureArgs;
[ProcedureType.ControllerTransfer]: ControllerTransferProcedureArgs;
[ProcedureType.SetController]: SetControllerProcedureArgs;
[ProcedureType.AssignSecurityTokenRole]: AssignSecurityTokenRoleProcedureArgs;
[ProcedureType.AssignStoRole]: AssignStoRoleProcedureArgs;
[ProcedureType.ModifyShareholderData]: ModifyShareholderDataProcedureArgs;
[ProcedureType.RevokeKyc]: RevokeKycProcedureArgs;
[ProcedureType.IssueTokens]: IssueTokensProcedureArgs;
[ProcedureType.ToggleAllowPreIssuing]: ToggleAllowPreIssuingProcedureArgs;
[ProcedureType.DisableFeature]: DisableFeatureProcedureArgs;
[ProcedureType.FinalizeSto]: FinalizeStoProcedureArgs;
[ProcedureType.ToggleAllowBeneficialInvestments]: ToggleAllowBeneficialInvestmentsProcedureArgs;
[ProcedureType.ModifyTieredStoData]: ModifyTieredStoDataProcedureArgs;
[ProcedureType.InvestInTieredSto]: InvestInTieredStoProcedureArgs;
[ProcedureType.InvestInSimpleSto]: InvestInSimpleStoProcedureArgs;
[ProcedureType.EnableGeneralPermissionManager]: EnableGeneralPermissionManagerProcedureArgs;
[ProcedureType.EnableGeneralTransferManager]: EnableGeneralTransferManagerProcedureArgs;
[ProcedureType.ModifyMaxHolderCount]: ModifyMaxHolderCountProcedureArgs;
[ProcedureType.ModifyMaxHolderPercentage]: ModifyMaxHolderPercentageProcedureArgs;
[ProcedureType.ModifyPercentageExemptions]: ModifyPercentageExemptionsProcedureArgs;
[ProcedureType.TransferSecurityTokens]: TransferSecurityTokensProcedureArgs;
[ProcedureType.ToggleFreezeTransfers]: ToggleFreezeTransfersProcedureArgs;
[ProcedureType.SignTransferData]: SignTransferDataProcedureArgs;
[ProcedureType.SignDisableControllerAck]: SignDisableControllerAckProcedureArgs;
[ProcedureType.SignFreezeIssuanceAck]: SignFreezeIssuanceAckProcedureArgs;
[ProcedureType.TransferReservationOwnership]: TransferReservationOwnershipProcedureArgs;
[ProcedureType.UnnamedProcedure]: {};
}
export enum TransactionStatus {
Idle = 'Idle',
Unapproved = 'Unapproved',
Running = 'Running',
Rejected = 'Rejected',
Succeeded = 'Succeeded',
Failed = 'Failed',
}
export enum TransactionQueueStatus {
Idle = 'Idle',
Running = 'Running',
Failed = 'Failed',
Succeeded = 'Succeeded',
}
export interface Fees {
usd: BigNumber | null;
poly: BigNumber;
}
export interface Pojo {
[key: string]:
| string
| number
| boolean
| null
| Pojo
| BigNumber
| Date
| (string | number | boolean | null | Pojo | BigNumber | Date)[];
}
export function isPojo(pojo: any): pojo is Pojo {
if (!pojo) {
return false;
}
const props = Object.getOwnPropertyNames(pojo);
return (
props.every(prop => {
return typeof pojo[prop] !== 'function';
}) && isPlainObject(pojo)
);
}
export enum TransactionSpeed {
Slow = 'Slow',
Medium = 'Medium',
Fast = 'Fast',
Fastest = 'Fastest',
}
export enum Feature {
Permissions = 'Permissions',
Shareholders = 'Shareholders',
Dividends = 'Dividends',
ShareholderCountRestrictions = 'ShareholderCountRestrictions',
PercentageOwnershipRestrictions = 'PercentageOwnershipRestrictions',
}
export enum SecurityTokenRole {
PermissionsAdministrator = 'PermissionsAdministrator',
DividendsOperator = 'DividendsOperator',
DividendsAdministrator = 'DividendsAdministrator',
ShareholdersAdministrator = 'ShareholdersAdministrator',
ShareholderCountRestrictionsAdministrator = 'ShareholderCountRestrictionsAdministrator',
PercentageOwnershipRestrictionsAdministrator = 'PercentageOwnershipRestrictionsAdministrator',
}
export enum StoRole {
StoOperator = 'StoOperator',
StoAdministrator = 'StoAdministrator',
}
export enum TransferStatusCode {
TransferFailure = 'TransferFailure',
TransferSuccess = 'TransferSuccess',
InsufficientBalance = 'InsufficientBalance',
InsufficientAllowance = 'InsufficientAllowance',
TransfersHalted = 'TransfersHalted',
FundsLocked = 'FundsLocked',
InvalidSender = 'InvalidSender',
InvalidReceiver = 'InvalidReceiver',
InvalidOperator = 'InvalidOperator',
}
/*
* Internal Types
*/
/**
* Return the type that results from excluding a property from another type
*
* @param T - type to exclude from
* @param K - name of the property that will be excluded
*/
export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
/**
* Transaction method from the contract-wrappers package
*
* @param A - type of the arguments object that the method receives when being called
*/
export type LowLevelMethod<A> = (args: A) => Promise<PolyResponse>;
/**
* Signature request method from the contract-wrappers package
*
* @param A - type of the arguments object that the method receives when being called
*/
export type SignatureRequest<A> = (args: A) => Promise<string>;
/**
* Represents a contract method that doesn't exist yet but will exist
* once a certain post transaction resolver is resolved
*
* @param T - type of the value that will be resolved by the post transaction resolver
* @param U - type of the arguments object that the future method will accept
*/
export interface FutureLowLevelMethod<T, U> {
/**
* function that returns a low level method
*/
futureMethod: (resolvedValue: T) => Promise<LowLevelMethod<U>>;
/**
* post transaction resolver that resolves into the value that is passed to the future method
*/
futureValue: PostTransactionResolver<T>;
}
/**
* Transforms a tuple of types into an array of resolver functions. For each type in the tuple, the corresponding resolver function returns that type wrapped in a promise
*/
export type ResolverArray<R extends any[]> = {
[P in keyof R]: (receipt: TransactionReceiptWithDecodedLogs) => Promise<R[P]>
};
/**
* Transforms a tuple of types into an array of Post Transaction Resolvers. For each type in the tuple, the corresponding Post Transaction Resolver resolves to that type
*
* @param Receipt - type of the receipt that the Post Transaction Resolver's resolver function will receive
*/
export type PostTransactionResolverArray<Value extends any[], Receipt extends any> = {
[P in keyof Value]: PostTransactionResolver<Value[P], Receipt>
};
/**
* Either a specific type or a Post Transaction Resolver that resolves to that type
*/
export type MaybeResolver<T> = PostTransactionResolver<T, any> | T;
/**
* Apply the MaybeResolver type to a tuple of types
*/
export type MapMaybeResolver<T> = { [K in keyof T]: MaybeResolver<T[K]> };
/**
* Schema of a specific transaction
*/
export interface TransactionSpec<
Args = any,
Value extends any[] = any[],
Receipt extends any = any,
FutureValue extends any = any
> {
method: LowLevelMethod<Args> | SignatureRequest<Args> | FutureLowLevelMethod<FutureValue, Args>;
args: MapMaybeResolver<Args>;
postTransactionResolvers?: PostTransactionResolverArray<Value, Receipt>;
tag?: PolyTransactionTag;
}