Skip to content

Commit

Permalink
fix(api): Policy isDraft field
Browse files Browse the repository at this point in the history
  • Loading branch information
hbriese committed Jul 28, 2024
1 parent 24bf632 commit 422de4f
Show file tree
Hide file tree
Showing 8 changed files with 176 additions and 171 deletions.
2 changes: 1 addition & 1 deletion api/dbschema/bootstrap.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ configure instance set query_work_mem := <cfg::memory>"8MiB";
configure instance set shared_buffers := <cfg::memory>"2GiB";

# Total memory available to the database for caching - 75%
configure instance set effective_cache_size := <cfg::memory>"3GiB";
configure instance set effective_cache_size := <cfg::memory>"6GiB";
140 changes: 70 additions & 70 deletions api/dbschema/edgeql-js/__spec__.ts

Large diffs are not rendered by default.

154 changes: 77 additions & 77 deletions api/dbschema/edgeql-js/modules/default.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion api/dbschema/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,9 @@ export namespace $default {
"proposal"?: Transaction | null;
"initState": boolean;
"isActive": boolean;
"isDraft": boolean;
"latest"?: PolicyState | null;
"isLatest": boolean;
"isDraft": boolean;
}
export interface Policy extends PolicyState {
"approvers": Approver[];
Expand Down
9 changes: 9 additions & 0 deletions api/dbschema/migrations/00002-m1ob6ar.edgeql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CREATE MIGRATION m1ob6arfwyamzcpgk2hgzhby3iwv3moewthqacorsw2mtyjkopdoaq
ONTO m13qxppnkqofigih7dxkipm2lh6k3ahrqerachqhdzihw76nb6i3aa
{
ALTER TYPE default::PolicyState {
ALTER PROPERTY isDraft {
USING ((__source__ ?= .draft));
};
};
};
4 changes: 2 additions & 2 deletions api/dbschema/policy.esdl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module default {
required initState := .activationBlock ?= 0;
required hasBeenActive := exists .activationBlock;
required isActive := .isLatest and .hasBeenActive;
required isDraft := exists .draft;
required isDraft := (__source__ ?= .draft);
latest := (__source__ if .isLatest else latestPolicy(.account, .key));
draft := assert_single((
with account := __source__.account, key := __source__.key
Expand Down Expand Up @@ -94,9 +94,9 @@ module default {
}

type TransfersConfig {
multi limits: TransferLimit { constraint exclusive; }
required defaultAllow: bool { default := true; };
required budget: uint32;
multi limits: TransferLimit { constraint exclusive; }
}

type TransferLimit {
Expand Down
2 changes: 1 addition & 1 deletion api/edgedb.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[edgedb]
server-version = "5.4"
server-version = "5.6"
34 changes: 15 additions & 19 deletions api/src/feat/transactions/delete-transaction.query.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,28 @@
// GENERATED by @edgedb/generate v0.5.3

import type { Executor } from 'edgedb';
import type {Executor} from "edgedb";

export type DeleteTransactionArgs = {
readonly transaction: string;
readonly "transaction": string;
};

export type DeleteTransactionReturns = {
transaction: {
id: string;
account: {
address: string;
"transaction": {
"id": string;
"account": {
"address": string;
};
} | null;
deletedPolicies: Array<{
id: string;
"deletedPolicies": Array<{
"id": string;
}>;
deletedTransaction: {
id: string;
"deletedTransaction": {
"id": string;
} | null;
};

export function deleteTransaction(
client: Executor,
args: DeleteTransactionArgs,
): Promise<DeleteTransactionReturns> {
return client.queryRequiredSingle(
`\
export function deleteTransaction(client: Executor, args: DeleteTransactionArgs): Promise<DeleteTransactionReturns> {
return client.queryRequiredSingle(`\
with t := (select Transaction filter .id = <uuid>$transaction)
select {
transaction := (
Expand All @@ -35,9 +31,9 @@ select {
account: { address }
}
),
# Delete policies the proposal was going to activate
deletedPolicies := (delete t.<proposal[is PolicyState]),
deletedTransaction := (delete t)
};`,
args,
);
};`, args);

}

0 comments on commit 422de4f

Please sign in to comment.