-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce support for custom gas in transaction request
Implement an initial design for a flexible request action type featuring custom decoding and encoding schemas. Refactor request and response DTOs to accommodate BigInt.
- Loading branch information
1 parent
24b0cfc
commit 5e9ee9d
Showing
26 changed files
with
554 additions
and
190 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 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
17 changes: 17 additions & 0 deletions
17
apps/orchestration/src/policy-engine/http/rest/dto/validator/evaluation.dto.ts
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 @@ | ||
import { ApiProperty } from '@nestjs/swagger' | ||
|
||
export class EvaluationDto { | ||
@ApiProperty() | ||
id: string | ||
|
||
@ApiProperty() | ||
decision: string | ||
|
||
@ApiProperty({ | ||
type: String | ||
}) | ||
signature?: string | null | ||
|
||
@ApiProperty() | ||
createdAt: Date | ||
} |
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
14 changes: 14 additions & 0 deletions
14
apps/orchestration/src/policy-engine/http/rest/dto/validator/signature.dto.ts
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 @@ | ||
import { ApiProperty } from '@nestjs/swagger' | ||
import { IsDefined, IsString } from 'class-validator' | ||
|
||
export class SignatureDto { | ||
@IsDefined() | ||
@IsString() | ||
@ApiProperty() | ||
hash: string | ||
|
||
@ApiProperty({ | ||
enum: ['ECDSA'] | ||
}) | ||
type?: string = 'ECDSA' | ||
} |
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,40 @@ | ||
import { Action, CreateAuthorizationRequest } from '@app/orchestration/policy-engine/core/type/domain.type' | ||
import { AuthorizationRequestDto } from '@app/orchestration/policy-engine/http/rest/dto/authorization-request.dto' | ||
import { plainToInstance } from 'class-transformer' | ||
|
||
// Not in love with the gymnastics required to bend a DTO to a domain object. | ||
// Most of the complexity came from the discriminated union type. | ||
// It's fine for now to keep it ugly here but I'll look at the problem later | ||
export const toCreateAuthorizationRequest = ( | ||
orgId: string, | ||
body: AuthorizationRequestDto | ||
): CreateAuthorizationRequest => { | ||
const dto = plainToInstance(AuthorizationRequestDto, body) | ||
const shared = { | ||
orgId, | ||
initiatorId: '97389cac-20f0-4d02-a3a9-b27c564ffd18', | ||
hash: dto.hash, | ||
evaluations: [] | ||
} | ||
|
||
if (dto.isSignMessage(dto.request)) { | ||
return { | ||
...shared, | ||
action: Action.SIGN_MESSAGE, | ||
request: { | ||
message: dto.request.message | ||
} | ||
} | ||
} | ||
|
||
return { | ||
...shared, | ||
action: Action.SIGN_TRANSACTION, | ||
request: { | ||
from: dto.request.from, | ||
to: dto.request.to, | ||
data: dto.request.data, | ||
gas: dto.request.gas | ||
} | ||
} | ||
} |
Oops, something went wrong.