This repository has been archived by the owner on Jul 6, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
151 changed files
with
14,108 additions
and
8,768 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { PolymathAPI, ModuleName, TransactionParams } from '../src'; | ||
import { moduleInstancesLookup } from './modules'; | ||
import { GeneralTransferManagerEvents_3_0_0 } from '@polymathnetwork/abi-wrappers'; | ||
|
||
/** | ||
* Adds investors to a security token's whitelist. Requires that a valid security token has been generated previously. | ||
* @param polymathAPI Reference to polymathAPI instance. | ||
* @param ticker Ticker of the Security Tokens | ||
* @param modifyKYCDataMultiParams Investors KYC Data Params | ||
*/ | ||
export const addInvestorsToWhitelist = async ( | ||
polymathAPI: PolymathAPI, | ||
ticker: string, | ||
modifyKYCDataMultiParams: TransactionParams.GeneralTransferManager.ModifyKYCDataMulti, | ||
) => { | ||
// Get general TM module instance | ||
const generalTM = (await moduleInstancesLookup(polymathAPI, { | ||
ticker, | ||
moduleName: ModuleName.GeneralTransferManager, | ||
}))[0]; | ||
|
||
// Subscribe to event | ||
await generalTM.subscribeAsync({ | ||
eventName: GeneralTransferManagerEvents_3_0_0.ModifyKYCData, | ||
indexFilterValues: {}, | ||
callback: async (error: any, log: any) => { | ||
if (error) { | ||
console.log(error); | ||
} else { | ||
console.log('Whitelist modified successfully', log); | ||
} | ||
}, | ||
}); | ||
|
||
// Publish kyc data to whitelist in general transfer manager | ||
await generalTM.modifyKYCDataMulti(modifyKYCDataMultiParams); | ||
|
||
console.log('KYC data:', await generalTM.getAllKYCData()); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { PolymathAPI, ModuleName, TransactionParams } from '../src'; | ||
import { moduleInstancesLookup } from './modules'; | ||
import { SecurityTokenEvents_3_0_0 } from '@polymathnetwork/abi-wrappers/lib/src'; | ||
|
||
/** | ||
* Mints the token to a specific investor. Requires a valid security token and no transfer restrictions impeding the issuance. | ||
* @param polymathAPI Reference to polymathAPI instance. | ||
* @param ticker Ticker of the Security Token | ||
* @param issueMultiParams Transaction params for issuing to multiple investors. | ||
*/ | ||
export const issueTokenToInvestors = async ( | ||
polymathAPI: PolymathAPI, | ||
ticker: string, | ||
issueMultiParams: TransactionParams.SecurityToken.IssueMulti, | ||
) => { | ||
const tokenAddress = await polymathAPI.securityTokenRegistry.getSecurityTokenAddress({ ticker: ticker! }); | ||
const tickerSecurityTokenInstance = await polymathAPI.tokenFactory.getSecurityTokenInstanceFromAddress(tokenAddress); | ||
|
||
// Subscribe to event | ||
await tickerSecurityTokenInstance.subscribeAsync({ | ||
eventName: SecurityTokenEvents_3_0_0.Issued, | ||
indexFilterValues: {}, | ||
callback: async (error: any, log: any) => { | ||
if (error) { | ||
console.log(error); | ||
} else { | ||
console.log('Tokens issued successfully', log); | ||
} | ||
}, | ||
}); | ||
|
||
// Get general TM module instance | ||
const generalTM = (await moduleInstancesLookup(polymathAPI, { | ||
ticker, | ||
moduleName: ModuleName.GeneralTransferManager, | ||
}))[0]; | ||
const listInvestors = await generalTM.getAllKYCData(); | ||
const found = listInvestors.find(function(addr: { investor: any }) { | ||
return issueMultiParams.investors.includes(addr.investor); | ||
}); | ||
// If the investors are in the whitelist, go ahead and issue multi with the params passed in. | ||
if (found) { | ||
await tickerSecurityTokenInstance.issueMulti(issueMultiParams); | ||
console.log('Tokens issued'); | ||
} else { | ||
console.log('Please make sure beneficiary address has been whitelisted'); | ||
} | ||
}; |
Oops, something went wrong.