-
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 endpoints to manage multi sig accounts
add endpoints to create and modify multiSigs, get proposal details and approve/reject them
- Loading branch information
1 parent
aac249b
commit 07d38f5
Showing
24 changed files
with
931 additions
and
11 deletions.
There are no files selected for viewing
Empty file.
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,27 @@ | ||
/* istanbul ignore file */ | ||
|
||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { BigNumber } from '@polymeshassociation/polymesh-sdk'; | ||
import { IsString } from 'class-validator'; | ||
|
||
import { IsBigNumber, ToBigNumber } from '~/common/decorators'; | ||
import { TransactionBaseDto } from '~/common/dto/transaction-base-dto'; | ||
|
||
export class CreateMultiSigDto extends TransactionBaseDto { | ||
@ApiProperty({ | ||
description: 'The number of approvals required in order for a proposal to be accepted', | ||
example: '1', | ||
}) | ||
@IsBigNumber() | ||
@ToBigNumber() | ||
readonly requiredSignatures: BigNumber; | ||
|
||
@ApiProperty({ | ||
description: 'The signers for the MultiSig', | ||
type: 'string', | ||
isArray: true, | ||
example: ['5GwwYnwCYcJ1Rkop35y7SDHAzbxrCkNUDD4YuCUJRPPXbvyV'], | ||
}) | ||
@IsString({ each: true }) | ||
readonly signers: string[]; | ||
} |
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,29 @@ | ||
/* istanbul ignore file */ | ||
|
||
import { ApiPropertyOptional } from '@nestjs/swagger'; | ||
import { Type } from 'class-transformer'; | ||
import { IsBoolean, IsOptional, ValidateNested } from 'class-validator'; | ||
|
||
import { TransactionBaseDto } from '~/common/dto/transaction-base-dto'; | ||
import { IsPermissionsLike } from '~/identities/decorators/validation'; | ||
import { PermissionsLikeDto } from '~/identities/dto/permissions-like.dto'; | ||
|
||
export class JoinCreatorDto extends TransactionBaseDto { | ||
@ApiPropertyOptional({ | ||
description: 'Whether or not to join the creator as the new primary key', | ||
type: 'boolean', | ||
}) | ||
@IsOptional() | ||
@IsBoolean() | ||
readonly asPrimary?: boolean; | ||
|
||
@ApiPropertyOptional({ | ||
description: 'Permissions to be granted to the multiSig if joining as a `secondaryAccount`', | ||
type: PermissionsLikeDto, | ||
}) | ||
@IsOptional() | ||
@ValidateNested() | ||
@Type(() => PermissionsLikeDto) | ||
@IsPermissionsLike() | ||
readonly permissions?: PermissionsLikeDto; | ||
} |
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 { BigNumber } from '@polymeshassociation/polymesh-sdk'; | ||
import { IsString } from 'class-validator'; | ||
|
||
import { IsBigNumber, ToBigNumber } from '~/common/decorators'; | ||
import { TransactionBaseDto } from '~/common/dto/transaction-base-dto'; | ||
|
||
export class ModifyMultiSigDto extends TransactionBaseDto { | ||
@ApiProperty({ | ||
description: 'The number of approvals required in order for a proposal to be accepted', | ||
example: '2', | ||
type: 'string', | ||
}) | ||
@IsBigNumber() | ||
@ToBigNumber() | ||
readonly requiredSignatures: BigNumber; | ||
|
||
@ApiProperty({ | ||
description: 'The signers for the MultiSig', | ||
type: 'string', | ||
isArray: true, | ||
example: ['5GwwYnwCYcJ1Rkop35y7SDHAzbxrCkNUDD4YuCUJRPPXbvyV'], | ||
}) | ||
@IsString({ each: true }) | ||
readonly signers: string[]; | ||
} |
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,14 @@ | ||
/* istanbul ignore file */ | ||
|
||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { IsString } from 'class-validator'; | ||
|
||
export class MultiSigParamsDto { | ||
@ApiProperty({ | ||
description: 'The address of the MultiSig', | ||
example: '5HCKs1tNprs5S1pHHmsHXaQacSQbYDhLUCyoMZiM7KT8JkNb', | ||
type: 'string', | ||
}) | ||
@IsString() | ||
readonly multiSigAddress: string; | ||
} |
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,26 @@ | ||
/* istanbul ignore file */ | ||
|
||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { BigNumber } from '@polymeshassociation/polymesh-sdk'; | ||
import { IsString } from 'class-validator'; | ||
|
||
import { IsBigNumber, ToBigNumber } from '~/common/decorators'; | ||
|
||
export class MultiSigProposalParamsDto { | ||
@ApiProperty({ | ||
description: 'The MultiSig address', | ||
type: 'string', | ||
example: '5HCKs1tNprs5S1pHHmsHXaQacSQbYDhLUCyoMZiM7KT8JkNb', | ||
}) | ||
@IsString() | ||
readonly multiSigAddress: string; | ||
|
||
@ApiProperty({ | ||
description: 'The proposal ID', | ||
type: 'string', | ||
example: '7', | ||
}) | ||
@IsBigNumber() | ||
@ToBigNumber() | ||
readonly proposalId: 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* istanbul ignore file */ | ||
|
||
import { ApiProperty } from '@nestjs/swagger'; | ||
|
||
import { TransactionQueueModel } from '~/common/models/transaction-queue.model'; | ||
|
||
export class MultiSigCreatedModel extends TransactionQueueModel { | ||
@ApiProperty({ | ||
description: 'The address of the multiSig', | ||
type: 'string', | ||
example: '5HCKs1tNprs5S1pHHmsHXaQacSQbYDhLUCyoMZiM7KT8JkNb', | ||
}) | ||
readonly multiSigAddress: string; | ||
|
||
constructor(model: MultiSigCreatedModel) { | ||
const { transactions, details, ...rest } = model; | ||
|
||
super({ transactions, details }); | ||
|
||
Object.assign(this, rest); | ||
} | ||
} |
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,87 @@ | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { BigNumber } from '@polymeshassociation/polymesh-sdk'; | ||
import { | ||
Account, | ||
AnyJson, | ||
ProposalStatus, | ||
TxTag, | ||
TxTags, | ||
} from '@polymeshassociation/polymesh-sdk/types'; | ||
|
||
import { FromBigNumber, FromEntityObject } from '~/common/decorators'; | ||
import { getTxTags } from '~/common/utils'; | ||
|
||
export class MultiSigProposalDetailsModel { | ||
@ApiProperty({ | ||
description: 'The number of approvals this proposal has received', | ||
type: 'string', | ||
example: '1', | ||
}) | ||
@FromBigNumber() | ||
approvalAmount: BigNumber; | ||
|
||
@ApiProperty({ | ||
description: 'The number of rejections this proposal has received', | ||
type: 'string', | ||
example: '0', | ||
}) | ||
@FromBigNumber() | ||
rejectionAmount: BigNumber; | ||
|
||
@ApiProperty({ | ||
description: 'The current status of the proposal', | ||
enum: ProposalStatus, | ||
type: 'string', | ||
example: ProposalStatus.Active, | ||
}) | ||
readonly status: string; | ||
|
||
@ApiProperty({ | ||
description: | ||
"An optional time in which this proposal will expire if a decision isn't reached by then", | ||
example: null, | ||
}) | ||
readonly expiry: Date | null; | ||
|
||
@ApiProperty({ | ||
description: | ||
'Determines if the proposal will automatically be closed once a threshold of reject votes has been reached', | ||
type: 'boolean', | ||
example: true, | ||
}) | ||
readonly autoClose: boolean; | ||
|
||
@ApiProperty({ | ||
description: 'The tag for the transaction being proposed for the MultiSig to execute', | ||
type: 'string', | ||
enum: getTxTags(), | ||
example: TxTags.asset.Issue, | ||
}) | ||
readonly txTag: TxTag; | ||
|
||
@ApiProperty({ | ||
description: 'The arguments to be passed to the transaction for this proposal', | ||
type: 'string', | ||
example: { | ||
ticker: '0x5449434b4552000000000000', | ||
amount: 1000000000, | ||
portfolio_kind: { | ||
default: null, | ||
}, | ||
}, | ||
}) | ||
readonly args: AnyJson; | ||
|
||
@ApiProperty({ | ||
description: 'Accounts of signing keys that have already voted on this proposal', | ||
isArray: true, | ||
type: 'string', | ||
example: ['5EyGPbr94Hw2r5kYR4eW21U9CuNwW87pk2bpkR5WGE2STK2r'], | ||
}) | ||
@FromEntityObject() | ||
voted: Account[]; | ||
|
||
constructor(model: MultiSigProposalDetailsModel) { | ||
Object.assign(this, model); | ||
} | ||
} |
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,51 @@ | ||
/* istanbul ignore file */ | ||
|
||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { BigNumber } from '@polymeshassociation/polymesh-sdk'; | ||
|
||
import { FromBigNumber } from '~/common/decorators'; | ||
import { MultiSigProposalDetailsModel } from '~/multi-sigs/models/multi-sig-proposal-details.model'; | ||
|
||
export class MultiSigProposalModel { | ||
@ApiProperty({ | ||
description: 'The multiSig for which the proposal if for', | ||
type: 'string', | ||
example: '5EjsqfmY4JqMSrt7YQCe3if5DK4FrG98uUwZsaXmNW7aKdNM', | ||
}) | ||
readonly multiSigAddress: string; | ||
|
||
@ApiProperty({ | ||
description: 'The ID of the proposal', | ||
example: '1', | ||
}) | ||
@FromBigNumber() | ||
readonly proposalId: BigNumber; | ||
|
||
@ApiProperty({ | ||
description: 'Proposal details', | ||
example: { | ||
approvalAmount: '1', | ||
rejectionAmount: '0', | ||
status: 'Active', | ||
expiry: null, | ||
autoClose: true, | ||
args: { | ||
ticker: '0x5449434b4552000000000000', | ||
amount: 1000000000, | ||
portfolio_kind: { | ||
default: null, | ||
}, | ||
}, | ||
txTag: 'asset.issue', | ||
voted: ['5EyGPbr94Hw2r5kYR4eW21U9CuNwW87pk2bpkR5WGE2STK2r'], | ||
}, | ||
}) | ||
readonly details: MultiSigProposalDetailsModel; | ||
|
||
constructor(model: MultiSigProposalModel) { | ||
const { details: rawDetails, ...rest } = model; | ||
const details = new MultiSigProposalDetailsModel(rawDetails); | ||
|
||
Object.assign(this, { ...rest, details }); | ||
} | ||
} |
Oops, something went wrong.