Skip to content

Commit

Permalink
fix: Postgresql syntax (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
CjHare authored Sep 26, 2022
1 parent 9c5b6ce commit 6b5a0ab
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
15 changes: 8 additions & 7 deletions scripts/sql/create_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,30 @@ CREATE TABLE delegation
proof TEXT,
delegated_weight BIGINT,
delegated_block BIGINT,
PRIMARY KEY (token_address,
delegator_address,
PRIMARY KEY (delegator_address,
delegatee_address)
);
CREATE INDEX delegation_index_delegator
ON delegation (
token_address,
delegator_address
);
CREATE INDEX delegation_index_delegatee
ON delegation (
delegatee_address
);

-- Delegators delegate their voting power to Delegatees
CREATE TABLE delegators
(
delegator_address CHAR(20),
delegator_address CHAR(20) PRIMARY KEY,
trie_root CHAR(32),
delegated_block BIGINT,
PRIMARY KEY delegator_address
delegated_block BIGINT
);

-- The single supported token's address, with support for contract migration
CREATE TABLE token
(
contract_address CHAR(20),
contract_address CHAR(20) PRIMARY KEY,
delegation_from_block BIGINT,
delegated_to_block BIGINT
);
4 changes: 2 additions & 2 deletions src/handler/get-voting-power.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ export const handler = async (
throwError('Missing tokenAddress parameter')

const result = await Database.pool().query({
name: 'fetch-delegation-by-token-address',
text: 'SELECT * FROM delegation WHERE token_address = $1',
name: 'fetch-delegation-by-delegator-address',
text: 'SELECT * FROM delegation WHERE delegator_address = $1',
values: [address]
})

Expand Down
4 changes: 2 additions & 2 deletions src/handler/mass-delegation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ export const handler = async (
throwError('Missing tokenAddress parameter')

const result = await Database.pool().query({
name: 'fetch-delegation-by-token-address',
text: 'SELECT * FROM delegation WHERE token_address = $1',
name: 'fetch-delegation-by-delegator-address',
text: 'SELECT * FROM delegation WHERE delegator_address = $1',
values: [address]
})

Expand Down

0 comments on commit 6b5a0ab

Please sign in to comment.