-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 🎸 Add support for off-chain settlement legs
* Modifies endpoints 1. `POST venues/create` to support optional property `signers` in the request body (`CreateVenueDto`) to specify list of addresses allowed to sign off chain receipts for instructions of the venue 2. `POST venues/:id/instructions/create` a. to support new optional attribute `endAfterBlock` in request body (`CreateInstructionDto`)to allow creation of instruction that can be executed manually after this given block. b. to add support for off chain legs by adding new optional type `OffChainLegDto` to type of legs 3. `POST instructions/:id/affirm` to support optional attributes `portfolios` and `receipts` in the request body (`AffirmInstructionDto`) to specify specific portfolios to affirm or the details of the off chain leg receipt to be used to affirm off chain legs * Adds new endpoints 1. `POST venues/:id/add-signers` and `POST venues/:id/remove-signers` to add/remove allowed signers from a Venue 2. `GET accounts/:id/receipts` to get all off chain receipts redeemed by an account 3. `GET instructions/:id/offchain-affirmations` to fetch all off chain affirmations status for all off chain legs in an instruction 4. `GET instructions/:id/offchain-affirmations/:legId` to fetch off chain affirmation status for a specific leg in an instruction 5. `POST instructions/:id/execute-manually` to execute an instruction manually
- Loading branch information
1 parent
b97e686
commit 7aa196c
Showing
37 changed files
with
1,446 additions
and
386 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 |
---|---|---|
|
@@ -30,6 +30,7 @@ | |
"Isin", | ||
"metatype", | ||
"nand", | ||
"offChain", | ||
"Permissioned", | ||
"polkadot", | ||
"Polymesh", | ||
|
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 |
---|---|---|
|
@@ -47,3 +47,8 @@ export enum ProcessMode { | |
|
||
AMQP = 'AMQP', | ||
} | ||
|
||
export enum LegType { | ||
offChain = 'offChain', | ||
onChain = 'onChain', | ||
} |
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,32 @@ | ||
/* istanbul ignore file */ | ||
|
||
import { ApiPropertyOptional } from '@nestjs/swagger'; | ||
import { Type } from 'class-transformer'; | ||
import { IsOptional, ValidateNested } from 'class-validator'; | ||
|
||
import { TransactionBaseDto } from '~/common/dto/transaction-base-dto'; | ||
import { PortfolioDto } from '~/portfolios/dto/portfolio.dto'; | ||
import { OffChainAffirmationReceiptDto } from '~/settlements/dto/offchain-affirmation-receipt.dto'; | ||
|
||
export class AffirmInstructionDto extends TransactionBaseDto { | ||
@ApiPropertyOptional({ | ||
description: 'List of portfolios that the signer controls and wants to affirm the instruction', | ||
type: () => PortfolioDto, | ||
isArray: true, | ||
}) | ||
@IsOptional() | ||
@ValidateNested({ each: true }) | ||
@Type(() => PortfolioDto) | ||
readonly portfolios?: PortfolioDto[]; | ||
|
||
@ApiPropertyOptional({ | ||
description: | ||
'List of off chain receipts required for affirming off chain legs(if any) in the instruction', | ||
type: () => OffChainAffirmationReceiptDto, | ||
isArray: true, | ||
}) | ||
@IsOptional() | ||
@ValidateNested({ each: true }) | ||
@Type(() => OffChainAffirmationReceiptDto) | ||
readonly receipts?: OffChainAffirmationReceiptDto[]; | ||
} |
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,28 @@ | ||
/* istanbul ignore file */ | ||
|
||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { IsEnum } from 'class-validator'; | ||
|
||
import { IsTicker } from '~/common/decorators/validation'; | ||
import { LegType } from '~/common/types'; | ||
|
||
export class AssetLegDto { | ||
@ApiProperty({ | ||
description: 'Ticker of the Asset', | ||
example: 'TICKER', | ||
}) | ||
@IsTicker() | ||
readonly asset: string; | ||
|
||
@ApiProperty({ | ||
description: 'Indicator to know if the transfer is on chain or off chain', | ||
enum: LegType, | ||
type: 'string', | ||
}) | ||
@IsEnum(LegType) | ||
readonly type: LegType; | ||
|
||
constructor(dto: AssetLegDto) { | ||
Object.assign(this, dto); | ||
} | ||
} |
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,17 @@ | ||
/* istanbul ignore file */ | ||
|
||
import { ApiPropertyOptional } from '@nestjs/swagger'; | ||
import { IsBoolean, IsOptional } from 'class-validator'; | ||
|
||
import { TransactionBaseDto } from '~/common/dto/transaction-base-dto'; | ||
|
||
export class ExecuteInstructionDto extends TransactionBaseDto { | ||
@ApiPropertyOptional({ | ||
description: 'Set to `true` to skip affirmation check, useful for batch transactions', | ||
type: 'boolean', | ||
example: false, | ||
}) | ||
@IsOptional() | ||
@IsBoolean() | ||
readonly skipAffirmationCheck?: boolean; | ||
} |
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,13 @@ | ||
/* istanbul ignore file */ | ||
|
||
import { BigNumber } from '@polymeshassociation/polymesh-sdk'; | ||
|
||
import { ToBigNumber } from '~/common/decorators/transformation'; | ||
import { IsBigNumber } from '~/common/decorators/validation'; | ||
import { IdParamsDto } from '~/common/dto/id-params.dto'; | ||
|
||
export class LegIdParamsDto extends IdParamsDto { | ||
@IsBigNumber() | ||
@ToBigNumber() | ||
readonly legId: BigNumber; | ||
} |
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
Oops, something went wrong.