-
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 address and nonce to tx model
also adds offline request model, and revert script to run migrations down
- Loading branch information
1 parent
d665053
commit aaf685b
Showing
15 changed files
with
103 additions
and
20 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
23 changes: 23 additions & 0 deletions
23
src/datastore/postgres/migrations/1705074621853-offline.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,23 @@ | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
||
export class Offline1705074621853 implements MigrationInterface { | ||
name = 'Offline1705074621853'; | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query('ALTER TABLE "offline_tx" ADD "address" text'); | ||
await queryRunner.query('UPDATE "offline_tx" SET "address" = \'\' WHERE "address" IS NULL'); | ||
await queryRunner.query('ALTER TABLE "offline_tx" ALTER COLUMN "address" SET NOT NULL'); | ||
await queryRunner.query('ALTER TABLE "offline_tx" ADD "nonce" integer'); | ||
await queryRunner.query('UPDATE "offline_tx" SET "nonce" = -1 WHERE "nonce" IS NULL'); | ||
await queryRunner.query('ALTER TABLE "offline_tx" ALTER COLUMN "nonce" SET NOT NULL'); | ||
|
||
await queryRunner.query('CREATE INDEX idx_address_nonce ON offline_tx (address, nonce)'); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query('DROP INDEX idx_address_nonce'); | ||
|
||
await queryRunner.query('ALTER TABLE "offline_tx" DROP COLUMN "nonce"'); | ||
await queryRunner.query('ALTER TABLE "offline_tx" DROP COLUMN "address"'); | ||
} | ||
} |
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,22 @@ | ||
/* istanbul ignore file */ | ||
|
||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { TransactionPayload } from '@polymeshassociation/polymesh-sdk/types'; | ||
import { IsString } from 'class-validator'; | ||
|
||
export class OfflineRequestModel { | ||
@ApiProperty({ | ||
description: 'The internal ID', | ||
}) | ||
@IsString() | ||
id: string; | ||
|
||
@ApiProperty({ | ||
description: 'The transaction payload to be signed', | ||
}) | ||
payload: TransactionPayload; | ||
|
||
constructor(model: OfflineRequestModel) { | ||
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
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