Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Z 344 remove incoming transfers sub #293

Merged
merged 2 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/dbschema/edgeql-js/__spec__.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion api/dbschema/edgeql-js/modules/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -705,10 +705,10 @@ export type $TransferlikeλShape = $.typeutil.flatten<$EventλShape & {
"amount": $.PropertyDesc<_std.$decimal, $.Cardinality.One, false, false, false, false>;
"from": $.PropertyDesc<$Address, $.Cardinality.One, false, false, false, false>;
"incoming": $.PropertyDesc<_std.$bool, $.Cardinality.One, false, false, false, false>;
"isFeeTransfer": $.PropertyDesc<_std.$bool, $.Cardinality.One, false, false, false, true>;
"outgoing": $.PropertyDesc<_std.$bool, $.Cardinality.One, false, false, false, false>;
"to": $.PropertyDesc<$Address, $.Cardinality.One, false, false, false, false>;
"spentBy": $.LinkDesc<$Policy, $.Cardinality.AtMostOne, {}, false, false, false, false>;
"fee": $.PropertyDesc<_std.$bool, $.Cardinality.One, false, false, false, true>;
}>;
type $Transferlike = $.ObjectType<"default::Transferlike", $TransferlikeλShape, null, [
...$Event['__exclusives__'],
Expand Down
2 changes: 1 addition & 1 deletion api/dbschema/events.esdl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module default {
required amount: decimal;
required incoming: bool;
required outgoing: bool;
required isFeeTransfer: bool { default := false; }
required fee: bool { default := false; }
spentBy: Policy { rewrite insert, update using (__subject__.result.transaction.policy) }

access policy members_can_select_insert
Expand Down
2 changes: 1 addition & 1 deletion api/dbschema/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,10 @@ export namespace $default {
"amount": string;
"from": string;
"incoming": boolean;
"isFeeTransfer": boolean;
"outgoing": boolean;
"to": string;
"spentBy"?: Policy | null;
"fee": boolean;
}
export interface Transfer extends Transferlike {}
export interface TransferApproval extends Transferlike {
Expand Down
9 changes: 9 additions & 0 deletions api/dbschema/migrations/00007-m15qj3h.edgeql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CREATE MIGRATION m15qj3htiny7zuqceuvj46wrm7yza5xyqmfuadsywsbc6tvh6vb34a
ONTO m13y2dtmcrd7yvmorrgn62mp2cakpvrcbz7p7g2rr4wk34b6ow7m7q
{
ALTER TYPE default::Transferlike {
ALTER PROPERTY isFeeTransfer {
RENAME TO fee;
};
};
};
6 changes: 3 additions & 3 deletions api/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -922,11 +922,11 @@ type Transfer implements Event & Node & Transferlike {
amount: Decimal!
block: BigInt!
confirmed: Boolean!
fee: Boolean!
from: Address!
id: ID!
incoming: Boolean!
internal: Boolean!
isFeeTransfer: Boolean!
logIndex: Float!
outgoing: Boolean!
result: Result
Expand All @@ -945,11 +945,11 @@ type TransferApproval implements Event & Node & Transferlike {
block: BigInt!
confirmed: Boolean!
delta: Decimal!
fee: Boolean!
from: Address!
id: ID!
incoming: Boolean!
internal: Boolean!
isFeeTransfer: Boolean!
logIndex: Float!
outgoing: Boolean!
result: Result
Expand Down Expand Up @@ -1012,11 +1012,11 @@ interface Transferlike implements Event & Node {
amount: Decimal!
block: BigInt!
confirmed: Boolean!
fee: Boolean!
from: Address!
id: ID!
incoming: Boolean!
internal: Boolean!
isFeeTransfer: Boolean!
logIndex: Float!
outgoing: Boolean!
result: Result
Expand Down
2 changes: 1 addition & 1 deletion api/src/feat/transfers/insert-transfer-approval.edgeql
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ with accountAddress := <UAddress>$account,
amount := <decimal>$amount,
incoming := (to = localAccount),
outgoing := (from = localAccount),
isFeeTransfer := ((result.transaction.paymaster in {from, to}) ?? false)
fee := ((result.transaction.paymaster in {from, to}) ?? false)
} unless conflict
)
select transfer;
2 changes: 1 addition & 1 deletion api/src/feat/transfers/insert-transfer-approval.query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ with accountAddress := <UAddress>$account,
amount := <decimal>$amount,
incoming := (to = localAccount),
outgoing := (from = localAccount),
isFeeTransfer := ((result.transaction.paymaster in {from, to}) ?? false)
fee := ((result.transaction.paymaster in {from, to}) ?? false)
} unless conflict
)
select transfer;`, args);
Expand Down
3 changes: 1 addition & 2 deletions api/src/feat/transfers/insert-transfer.edgeql
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@ with accountAddress := <UAddress>$account,
amount := <decimal>$amount,
incoming := (to = localAccount),
outgoing := (from = localAccount),
isFeeTransfer := ((result.transaction.paymaster in {from, to}) ?? false)
fee := ((result.transaction.paymaster in {from, to}) ?? false)
} unless conflict
)
select transfer {
id,
internal,
isFeeTransfer,
accountUsers := .account.approvers.user.id
}
6 changes: 3 additions & 3 deletions api/src/feat/transfers/insert-transfer.query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export type InsertTransferArgs = {
export type InsertTransferReturns = {
"id": string;
"internal": boolean;
"isFeeTransfer": boolean;
"fee": boolean;
"accountUsers": Array<string>;
} | null;

Expand Down Expand Up @@ -46,13 +46,13 @@ with accountAddress := <UAddress>$account,
amount := <decimal>$amount,
incoming := (to = localAccount),
outgoing := (from = localAccount),
isFeeTransfer := ((result.transaction.paymaster in {from, to}) ?? false)
fee := ((result.transaction.paymaster in {from, to}) ?? false)
} unless conflict
)
select transfer {
id,
internal,
isFeeTransfer,
fee,
accountUsers := .account.approvers.user.id
}`, args);

Expand Down
2 changes: 1 addition & 1 deletion api/src/feat/transfers/transfers.events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export class TransfersEvents {
(payload) => payload.transfer,
);

if (!event.result && !transfer.isFeeTransfer) {
if (!event.result && !transfer.fee) {
this.log.debug(
`[${account}]: token (${token}) transfer ${
from === account ? `to ${to}` : `from ${from}`
Expand Down
2 changes: 1 addition & 1 deletion api/src/feat/transfers/transfers.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class Transferlike extends Node {
outgoing: boolean;

@Field(() => Boolean)
isFeeTransfer: boolean;
fee: boolean;

@Field(() => Policy, { nullable: true })
spentBy?: Policy;
Expand Down
2 changes: 1 addition & 1 deletion app/src/app/(nav)/[account]/(home)/activity/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@

const items = [...(a?.proposals ?? []), ...(a?.transfers ?? [])]
.map((v) => ({ ...v, section: getItemSection(v), timestamp: asDateTime(v.timestamp) }))
.sort((a, b) => asDateTime(b.timestamp).toMillis() - asDateTime(a.timestamp).toMillis());
.sort((a, b) => asDateTime(a.timestamp).toMillis() - asDateTime(b.timestamp).toMillis());

const data = [...new Set(items.map((i) => i.section))]
.sort((a, b) => sectionOrder(a) - sectionOrder(b))
Expand Down Expand Up @@ -115,7 +115,7 @@
) : null,
)
.with({ __typename: 'Transfer' }, (t) => (
<IncomingTransferItem transfer={t as any} containerStyle={containerStyle} />

Check warning on line 118 in app/src/app/(nav)/[account]/(home)/activity/index.tsx

View workflow job for this annotation

GitHub Actions / app-tests

Unexpected any. Specify a different type
))
.otherwise(() => {
throw new Error('Unexpected item type');
Expand Down Expand Up @@ -163,7 +163,7 @@
return match(item)
.with({ __typename: 'Transaction', status: 'Pending' }, () => 'Pending approval' as const)
.with({ __typename: 'Transaction', status: 'Scheduled' }, () => 'Scheduled' as const)
.with({ __typename: 'Message', signature: P.nullish }, (m) => 'Pending approval' as const)

Check warning on line 166 in app/src/app/(nav)/[account]/(home)/activity/index.tsx

View workflow job for this annotation

GitHub Actions / app-tests

'm' is defined but never used. Allowed unused args must match /^_/u
.otherwise((v) => {
const t = asDateTime(v.timestamp).startOf('day');

Expand Down
4 changes: 2 additions & 2 deletions app/src/components/transaction/TransactionTransfers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const Transaction = graphql`
amount
from
to
isFeeTransfer
fee
}
}
...TransactionValue_transaction
Expand All @@ -43,7 +43,7 @@ export function TransactionTransfers(props: TransactionTransfersProps) {
const { styles } = useStyles(stylesheet);
const t = useFragment(Transaction, props.transaction);

const transfers = t.result?.transfers?.filter((t) => !t.isFeeTransfer);
const transfers = t.result?.transfers?.filter((t) => !t.fee);

if (!transfers?.length) return null;

Expand Down
4 changes: 2 additions & 2 deletions app/src/components/transaction/TransactionValue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const Transaction = graphql`
transfers {
id
value
isFeeTransfer
fee
}
}
}
Expand All @@ -26,7 +26,7 @@ export interface TransactionValueProps {
export function TransactionValue(props: TransactionValueProps) {
const p = useFragment(Transaction, props.transaction);

const transfers = (p.result?.transfers ?? []).filter((t) => !t.isFeeTransfer);
const transfers = (p.result?.transfers ?? []).filter((t) => !t.fee);

const value = Decimal.sum(0, ...transfers.map((t) => t.value ?? 0));

Expand Down
Loading