-
Notifications
You must be signed in to change notification settings - Fork 10
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
Temporal for transfers #965
base: dev
Are you sure you want to change the base?
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
cb8b1c0
to
6ed7a67
Compare
6ed7a67
to
9fd4d1c
Compare
8b23b52
to
6d8bd56
Compare
6d8bd56
to
df2de64
Compare
9fd4d1c
to
ce971eb
Compare
808686b
to
5088a28
Compare
5088a28
to
6ed4516
Compare
1fc06c7
to
e02b9a7
Compare
|
||
const workflowId = await transfer({ userOp }) | ||
|
||
if (workflowId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are there cases where we don't get a workflowId? we should throw an error if we don't get one back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we throw in the temporal api
sendapp/packages/api/src/routers/temporal.ts
Lines 27 to 48 in d623de1
try { | |
const client = await getTemporalClient() | |
const chainId = baseMainnetClient.chain.id | |
const entryPoint = entryPointAddress[chainId] | |
const userOpHash = getUserOperationHash({ | |
userOperation: userOp, | |
entryPoint, | |
chainId, | |
}) | |
const { workflowId } = await client.workflow.start(TransferWorkflow, { | |
taskQueue: 'monorepo', | |
workflowId: `temporal/transfer/${user.id}/${userOpHash}`, | |
args: [userOp], | |
}) | |
log(`Workflow Created: ${workflowId}`) | |
return workflowId | |
} catch (error) { | |
throw new TRPCError({ | |
code: 'INTERNAL_SERVER_ERROR', | |
message: error instanceof Error ? error.message : 'Unknown error', | |
}) | |
} |
the catch should handle it. Though we could probably clean it up
supabase/migrations/20250307021828_create_temporal_transfers_table.sql
Outdated
Show resolved
Hide resolved
supabase/migrations/20250307021828_create_temporal_transfers_table.sql
Outdated
Show resolved
Hide resolved
supabase/migrations/20250307021828_create_temporal_transfers_table.sql
Outdated
Show resolved
Hide resolved
left join profiles from_p on a.from_user_id = from_p.id | ||
left join profiles to_p on a.to_user_id = to_p.id | ||
where a.from_user_id = ( select auth.uid() ) | ||
or (a.to_user_id = ( select auth.uid() ) and a.event_name not like 'temporal_%') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is so we don't show pending transfers to the recipient right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah
supabase/migrations/20250307021828_create_temporal_transfers_table.sql
Outdated
Show resolved
Hide resolved
better db error handling
Combine update and insert triggers
LANGUAGE plpgsql | ||
SECURITY DEFINER | ||
AS $$ | ||
BEGINa |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo
CREATE TABLE temporal.send_account_transfers( | ||
id serial primary key, | ||
workflow_id text not null, | ||
user_id uuid not null DEFAULT uuid_nil(), -- rely on trigger to set user_id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should not set a default then.
|
||
-- Validate user_id | ||
IF _user_id IS NULL THEN | ||
RAISE EXCEPTION 'No user found for the given address'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm. most likely not going to happen, but instead of blocking the write. Let's just raise a notice with the workflow ID and then return early.
CREATE INDEX temporal_send_account_transfers_created_at_idx ON temporal.send_account_transfers(created_at); | ||
CREATE UNIQUE INDEX temporal_send_account_transfers_workflow_id_idx ON temporal.send_account_transfers(workflow_id); | ||
|
||
CREATE OR REPLACE FUNCTION temporal.handle_transfer_upsert() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe a one liner comment explaining why this is a good idea or why we did it this way
db55fb2
to
88e55be
Compare
Create transfer tempora workflow
New trpc route that starts transfer workflow
Encapsulate temporal into a package
Call transfer trpc mutation from frontend
Create transfer temporal workflow
Encapsulate temporal into a package
Create transfer tempora workflow
Encapsulate temporal into a package
Temporal cloud changes
remove debug env
Show pending transfers from temporal in UI