generated from PolymeshAssociation/typescript-boilerplate
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
1 parent
390aa05
commit edff37f
Showing
5 changed files
with
78 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { setIssuanceData } from '~/api/procedures'; | ||
import { Namespace, TransactionQueue } from '~/base'; | ||
import { IssuanceData } from '~/types'; | ||
|
||
import { SecurityToken } from './'; | ||
|
||
/** | ||
* Handles all Security Token Issuance related functionality | ||
*/ | ||
export class Issuance extends Namespace<SecurityToken> { | ||
/** | ||
* Issue a certain amount of tokens to a one or multiple DIDs. The investor must be an acredited client. | ||
* | ||
* @param args.issuances - array that specifies who to issue tokens to and which amounts | ||
*/ | ||
public issue(args: { issuances: IssuanceData[] }): Promise<TransactionQueue<SecurityToken>> { | ||
const { | ||
parent: { ticker }, | ||
context, | ||
} = this; | ||
return setIssuanceData.prepare({ ticker, ...args }, context); | ||
} | ||
} |
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,41 @@ | ||
import { SecurityToken } from '~/api/entities'; | ||
import { PolymeshError, Procedure } from '~/base'; | ||
import { ErrorCode, IssuanceData, Role, RoleType } from '~/types'; | ||
import { stringToTicker } from '~/utils'; | ||
|
||
export interface SetIssuanceDataParams { | ||
issuances: IssuanceData[]; | ||
} | ||
|
||
export type Params = SetIssuanceDataParams & { | ||
ticker: string; | ||
}; | ||
|
||
/** | ||
* @hidden | ||
*/ | ||
export async function prepareSetIssuanceData( | ||
this: Procedure<Params, SecurityToken>, | ||
args: Params | ||
): Promise<SecurityToken> { | ||
const { | ||
context: { | ||
polymeshApi: { query, tx }, | ||
}, | ||
context, | ||
} = this; | ||
const { ticker, issuances } = args; | ||
|
||
const rawTicker = stringToTicker(ticker, context); | ||
|
||
return new SecurityToken({ ticker }, context); | ||
} | ||
|
||
/** | ||
* @hidden | ||
*/ | ||
export function getRequiredRoles({ ticker }: Params): Role[] { | ||
return [{ type: RoleType.TokenOwner, ticker }]; | ||
} | ||
|
||
export const setIssuanceData = new Procedure(prepareSetIssuanceData, getRequiredRoles); |
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