-
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.
Merge pull request #31 from vulcanize/feature/VUL-120-Storage-Watchin…
…g-part-2 VUL-120 storage watching part 2
- Loading branch information
Showing
13 changed files
with
911 additions
and
168 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,14 @@ | ||
import {MigrationInterface, QueryRunner} from "typeorm"; | ||
|
||
export class StateVariable1606457557226 implements MigrationInterface { | ||
name = 'StateVariable1606457557226' | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`ALTER TABLE "contract"."state" ADD "variable" character varying`); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`ALTER TABLE "contract"."state" DROP COLUMN "variable"`); | ||
} | ||
|
||
} |
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,26 @@ | ||
import {EntityRepository, QueryRunner} from 'typeorm'; | ||
|
||
@EntityRepository() | ||
export default class EventRepository { | ||
private queryRunner: QueryRunner; | ||
|
||
constructor(queryRunner: QueryRunner) { | ||
this.queryRunner = queryRunner; | ||
} | ||
|
||
public async add(tableName: string, data): Promise<number> { | ||
const sql = `INSERT INTO ${tableName} | ||
(${data.map((line) => line.isStrict ? line.name : 'data_' + line.name.toLowerCase().trim()).join(',')}) | ||
VALUES | ||
('${data.map((line) => line.value.toString().replace(/\0/g, '')).join('\',\'')}') RETURNING id;`; | ||
|
||
console.log(sql); | ||
|
||
const res = await this.queryRunner.query(sql); | ||
if (!res) { | ||
return null; | ||
} | ||
|
||
return res[0].id; | ||
} | ||
} |
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 @@ | ||
import {EntityRepository, QueryRunner} from 'typeorm'; | ||
|
||
@EntityRepository() | ||
export default class SlotRepository { | ||
private queryRunner: QueryRunner; | ||
|
||
constructor(queryRunner: QueryRunner) { | ||
this.queryRunner = queryRunner; | ||
} | ||
|
||
public async add(tableName: string, name: string[], value): Promise<number> { | ||
const sql = `INSERT INTO ${tableName} (${name.join(',')}) VALUES ('${value.map((v) => v.toString().replace(/\0/g, '')).join('\',\'')}') RETURNING id;`; | ||
console.log(sql); | ||
|
||
const res = await this.queryRunner.query(sql); | ||
if (!res) { | ||
return null; | ||
} | ||
|
||
return res[0].id; | ||
} | ||
} |
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.