Skip to content

Commit 4d30354

Browse files
committed
fix: auto merge
2 parents 1ec51ba + 4fc5a21 commit 4d30354

74 files changed

Lines changed: 3022 additions & 1222 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@polymathnetwork/sdk",
3-
"version": "2.0.1-beta.65",
3+
"version": "2.0.1-beta.67",
44
"description": "A Javascript SDK for interacting with the Polymath network for the browser and Node.js",
55
"bugs": {
66
"url": "https://github.com/PolymathNetwork/polymath-sdk/issues"

src/Context.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import {
55
SecurityTokenReservationFactory,
66
Erc20TokenBalanceFactory,
77
InvestmentFactory,
8-
CappedStoFactory,
9-
UsdTieredStoFactory,
8+
SimpleStoFactory,
9+
TieredStoFactory,
1010
DividendDistributionFactory,
1111
CheckpointFactory,
1212
Erc20DividendsManagerFactory,
@@ -24,8 +24,8 @@ export interface Factories {
2424
securityTokenReservationFactory: SecurityTokenReservationFactory;
2525
erc20TokenBalanceFactory: Erc20TokenBalanceFactory;
2626
investmentFactory: InvestmentFactory;
27-
cappedStoFactory: CappedStoFactory;
28-
usdTieredStoFactory: UsdTieredStoFactory;
27+
simpleStoFactory: SimpleStoFactory;
28+
tieredStoFactory: TieredStoFactory;
2929
dividendDistributionFactory: DividendDistributionFactory;
3030
checkpointFactory: CheckpointFactory;
3131
erc20DividendsManagerFactory: Erc20DividendsManagerFactory;
@@ -60,8 +60,8 @@ export class Context {
6060
securityTokenReservationFactory: new SecurityTokenReservationFactory(this),
6161
erc20TokenBalanceFactory: new Erc20TokenBalanceFactory(this),
6262
investmentFactory: new InvestmentFactory(this),
63-
cappedStoFactory: new CappedStoFactory(this),
64-
usdTieredStoFactory: new UsdTieredStoFactory(this),
63+
simpleStoFactory: new SimpleStoFactory(this),
64+
tieredStoFactory: new TieredStoFactory(this),
6565
dividendDistributionFactory: new DividendDistributionFactory(this),
6666
checkpointFactory: new CheckpointFactory(this),
6767
erc20DividendsManagerFactory: new Erc20DividendsManagerFactory(this),

src/PolymathBase.ts

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,20 @@ import {
2020
VestingEscrowWallet,
2121
RestrictedPartialSaleTransferManager,
2222
Perm,
23+
isCappedSTO,
24+
isCappedSTO_3_0_0,
25+
isUSDTieredSTO,
26+
isUSDTieredSTO_3_0_0,
27+
isGeneralPermissionManager,
28+
isGeneralPermissionManager_3_0_0,
29+
isGeneralTransferManager,
30+
isBlacklistTransferManager,
31+
isLockUpTransferManager,
32+
isCountTransferManager,
33+
isManualApprovalTransferManager,
34+
isPercentageTransferManager,
35+
isVolumeRestrictionTransferManager,
36+
isRestrictedPartialSaleTransferManager,
2337
} from '@polymathnetwork/contract-wrappers';
2438
import { range, flatten, includes } from 'lodash';
2539
import P from 'bluebird';
@@ -244,6 +258,63 @@ export class PolymathBase extends PolymathAPI {
244258
});
245259
};
246260

261+
public getTreasuryWallet = async ({ module }: { module: Module }) => {
262+
const stAddress = await module.securityToken();
263+
const token = await this.tokenFactory.getSecurityTokenInstanceFromAddress(stAddress);
264+
const defaultWallet = await token.getTreasuryWallet();
265+
266+
if (isCappedSTO(module)) {
267+
if (isCappedSTO_3_0_0(module)) {
268+
return defaultWallet;
269+
}
270+
}
271+
272+
if (isUSDTieredSTO(module)) {
273+
if (isUSDTieredSTO_3_0_0(module)) {
274+
const wallet = await module.treasuryWallet();
275+
return wallet === '0x0000000000000000000000000000000000000000' ? defaultWallet : wallet;
276+
}
277+
}
278+
279+
if (isGeneralPermissionManager(module)) {
280+
return defaultWallet;
281+
}
282+
283+
if (isGeneralTransferManager(module)) {
284+
return defaultWallet;
285+
}
286+
287+
if (isBlacklistTransferManager(module)) {
288+
return defaultWallet;
289+
}
290+
291+
if (isLockUpTransferManager(module)) {
292+
return defaultWallet;
293+
}
294+
295+
if (isCountTransferManager(module)) {
296+
return defaultWallet;
297+
}
298+
299+
if (isManualApprovalTransferManager(module)) {
300+
return defaultWallet;
301+
}
302+
303+
if (isPercentageTransferManager(module)) {
304+
return defaultWallet;
305+
}
306+
307+
if (isVolumeRestrictionTransferManager(module)) {
308+
return defaultWallet;
309+
}
310+
311+
if (isRestrictedPartialSaleTransferManager(module)) {
312+
return defaultWallet;
313+
}
314+
315+
return module.getTreasuryWallet();
316+
};
317+
247318
public getModuleAddressesByName = async (
248319
{ symbol, moduleName }: GetModuleAddressesByNameParams,
249320
opts?: GetModuleAddressesByNameOpts

src/PostTransactionResolver.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import { TransactionReceiptWithDecodedLogs } from '@polymathnetwork/contract-wrappers';
22

3-
export class PostTransactionResolver<Value extends any> {
3+
export class PostTransactionResolver<
4+
Value extends any,
5+
Receipt extends any = TransactionReceiptWithDecodedLogs
6+
> {
47
public result?: Value;
58

6-
private resolver: (
7-
receipt: TransactionReceiptWithDecodedLogs
8-
) => Promise<Value> | Promise<undefined>;
9+
private resolver: (receipt: Receipt) => Promise<Value> | Promise<undefined>;
910

10-
constructor(resolver?: (receipt: TransactionReceiptWithDecodedLogs) => Promise<Value>) {
11+
constructor(resolver?: (receipt: Receipt) => Promise<Value>) {
1112
if (!resolver) {
1213
this.resolver = async () => undefined;
1314
return;
@@ -16,13 +17,15 @@ export class PostTransactionResolver<Value extends any> {
1617
this.resolver = resolver;
1718
}
1819

19-
public async run(receipt: TransactionReceiptWithDecodedLogs) {
20+
public async run(receipt: Receipt) {
2021
const result = await this.resolver(receipt);
2122

2223
this.result = result;
2324
}
2425
}
2526

26-
export function isPostTransactionResolver<T = any>(val: any): val is PostTransactionResolver<T> {
27+
export function isPostTransactionResolver<T = any, R = TransactionReceiptWithDecodedLogs>(
28+
val: any
29+
): val is PostTransactionResolver<T, R> {
2730
return val instanceof PostTransactionResolver;
2831
}

src/browserUtils.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,7 @@ export async function getCurrentAddress() {
170170
export function onAddressChange(cb: (newAddress: string, previousAddress?: string) => void) {
171171
if (isUnsupported(window as ExtendedWindow)) {
172172
// eslint-disable-next-line no-console
173-
console.warn(
174-
'"onAddressChange" Was called, but the current browser does not support Ethereum.'
175-
);
173+
console.warn('"onAddressChange" Was called, but the current browser does not support Ethereum');
176174
return () => {};
177175
}
178176

@@ -206,9 +204,7 @@ export function onAddressChange(cb: (newAddress: string, previousAddress?: strin
206204
export function onNetworkChange(cb: (newNetwork: number, previousNetwork?: number) => void) {
207205
if (isUnsupported(window as ExtendedWindow)) {
208206
// eslint-disable-next-line no-console
209-
console.warn(
210-
'"onNetworkChange" Was called, but the current browser does not support Ethereum.'
211-
);
207+
console.warn('"onNetworkChange" Was called, but the current browser does not support Ethereum');
212208
return () => {};
213209
}
214210

src/entities/CappedSto.ts

Lines changed: 0 additions & 64 deletions
This file was deleted.

src/entities/Checkpoint.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class Checkpoint extends Entity<Params> {
3838
if (!isUniqueIdentifiers(unserialized)) {
3939
throw new PolymathError({
4040
code: ErrorCode.InvalidUuid,
41-
message: 'Wrong Checkpoint ID format.',
41+
message: 'Wrong Checkpoint ID format',
4242
});
4343
}
4444

src/entities/DividendDistribution.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export class DividendDistribution extends Entity<Params> {
5555
if (!isUniqueIdentifiers(unserialized)) {
5656
throw new PolymathError({
5757
code: ErrorCode.InvalidUuid,
58-
message: 'Wrong Dividend Distribution ID format.',
58+
message: 'Wrong Dividend Distribution ID format',
5959
});
6060
}
6161

src/entities/DividendsManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export abstract class DividendsManager<P> extends Entity<P> {
3939
if (!isUniqueIdentifiers(unserialized)) {
4040
throw new PolymathError({
4141
code: ErrorCode.InvalidUuid,
42-
message: 'Wrong Dividends Manager ID format.',
42+
message: 'Wrong Dividends Manager ID format',
4343
});
4444
}
4545

src/entities/Erc20TokenBalance.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class Erc20TokenBalance extends Entity<Params> {
3434
if (!isUniqueIdentifiers(unserialized)) {
3535
throw new PolymathError({
3636
code: ErrorCode.InvalidUuid,
37-
message: 'Wrong ERC20 Token Balance ID format.',
37+
message: 'Wrong ERC20 Token Balance ID format',
3838
});
3939
}
4040

0 commit comments

Comments
 (0)