diff --git a/.gitignore b/.gitignore index f3af7694..3a93029e 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,8 @@ - .direnv .env +.mempool_data result tmp .bacon-locations +.claude/settings.local.json diff --git a/.sqlx/query-01266b0e2f33d1b1612b14e8b2270bc1654a32b3bcd4948c49de4e56589e5d94.json b/.sqlx/query-01266b0e2f33d1b1612b14e8b2270bc1654a32b3bcd4948c49de4e56589e5d94.json new file mode 100644 index 00000000..538b59f0 --- /dev/null +++ b/.sqlx/query-01266b0e2f33d1b1612b14e8b2270bc1654a32b3bcd4948c49de4e56589e5d94.json @@ -0,0 +1,47 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM bria_profiles WHERE account_id = $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $2 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_profile_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "01266b0e2f33d1b1612b14e8b2270bc1654a32b3bcd4948c49de4e56589e5d94" +} diff --git a/.sqlx/query-03a7f3a2c86a0415f054e409f30fb66c58bb9b15d48c2e46fd4a050c5e20ff76.json b/.sqlx/query-03a7f3a2c86a0415f054e409f30fb66c58bb9b15d48c2e46fd4a050c5e20ff76.json deleted file mode 100644 index 55abcf08..00000000 --- a/.sqlx/query-03a7f3a2c86a0415f054e409f30fb66c58bb9b15d48c2e46fd4a050c5e20ff76.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "UPDATE bria_addresses\n SET external_id = $1\n WHERE account_id = $2 AND address = $3", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Varchar", - "Uuid", - "Text" - ] - }, - "nullable": [] - }, - "hash": "03a7f3a2c86a0415f054e409f30fb66c58bb9b15d48c2e46fd4a050c5e20ff76" -} diff --git a/.sqlx/query-040edae73739bda4b4d2ba3c67a90f9dc7a528b9e6dff3d56497d7d6c1db72ad.json b/.sqlx/query-040edae73739bda4b4d2ba3c67a90f9dc7a528b9e6dff3d56497d7d6c1db72ad.json deleted file mode 100644 index 4ea2460d..00000000 --- a/.sqlx/query-040edae73739bda4b4d2ba3c67a90f9dc7a528b9e6dff3d56497d7d6c1db72ad.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "SELECT p.id, e.sequence, e.event_type, e.event\n FROM bria_profiles p\n JOIN bria_profile_events e ON p.id = e.id\n WHERE p.account_id = $1 AND p.id = $2\n ORDER BY p.id, sequence", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "id", - "type_info": "Uuid" - }, - { - "ordinal": 1, - "name": "sequence", - "type_info": "Int4" - }, - { - "ordinal": 2, - "name": "event_type", - "type_info": "Varchar" - }, - { - "ordinal": 3, - "name": "event", - "type_info": "Jsonb" - } - ], - "parameters": { - "Left": [ - "Uuid", - "Uuid" - ] - }, - "nullable": [ - false, - false, - false, - false - ] - }, - "hash": "040edae73739bda4b4d2ba3c67a90f9dc7a528b9e6dff3d56497d7d6c1db72ad" -} diff --git a/.sqlx/query-044e1fb61853894f16ac0e91b68d7ed7778c2a3fd2f7ff5e03849bc83e6a2574.json b/.sqlx/query-044e1fb61853894f16ac0e91b68d7ed7778c2a3fd2f7ff5e03849bc83e6a2574.json new file mode 100644 index 00000000..25ba8749 --- /dev/null +++ b/.sqlx/query-044e1fb61853894f16ac0e91b68d7ed7778c2a3fd2f7ff5e03849bc83e6a2574.json @@ -0,0 +1,50 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (\n SELECT *\n FROM bria_payouts\n WHERE account_id = $1 AND batch_id = $2\n AND (COALESCE((created_at, id) > ($4, $3), $3 IS NULL))\n ORDER BY created_at, id) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $5 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_payout_events e ON i.id = e.id ORDER BY i.created_at, i.id, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Uuid", + "Uuid", + "Timestamptz", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "044e1fb61853894f16ac0e91b68d7ed7778c2a3fd2f7ff5e03849bc83e6a2574" +} diff --git a/.sqlx/query-05399525ae25b49630b203a708fdcb54a97c0ce3dd889d31227af99fdbb8fb98.json b/.sqlx/query-05399525ae25b49630b203a708fdcb54a97c0ce3dd889d31227af99fdbb8fb98.json new file mode 100644 index 00000000..c9909cc3 --- /dev/null +++ b/.sqlx/query-05399525ae25b49630b203a708fdcb54a97c0ce3dd889d31227af99fdbb8fb98.json @@ -0,0 +1,48 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM bria_payout_queues WHERE (COALESCE(id > $2, true)) ORDER BY id ASC LIMIT $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $3 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_payout_queue_events e ON i.id = e.id ORDER BY i.id asc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Int8", + "Uuid", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "05399525ae25b49630b203a708fdcb54a97c0ce3dd889d31227af99fdbb8fb98" +} diff --git a/.sqlx/query-07dfe35dc6e9ce9c7435aa03ba6a346ce4ced6f651af14b35bc470d17144b93f.json b/.sqlx/query-07dfe35dc6e9ce9c7435aa03ba6a346ce4ced6f651af14b35bc470d17144b93f.json deleted file mode 100644 index 25e61e24..00000000 --- a/.sqlx/query-07dfe35dc6e9ce9c7435aa03ba6a346ce4ced6f651af14b35bc470d17144b93f.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "INSERT INTO bria_wallets (id, account_id, name) VALUES ($1, $2, $3) RETURNING (id)", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "id", - "type_info": "Uuid" - } - ], - "parameters": { - "Left": [ - "Uuid", - "Uuid", - "Varchar" - ] - }, - "nullable": [ - false - ] - }, - "hash": "07dfe35dc6e9ce9c7435aa03ba6a346ce4ced6f651af14b35bc470d17144b93f" -} diff --git a/.sqlx/query-0e5fddf54f196b42026c713274e7d45a852ca8a493a874d770ae8d4b0e4ad573.json b/.sqlx/query-0e5fddf54f196b42026c713274e7d45a852ca8a493a874d770ae8d4b0e4ad573.json new file mode 100644 index 00000000..a119f48d --- /dev/null +++ b/.sqlx/query-0e5fddf54f196b42026c713274e7d45a852ca8a493a874d770ae8d4b0e4ad573.json @@ -0,0 +1,50 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT account_id, created_at, id FROM bria_payout_queues WHERE ((account_id = $1) AND (COALESCE((created_at, id) < ($4, $3), $3 IS NULL))) ORDER BY created_at DESC, id DESC LIMIT $2) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $5 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_payout_queue_events e ON i.id = e.id ORDER BY i.created_at desc, i.id desc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Int8", + "Uuid", + "Timestamptz", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "0e5fddf54f196b42026c713274e7d45a852ca8a493a874d770ae8d4b0e4ad573" +} diff --git a/.sqlx/query-0ec68ead66afd6750ba3e7cb5d87aa658670564a94034f84b0cc631ef1aa819f.json b/.sqlx/query-0ec68ead66afd6750ba3e7cb5d87aa658670564a94034f84b0cc631ef1aa819f.json new file mode 100644 index 00000000..d3fb66a6 --- /dev/null +++ b/.sqlx/query-0ec68ead66afd6750ba3e7cb5d87aa658670564a94034f84b0cc631ef1aa819f.json @@ -0,0 +1,48 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM bria_wallets WHERE (COALESCE(id > $2, true)) ORDER BY id ASC LIMIT $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $3 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_wallet_events e ON i.id = e.id ORDER BY i.id asc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Int8", + "Uuid", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "0ec68ead66afd6750ba3e7cb5d87aa658670564a94034f84b0cc631ef1aa819f" +} diff --git a/.sqlx/query-118e50dac9417b77bb821bf64ef38eb89949deb050faf4150d1aa031f109304f.json b/.sqlx/query-118e50dac9417b77bb821bf64ef38eb89949deb050faf4150d1aa031f109304f.json new file mode 100644 index 00000000..d41a4e8a --- /dev/null +++ b/.sqlx/query-118e50dac9417b77bb821bf64ef38eb89949deb050faf4150d1aa031f109304f.json @@ -0,0 +1,49 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT created_at, id FROM bria_signing_sessions WHERE (COALESCE((created_at, id) < ($3, $2), $2 IS NULL)) ORDER BY created_at DESC, id DESC LIMIT $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $4 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_signing_session_events e ON i.id = e.id ORDER BY i.created_at desc, i.id desc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Int8", + "Uuid", + "Timestamptz", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "118e50dac9417b77bb821bf64ef38eb89949deb050faf4150d1aa031f109304f" +} diff --git a/.sqlx/query-11d100c94adcd4e0dbb1acb827437b22e4e7f5cb1b997e5df1e13995e82b5a0c.json b/.sqlx/query-11d100c94adcd4e0dbb1acb827437b22e4e7f5cb1b997e5df1e13995e82b5a0c.json new file mode 100644 index 00000000..bdabc191 --- /dev/null +++ b/.sqlx/query-11d100c94adcd4e0dbb1acb827437b22e4e7f5cb1b997e5df1e13995e82b5a0c.json @@ -0,0 +1,49 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (\n SELECT *\n FROM bria_payouts\n WHERE account_id = $1 AND wallet_id = $2\n ORDER BY created_at DESC \n OFFSET $3) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $4 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_payout_events e ON i.id = e.id ORDER BY i.created_at desc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Uuid", + "Int8", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "11d100c94adcd4e0dbb1acb827437b22e4e7f5cb1b997e5df1e13995e82b5a0c" +} diff --git a/.sqlx/query-1a3b6d6a21bf98577024822bf6339123935560e676624e6506dcf11ab5932545.json b/.sqlx/query-1a3b6d6a21bf98577024822bf6339123935560e676624e6506dcf11ab5932545.json new file mode 100644 index 00000000..bd80c470 --- /dev/null +++ b/.sqlx/query-1a3b6d6a21bf98577024822bf6339123935560e676624e6506dcf11ab5932545.json @@ -0,0 +1,16 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE bria_payout_queues SET name = $2, account_id = $3 WHERE id = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Varchar", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "1a3b6d6a21bf98577024822bf6339123935560e676624e6506dcf11ab5932545" +} diff --git a/.sqlx/query-1a9d54b35bd2d6cc759478127e25691d40d037f6130a9d54e519c794fd8b048f.json b/.sqlx/query-1a9d54b35bd2d6cc759478127e25691d40d037f6130a9d54e519c794fd8b048f.json new file mode 100644 index 00000000..ed3569b7 --- /dev/null +++ b/.sqlx/query-1a9d54b35bd2d6cc759478127e25691d40d037f6130a9d54e519c794fd8b048f.json @@ -0,0 +1,49 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT created_at, id FROM bria_payouts WHERE (COALESCE((created_at, id) > ($3, $2), $2 IS NULL)) ORDER BY created_at ASC, id ASC LIMIT $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $4 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_payout_events e ON i.id = e.id ORDER BY i.created_at asc, i.id asc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Int8", + "Uuid", + "Timestamptz", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "1a9d54b35bd2d6cc759478127e25691d40d037f6130a9d54e519c794fd8b048f" +} diff --git a/.sqlx/query-1ac621a8ce19e3bd37d80e8c47564893ce2bc37f4be3304bcfe2c461bd807bbc.json b/.sqlx/query-1ac621a8ce19e3bd37d80e8c47564893ce2bc37f4be3304bcfe2c461bd807bbc.json new file mode 100644 index 00000000..7aaeef4c --- /dev/null +++ b/.sqlx/query-1ac621a8ce19e3bd37d80e8c47564893ce2bc37f4be3304bcfe2c461bd807bbc.json @@ -0,0 +1,47 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM bria_addresses WHERE id = ANY($1)) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $2 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_address_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "UuidArray", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "1ac621a8ce19e3bd37d80e8c47564893ce2bc37f4be3304bcfe2c461bd807bbc" +} diff --git a/.sqlx/query-1bd933fc3fa4865e08bc0c3275e82dc927d9bb9266bec606fb3954beedd74842.json b/.sqlx/query-1bd933fc3fa4865e08bc0c3275e82dc927d9bb9266bec606fb3954beedd74842.json new file mode 100644 index 00000000..aac643a7 --- /dev/null +++ b/.sqlx/query-1bd933fc3fa4865e08bc0c3275e82dc927d9bb9266bec606fb3954beedd74842.json @@ -0,0 +1,47 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM bria_profiles WHERE id = ANY($1)) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $2 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_profile_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "UuidArray", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "1bd933fc3fa4865e08bc0c3275e82dc927d9bb9266bec606fb3954beedd74842" +} diff --git a/.sqlx/query-e6b22adbdcceb4afb26aeceb299fbb32d97989aa7d87ab7f529d2393c36e4f74.json b/.sqlx/query-1e4260ff3d905155725d101e4c99f9bd084e7239808f5f5797f9e290e9d604bb.json similarity index 50% rename from .sqlx/query-e6b22adbdcceb4afb26aeceb299fbb32d97989aa7d87ab7f529d2393c36e4f74.json rename to .sqlx/query-1e4260ff3d905155725d101e4c99f9bd084e7239808f5f5797f9e290e9d604bb.json index 48b6103f..f4710182 100644 --- a/.sqlx/query-e6b22adbdcceb4afb26aeceb299fbb32d97989aa7d87ab7f529d2393c36e4f74.json +++ b/.sqlx/query-1e4260ff3d905155725d101e4c99f9bd084e7239808f5f5797f9e290e9d604bb.json @@ -1,53 +1,47 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT b.*, e.sequence, e.event\n FROM bria_payout_queues b\n JOIN bria_payout_queue_events e ON b.id = e.id\n WHERE account_id = $1 AND b.id = $2\n ORDER BY e.sequence", + "query": "WITH entities AS (SELECT id FROM bria_payouts WHERE id = $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $2 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_payout_events e ON i.id = e.id ORDER BY i.id, e.sequence", "describe": { "columns": [ { "ordinal": 0, - "name": "id", + "name": "entity_id: Repo__Id", "type_info": "Uuid" }, { "ordinal": 1, - "name": "account_id", - "type_info": "Uuid" + "name": "sequence", + "type_info": "Int4" }, { "ordinal": 2, - "name": "name", - "type_info": "Varchar" + "name": "event", + "type_info": "Jsonb" }, { "ordinal": 3, - "name": "created_at", - "type_info": "Timestamptz" + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" }, { "ordinal": 4, - "name": "sequence", - "type_info": "Int4" - }, - { - "ordinal": 5, - "name": "event", - "type_info": "Jsonb" + "name": "recorded_at", + "type_info": "Timestamptz" } ], "parameters": { "Left": [ "Uuid", - "Uuid" + "Bool" ] }, "nullable": [ false, false, false, - false, - false, + null, false ] }, - "hash": "e6b22adbdcceb4afb26aeceb299fbb32d97989aa7d87ab7f529d2393c36e4f74" + "hash": "1e4260ff3d905155725d101e4c99f9bd084e7239808f5f5797f9e290e9d604bb" } diff --git a/.sqlx/query-2007c8cee0c1f518fc56c7c465b77b0251220a30d28eff95089f68091cb92326.json b/.sqlx/query-2007c8cee0c1f518fc56c7c465b77b0251220a30d28eff95089f68091cb92326.json deleted file mode 100644 index 00873a87..00000000 --- a/.sqlx/query-2007c8cee0c1f518fc56c7c465b77b0251220a30d28eff95089f68091cb92326.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n SELECT b.*, e.sequence, e.event\n FROM bria_payout_queues b\n JOIN bria_payout_queue_events e ON b.id = e.id\n ORDER BY b.id, e.sequence", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "id", - "type_info": "Uuid" - }, - { - "ordinal": 1, - "name": "account_id", - "type_info": "Uuid" - }, - { - "ordinal": 2, - "name": "name", - "type_info": "Varchar" - }, - { - "ordinal": 3, - "name": "created_at", - "type_info": "Timestamptz" - }, - { - "ordinal": 4, - "name": "sequence", - "type_info": "Int4" - }, - { - "ordinal": 5, - "name": "event", - "type_info": "Jsonb" - } - ], - "parameters": { - "Left": [] - }, - "nullable": [ - false, - false, - false, - false, - false, - false - ] - }, - "hash": "2007c8cee0c1f518fc56c7c465b77b0251220a30d28eff95089f68091cb92326" -} diff --git a/.sqlx/query-21cab8d30e477cd1e67fa8f383fe5dcdbba978e08423a33b075231a8832363a2.json b/.sqlx/query-21cab8d30e477cd1e67fa8f383fe5dcdbba978e08423a33b075231a8832363a2.json new file mode 100644 index 00000000..6859dde3 --- /dev/null +++ b/.sqlx/query-21cab8d30e477cd1e67fa8f383fe5dcdbba978e08423a33b075231a8832363a2.json @@ -0,0 +1,47 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM bria_wallets WHERE account_id = $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $2 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_wallet_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "21cab8d30e477cd1e67fa8f383fe5dcdbba978e08423a33b075231a8832363a2" +} diff --git a/.sqlx/query-21ea4761928aec144a72c1ced9baadc31fa57b51b94766af188b7ae448eb994f.json b/.sqlx/query-21ea4761928aec144a72c1ced9baadc31fa57b51b94766af188b7ae448eb994f.json deleted file mode 100644 index e222d274..00000000 --- a/.sqlx/query-21ea4761928aec144a72c1ced9baadc31fa57b51b94766af188b7ae448eb994f.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "SELECT sequence, event_type, event FROM bria_xpub_events\n WHERE id = $1\n ORDER BY sequence", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "sequence", - "type_info": "Int4" - }, - { - "ordinal": 1, - "name": "event_type", - "type_info": "Varchar" - }, - { - "ordinal": 2, - "name": "event", - "type_info": "Jsonb" - } - ], - "parameters": { - "Left": [ - "Uuid" - ] - }, - "nullable": [ - false, - false, - false - ] - }, - "hash": "21ea4761928aec144a72c1ced9baadc31fa57b51b94766af188b7ae448eb994f" -} diff --git a/.sqlx/query-2249f68f6b116c763f2805afe476b97a27333e204f10b9e68cf825719c5c2498.json b/.sqlx/query-2249f68f6b116c763f2805afe476b97a27333e204f10b9e68cf825719c5c2498.json new file mode 100644 index 00000000..1bffefaf --- /dev/null +++ b/.sqlx/query-2249f68f6b116c763f2805afe476b97a27333e204f10b9e68cf825719c5c2498.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE bria_wallets SET name = $2 WHERE id = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Varchar" + ] + }, + "nullable": [] + }, + "hash": "2249f68f6b116c763f2805afe476b97a27333e204f10b9e68cf825719c5c2498" +} diff --git a/.sqlx/query-24126c8a99b07e414f6a01bd5134c01074f983bb9eb93018e618dea27e943334.json b/.sqlx/query-24126c8a99b07e414f6a01bd5134c01074f983bb9eb93018e618dea27e943334.json new file mode 100644 index 00000000..6621c96a --- /dev/null +++ b/.sqlx/query-24126c8a99b07e414f6a01bd5134c01074f983bb9eb93018e618dea27e943334.json @@ -0,0 +1,49 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT created_at, id FROM bria_xpubs WHERE (COALESCE((created_at, id) < ($3, $2), $2 IS NULL)) ORDER BY created_at DESC, id DESC LIMIT $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $4 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_xpub_events e ON i.id = e.id ORDER BY i.created_at desc, i.id desc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Int8", + "Uuid", + "Timestamptz", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "24126c8a99b07e414f6a01bd5134c01074f983bb9eb93018e618dea27e943334" +} diff --git a/.sqlx/query-24335a859b72745eb385891c6d5d8ec5221d958eacb931c0054d70fbec66c7c3.json b/.sqlx/query-24335a859b72745eb385891c6d5d8ec5221d958eacb931c0054d70fbec66c7c3.json new file mode 100644 index 00000000..5f1159b7 --- /dev/null +++ b/.sqlx/query-24335a859b72745eb385891c6d5d8ec5221d958eacb931c0054d70fbec66c7c3.json @@ -0,0 +1,48 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM bria_payouts WHERE (COALESCE(id > $2, true)) ORDER BY id ASC LIMIT $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $3 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_payout_events e ON i.id = e.id ORDER BY i.id asc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Int8", + "Uuid", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "24335a859b72745eb385891c6d5d8ec5221d958eacb931c0054d70fbec66c7c3" +} diff --git a/.sqlx/query-24db1c5fa667f489cfbcda3ab832698186ec14fd4e857e3d32317967ac69ad2a.json b/.sqlx/query-24db1c5fa667f489cfbcda3ab832698186ec14fd4e857e3d32317967ac69ad2a.json new file mode 100644 index 00000000..d68b3419 --- /dev/null +++ b/.sqlx/query-24db1c5fa667f489cfbcda3ab832698186ec14fd4e857e3d32317967ac69ad2a.json @@ -0,0 +1,49 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT created_at, id FROM bria_wallets WHERE (COALESCE((created_at, id) > ($3, $2), $2 IS NULL)) ORDER BY created_at ASC, id ASC LIMIT $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $4 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_wallet_events e ON i.id = e.id ORDER BY i.created_at asc, i.id asc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Int8", + "Uuid", + "Timestamptz", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "24db1c5fa667f489cfbcda3ab832698186ec14fd4e857e3d32317967ac69ad2a" +} diff --git a/.sqlx/query-259c8d203542581ea7f2dced50c10abc54fa407a5a5665e44639f99f8ab61455.json b/.sqlx/query-259c8d203542581ea7f2dced50c10abc54fa407a5a5665e44639f99f8ab61455.json new file mode 100644 index 00000000..9777732c --- /dev/null +++ b/.sqlx/query-259c8d203542581ea7f2dced50c10abc54fa407a5a5665e44639f99f8ab61455.json @@ -0,0 +1,49 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT created_at, id FROM bria_signing_sessions WHERE (COALESCE((created_at, id) > ($3, $2), $2 IS NULL)) ORDER BY created_at ASC, id ASC LIMIT $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $4 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_signing_session_events e ON i.id = e.id ORDER BY i.created_at asc, i.id asc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Int8", + "Uuid", + "Timestamptz", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "259c8d203542581ea7f2dced50c10abc54fa407a5a5665e44639f99f8ab61455" +} diff --git a/.sqlx/query-279d5f7d7d21b641b5c6352f62d37417409ba0aaedb5ebe5213decee968e79fe.json b/.sqlx/query-279d5f7d7d21b641b5c6352f62d37417409ba0aaedb5ebe5213decee968e79fe.json new file mode 100644 index 00000000..13a72fad --- /dev/null +++ b/.sqlx/query-279d5f7d7d21b641b5c6352f62d37417409ba0aaedb5ebe5213decee968e79fe.json @@ -0,0 +1,50 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (\n SELECT *\n FROM bria_payouts\n WHERE batch_id is NULL AND account_id = $1 AND payout_queue_id = $2\n AND (COALESCE((created_at, id) > ($4, $3), $3 IS NULL))\n ORDER BY created_at, id\n FOR UPDATE) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $5 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_payout_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Uuid", + "Uuid", + "Timestamptz", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "279d5f7d7d21b641b5c6352f62d37417409ba0aaedb5ebe5213decee968e79fe" +} diff --git a/.sqlx/query-290697d21826c0cf91ed115e04aa98f6c850d40d8ce3ad64e7d7bbe53334e338.json b/.sqlx/query-290697d21826c0cf91ed115e04aa98f6c850d40d8ce3ad64e7d7bbe53334e338.json new file mode 100644 index 00000000..7a625583 --- /dev/null +++ b/.sqlx/query-290697d21826c0cf91ed115e04aa98f6c850d40d8ce3ad64e7d7bbe53334e338.json @@ -0,0 +1,17 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO bria_profiles (id, name, account_id, created_at) VALUES ($1, $2, $3, COALESCE($4, NOW()))", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Varchar", + "Uuid", + "Timestamptz" + ] + }, + "nullable": [] + }, + "hash": "290697d21826c0cf91ed115e04aa98f6c850d40d8ce3ad64e7d7bbe53334e338" +} diff --git a/.sqlx/query-2a3a40f8b01cb161ca8ad94b3441ce62142370967be1d42aeee59fd2952106fb.json b/.sqlx/query-2a3a40f8b01cb161ca8ad94b3441ce62142370967be1d42aeee59fd2952106fb.json new file mode 100644 index 00000000..9737afaf --- /dev/null +++ b/.sqlx/query-2a3a40f8b01cb161ca8ad94b3441ce62142370967be1d42aeee59fd2952106fb.json @@ -0,0 +1,49 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT created_at, id FROM bria_addresses WHERE (COALESCE((created_at, id) > ($3, $2), $2 IS NULL)) ORDER BY created_at ASC, id ASC LIMIT $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $4 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_address_events e ON i.id = e.id ORDER BY i.created_at asc, i.id asc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Int8", + "Uuid", + "Timestamptz", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "2a3a40f8b01cb161ca8ad94b3441ce62142370967be1d42aeee59fd2952106fb" +} diff --git a/.sqlx/query-2c9a8151247c14fd011897d7f753c5996b6bd136149b13e5df4babdd6c5be8a4.json b/.sqlx/query-2c9a8151247c14fd011897d7f753c5996b6bd136149b13e5df4babdd6c5be8a4.json new file mode 100644 index 00000000..433f013e --- /dev/null +++ b/.sqlx/query-2c9a8151247c14fd011897d7f753c5996b6bd136149b13e5df4babdd6c5be8a4.json @@ -0,0 +1,50 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT account_id, created_at, id FROM bria_xpubs WHERE ((account_id = $1) AND (COALESCE((created_at, id) > ($4, $3), $3 IS NULL))) ORDER BY created_at ASC, id ASC LIMIT $2) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $5 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_xpub_events e ON i.id = e.id ORDER BY i.created_at asc, i.id asc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Int8", + "Uuid", + "Timestamptz", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "2c9a8151247c14fd011897d7f753c5996b6bd136149b13e5df4babdd6c5be8a4" +} diff --git a/.sqlx/query-2ef3dc26b44ca0f6fb5bd698f7eb963ca41a1c7fb9ca50bef007492dc62d6891.json b/.sqlx/query-2ef3dc26b44ca0f6fb5bd698f7eb963ca41a1c7fb9ca50bef007492dc62d6891.json deleted file mode 100644 index f745f675..00000000 --- a/.sqlx/query-2ef3dc26b44ca0f6fb5bd698f7eb963ca41a1c7fb9ca50bef007492dc62d6891.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "SELECT id FROM bria_xpubs WHERE account_id = $1 AND name = $2", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "id", - "type_info": "Uuid" - } - ], - "parameters": { - "Left": [ - "Uuid", - "Text" - ] - }, - "nullable": [ - false - ] - }, - "hash": "2ef3dc26b44ca0f6fb5bd698f7eb963ca41a1c7fb9ca50bef007492dc62d6891" -} diff --git a/.sqlx/query-32472ea9a6598dbd856420172ddbcf633b0e7ffed5fcb0eb5b28dc5eb0a65b16.json b/.sqlx/query-32472ea9a6598dbd856420172ddbcf633b0e7ffed5fcb0eb5b28dc5eb0a65b16.json new file mode 100644 index 00000000..89d81b2e --- /dev/null +++ b/.sqlx/query-32472ea9a6598dbd856420172ddbcf633b0e7ffed5fcb0eb5b28dc5eb0a65b16.json @@ -0,0 +1,49 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT account_id, id FROM bria_profiles WHERE ((account_id = $1) AND (COALESCE(id < $3, true))) ORDER BY id DESC LIMIT $2) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $4 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_profile_events e ON i.id = e.id ORDER BY i.id desc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Int8", + "Uuid", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "32472ea9a6598dbd856420172ddbcf633b0e7ffed5fcb0eb5b28dc5eb0a65b16" +} diff --git a/.sqlx/query-32ff4078f342d5337ba35916aedda40d51cd9a60fd7a255fd7ea209ed5a89357.json b/.sqlx/query-32ff4078f342d5337ba35916aedda40d51cd9a60fd7a255fd7ea209ed5a89357.json new file mode 100644 index 00000000..10c3950e --- /dev/null +++ b/.sqlx/query-32ff4078f342d5337ba35916aedda40d51cd9a60fd7a255fd7ea209ed5a89357.json @@ -0,0 +1,26 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO bria_payout_queue_events (id, recorded_at, sequence, event_type, event) SELECT $1, COALESCE($2, NOW()), ROW_NUMBER() OVER () + $3, unnested.event_type, unnested.event FROM UNNEST($4::TEXT[], $5::JSONB[]) AS unnested(event_type, event) RETURNING recorded_at", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Timestamptz", + "Int8", + "TextArray", + "JsonbArray" + ] + }, + "nullable": [ + false + ] + }, + "hash": "32ff4078f342d5337ba35916aedda40d51cd9a60fd7a255fd7ea209ed5a89357" +} diff --git a/.sqlx/query-3380cc0e4ce5ce20579249dc342cf3e4456b4c9bda04f8c7b542d4e782054a51.json b/.sqlx/query-3380cc0e4ce5ce20579249dc342cf3e4456b4c9bda04f8c7b542d4e782054a51.json new file mode 100644 index 00000000..417bf779 --- /dev/null +++ b/.sqlx/query-3380cc0e4ce5ce20579249dc342cf3e4456b4c9bda04f8c7b542d4e782054a51.json @@ -0,0 +1,48 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM bria_payout_queues WHERE (COALESCE(id < $2, true)) ORDER BY id DESC LIMIT $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $3 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_payout_queue_events e ON i.id = e.id ORDER BY i.id desc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Int8", + "Uuid", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "3380cc0e4ce5ce20579249dc342cf3e4456b4c9bda04f8c7b542d4e782054a51" +} diff --git a/.sqlx/query-3620bdf48b7cbbc099eadf41b701a5739c538023fac61baa64bf9da1b0d69a46.json b/.sqlx/query-3620bdf48b7cbbc099eadf41b701a5739c538023fac61baa64bf9da1b0d69a46.json new file mode 100644 index 00000000..ff0d65a3 --- /dev/null +++ b/.sqlx/query-3620bdf48b7cbbc099eadf41b701a5739c538023fac61baa64bf9da1b0d69a46.json @@ -0,0 +1,48 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM bria_addresses WHERE (COALESCE(id < $2, true)) ORDER BY id DESC LIMIT $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $3 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_address_events e ON i.id = e.id ORDER BY i.id desc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Int8", + "Uuid", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "3620bdf48b7cbbc099eadf41b701a5739c538023fac61baa64bf9da1b0d69a46" +} diff --git a/.sqlx/query-38ee995cafdc4c4cd1319682e059e9b3b96a10251e0c78656353757f6b965a8c.json b/.sqlx/query-390469b173205a768d2a955590f645df9df3b86b6790e788f880ac375540df58.json similarity index 68% rename from .sqlx/query-38ee995cafdc4c4cd1319682e059e9b3b96a10251e0c78656353757f6b965a8c.json rename to .sqlx/query-390469b173205a768d2a955590f645df9df3b86b6790e788f880ac375540df58.json index 0467c85a..06a3ffec 100644 --- a/.sqlx/query-38ee995cafdc4c4cd1319682e059e9b3b96a10251e0c78656353757f6b965a8c.json +++ b/.sqlx/query-390469b173205a768d2a955590f645df9df3b86b6790e788f880ac375540df58.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n INSERT INTO bria_xpub_signer_configs (id, cypher, nonce, created_at, modified_at)\n VALUES ($1, $2, $3, NOW(), NOW())\n ON CONFLICT (id) DO UPDATE \n SET cypher = $2, nonce = $3, modified_at = NOW()\n ", + "query": "\n INSERT INTO bria_xpub_signer_configs (id, cypher, nonce, created_at, modified_at)\n VALUES ($1, $2, $3, NOW(), NOW())\n ON CONFLICT (id) DO UPDATE\n SET cypher = $2, nonce = $3, modified_at = NOW()\n ", "describe": { "columns": [], "parameters": { @@ -12,5 +12,5 @@ }, "nullable": [] }, - "hash": "38ee995cafdc4c4cd1319682e059e9b3b96a10251e0c78656353757f6b965a8c" + "hash": "390469b173205a768d2a955590f645df9df3b86b6790e788f880ac375540df58" } diff --git a/.sqlx/query-f7df099ce3c2628910cef4b4d5445610313be8ece43f5f530d8e0e2322a62cf4.json b/.sqlx/query-3f32b12dd86d1cfb133e7e2434b79063f762d4efb4174d3eaf3795da7785f9c5.json similarity index 55% rename from .sqlx/query-f7df099ce3c2628910cef4b4d5445610313be8ece43f5f530d8e0e2322a62cf4.json rename to .sqlx/query-3f32b12dd86d1cfb133e7e2434b79063f762d4efb4174d3eaf3795da7785f9c5.json index b1acca9e..7c6a1883 100644 --- a/.sqlx/query-f7df099ce3c2628910cef4b4d5445610313be8ece43f5f530d8e0e2322a62cf4.json +++ b/.sqlx/query-3f32b12dd86d1cfb133e7e2434b79063f762d4efb4174d3eaf3795da7785f9c5.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "INSERT INTO bria_payouts (id, account_id, wallet_id, payout_queue_id, profile_id, external_id)\n VALUES ($1, $2, $3, $4, $5, $6)", + "query": "INSERT INTO bria_payouts (id, account_id, wallet_id, payout_queue_id, profile_id, external_id, created_at) VALUES ($1, $2, $3, $4, $5, $6, COALESCE($7, NOW()))", "describe": { "columns": [], "parameters": { @@ -10,10 +10,11 @@ "Uuid", "Uuid", "Uuid", - "Varchar" + "Varchar", + "Timestamptz" ] }, "nullable": [] }, - "hash": "f7df099ce3c2628910cef4b4d5445610313be8ece43f5f530d8e0e2322a62cf4" + "hash": "3f32b12dd86d1cfb133e7e2434b79063f762d4efb4174d3eaf3795da7785f9c5" } diff --git a/.sqlx/query-3f76551e5ac8d57c43c39b276f9c923a8619eb450a7c8e121324952d1c32950b.json b/.sqlx/query-3f76551e5ac8d57c43c39b276f9c923a8619eb450a7c8e121324952d1c32950b.json new file mode 100644 index 00000000..94ebaa37 --- /dev/null +++ b/.sqlx/query-3f76551e5ac8d57c43c39b276f9c923a8619eb450a7c8e121324952d1c32950b.json @@ -0,0 +1,48 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM bria_signing_sessions WHERE (COALESCE(id < $2, true)) ORDER BY id DESC LIMIT $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $3 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_signing_session_events e ON i.id = e.id ORDER BY i.id desc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Int8", + "Uuid", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "3f76551e5ac8d57c43c39b276f9c923a8619eb450a7c8e121324952d1c32950b" +} diff --git a/.sqlx/query-3f96b570e8ced8061e9340b74fecbe5d117b54b754c0cc888edf82ed2972f5c1.json b/.sqlx/query-3f96b570e8ced8061e9340b74fecbe5d117b54b754c0cc888edf82ed2972f5c1.json deleted file mode 100644 index 871beef8..00000000 --- a/.sqlx/query-3f96b570e8ced8061e9340b74fecbe5d117b54b754c0cc888edf82ed2972f5c1.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "SELECT sequence, event_type, event FROM bria_profile_events\n WHERE id = $1\n ORDER BY sequence", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "sequence", - "type_info": "Int4" - }, - { - "ordinal": 1, - "name": "event_type", - "type_info": "Varchar" - }, - { - "ordinal": 2, - "name": "event", - "type_info": "Jsonb" - } - ], - "parameters": { - "Left": [ - "Uuid" - ] - }, - "nullable": [ - false, - false, - false - ] - }, - "hash": "3f96b570e8ced8061e9340b74fecbe5d117b54b754c0cc888edf82ed2972f5c1" -} diff --git a/.sqlx/query-3ffc7db9c71b9933f13aebc6a4a7b3d3c9586e78ae50a78322a79124516af1cd.json b/.sqlx/query-3ffc7db9c71b9933f13aebc6a4a7b3d3c9586e78ae50a78322a79124516af1cd.json new file mode 100644 index 00000000..5042b83b --- /dev/null +++ b/.sqlx/query-3ffc7db9c71b9933f13aebc6a4a7b3d3c9586e78ae50a78322a79124516af1cd.json @@ -0,0 +1,47 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM bria_signing_sessions WHERE batch_id = $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $2 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_signing_session_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "3ffc7db9c71b9933f13aebc6a4a7b3d3c9586e78ae50a78322a79124516af1cd" +} diff --git a/.sqlx/query-42f8b84317c23636033b640c676acc8e4c07dcafee002b768a02e2a82b414507.json b/.sqlx/query-42f8b84317c23636033b640c676acc8e4c07dcafee002b768a02e2a82b414507.json new file mode 100644 index 00000000..177791ed --- /dev/null +++ b/.sqlx/query-42f8b84317c23636033b640c676acc8e4c07dcafee002b768a02e2a82b414507.json @@ -0,0 +1,49 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT account_id, id FROM bria_xpubs WHERE ((account_id = $1) AND (COALESCE(id < $3, true))) ORDER BY id DESC LIMIT $2) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $4 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_xpub_events e ON i.id = e.id ORDER BY i.id desc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Int8", + "Uuid", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "42f8b84317c23636033b640c676acc8e4c07dcafee002b768a02e2a82b414507" +} diff --git a/.sqlx/query-459e6f5ecb870b4762324c2d19173f239f1b4c71b58b475e5c6bc1b66783d877.json b/.sqlx/query-459e6f5ecb870b4762324c2d19173f239f1b4c71b58b475e5c6bc1b66783d877.json new file mode 100644 index 00000000..64b28631 --- /dev/null +++ b/.sqlx/query-459e6f5ecb870b4762324c2d19173f239f1b4c71b58b475e5c6bc1b66783d877.json @@ -0,0 +1,47 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM bria_payouts WHERE payout_queue_id = $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $2 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_payout_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "459e6f5ecb870b4762324c2d19173f239f1b4c71b58b475e5c6bc1b66783d877" +} diff --git a/.sqlx/query-4bd1b6db31988bbc58bc01e75ba3979ca28a59910bd5c8b7f09106a0f55247d9.json b/.sqlx/query-4bd1b6db31988bbc58bc01e75ba3979ca28a59910bd5c8b7f09106a0f55247d9.json new file mode 100644 index 00000000..8e99d7ef --- /dev/null +++ b/.sqlx/query-4bd1b6db31988bbc58bc01e75ba3979ca28a59910bd5c8b7f09106a0f55247d9.json @@ -0,0 +1,50 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT account_id, created_at, id FROM bria_xpubs WHERE ((account_id = $1) AND (COALESCE((created_at, id) < ($4, $3), $3 IS NULL))) ORDER BY created_at DESC, id DESC LIMIT $2) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $5 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_xpub_events e ON i.id = e.id ORDER BY i.created_at desc, i.id desc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Int8", + "Uuid", + "Timestamptz", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "4bd1b6db31988bbc58bc01e75ba3979ca28a59910bd5c8b7f09106a0f55247d9" +} diff --git a/.sqlx/query-4d18acca29015f43bba9b8432af0f20dfef2d1cc2d2b680a173255dd17b36290.json b/.sqlx/query-4d18acca29015f43bba9b8432af0f20dfef2d1cc2d2b680a173255dd17b36290.json new file mode 100644 index 00000000..387a4a11 --- /dev/null +++ b/.sqlx/query-4d18acca29015f43bba9b8432af0f20dfef2d1cc2d2b680a173255dd17b36290.json @@ -0,0 +1,48 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM bria_addresses WHERE (COALESCE(id > $2, true)) ORDER BY id ASC LIMIT $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $3 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_address_events e ON i.id = e.id ORDER BY i.id asc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Int8", + "Uuid", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "4d18acca29015f43bba9b8432af0f20dfef2d1cc2d2b680a173255dd17b36290" +} diff --git a/.sqlx/query-4e20d7faf0a2ba905ad5bbc8c8f23373bdc25ad32843725868a5218678cdfff0.json b/.sqlx/query-4e20d7faf0a2ba905ad5bbc8c8f23373bdc25ad32843725868a5218678cdfff0.json new file mode 100644 index 00000000..767e5405 --- /dev/null +++ b/.sqlx/query-4e20d7faf0a2ba905ad5bbc8c8f23373bdc25ad32843725868a5218678cdfff0.json @@ -0,0 +1,48 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM bria_profiles WHERE (COALESCE(id > $2, true)) ORDER BY id ASC LIMIT $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $3 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_profile_events e ON i.id = e.id ORDER BY i.id asc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Int8", + "Uuid", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "4e20d7faf0a2ba905ad5bbc8c8f23373bdc25ad32843725868a5218678cdfff0" +} diff --git a/.sqlx/query-4e35dd7dff49406af0e56f17e8b9948483fbf370cf28fc0d5736fc15da01acc3.json b/.sqlx/query-4e35dd7dff49406af0e56f17e8b9948483fbf370cf28fc0d5736fc15da01acc3.json new file mode 100644 index 00000000..4af9551f --- /dev/null +++ b/.sqlx/query-4e35dd7dff49406af0e56f17e8b9948483fbf370cf28fc0d5736fc15da01acc3.json @@ -0,0 +1,26 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO bria_profile_events (id, recorded_at, sequence, event_type, event) SELECT $1, COALESCE($2, NOW()), ROW_NUMBER() OVER () + $3, unnested.event_type, unnested.event FROM UNNEST($4::TEXT[], $5::JSONB[]) AS unnested(event_type, event) RETURNING recorded_at", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Timestamptz", + "Int8", + "TextArray", + "JsonbArray" + ] + }, + "nullable": [ + false + ] + }, + "hash": "4e35dd7dff49406af0e56f17e8b9948483fbf370cf28fc0d5736fc15da01acc3" +} diff --git a/.sqlx/query-51ff446a8164f54bc059968fa858b1940a601adcf8bcab6dbacd0d2befa1fc4c.json b/.sqlx/query-51ff446a8164f54bc059968fa858b1940a601adcf8bcab6dbacd0d2befa1fc4c.json new file mode 100644 index 00000000..98bd766e --- /dev/null +++ b/.sqlx/query-51ff446a8164f54bc059968fa858b1940a601adcf8bcab6dbacd0d2befa1fc4c.json @@ -0,0 +1,48 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM bria_wallets WHERE (COALESCE(id < $2, true)) ORDER BY id DESC LIMIT $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $3 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_wallet_events e ON i.id = e.id ORDER BY i.id desc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Int8", + "Uuid", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "51ff446a8164f54bc059968fa858b1940a601adcf8bcab6dbacd0d2befa1fc4c" +} diff --git a/.sqlx/query-2c5e7765d15a8b3893f40a98898cca618f69ae9b16abeeb1dfe37fd8e3408f13.json b/.sqlx/query-54e30a8dd82a2bc27930bcea9795aae5f9df159a10a96ea039ce50e7d0574bcc.json similarity index 50% rename from .sqlx/query-2c5e7765d15a8b3893f40a98898cca618f69ae9b16abeeb1dfe37fd8e3408f13.json rename to .sqlx/query-54e30a8dd82a2bc27930bcea9795aae5f9df159a10a96ea039ce50e7d0574bcc.json index eaf19c65..d3800284 100644 --- a/.sqlx/query-2c5e7765d15a8b3893f40a98898cca618f69ae9b16abeeb1dfe37fd8e3408f13.json +++ b/.sqlx/query-54e30a8dd82a2bc27930bcea9795aae5f9df159a10a96ea039ce50e7d0574bcc.json @@ -1,53 +1,47 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT b.*, e.sequence, e.event\n FROM bria_wallets b\n JOIN bria_wallet_events e ON b.id = e.id\n WHERE account_id = $1 AND name = $2\n ORDER BY e.sequence", + "query": "WITH entities AS (SELECT id FROM bria_xpubs WHERE id = $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $2 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_xpub_events e ON i.id = e.id ORDER BY i.id, e.sequence", "describe": { "columns": [ { "ordinal": 0, - "name": "id", + "name": "entity_id: Repo__Id", "type_info": "Uuid" }, { "ordinal": 1, - "name": "account_id", - "type_info": "Uuid" + "name": "sequence", + "type_info": "Int4" }, { "ordinal": 2, - "name": "name", - "type_info": "Varchar" + "name": "event", + "type_info": "Jsonb" }, { "ordinal": 3, - "name": "created_at", - "type_info": "Timestamptz" + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" }, { "ordinal": 4, - "name": "sequence", - "type_info": "Int4" - }, - { - "ordinal": 5, - "name": "event", - "type_info": "Jsonb" + "name": "recorded_at", + "type_info": "Timestamptz" } ], "parameters": { "Left": [ "Uuid", - "Text" + "Bool" ] }, "nullable": [ false, false, false, - false, - false, + null, false ] }, - "hash": "2c5e7765d15a8b3893f40a98898cca618f69ae9b16abeeb1dfe37fd8e3408f13" + "hash": "54e30a8dd82a2bc27930bcea9795aae5f9df159a10a96ea039ce50e7d0574bcc" } diff --git a/.sqlx/query-55ca43169585550b32c40d2136f479bc62922fc3d77e2473ba7232fad46f491a.json b/.sqlx/query-55ca43169585550b32c40d2136f479bc62922fc3d77e2473ba7232fad46f491a.json deleted file mode 100644 index 93a65b44..00000000 --- a/.sqlx/query-55ca43169585550b32c40d2136f479bc62922fc3d77e2473ba7232fad46f491a.json +++ /dev/null @@ -1,77 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n SELECT b.*, e.sequence, e.event\n FROM bria_payouts b\n JOIN bria_payout_events e ON b.id = e.id\n WHERE b.batch_id IS NULL AND b.account_id = $1 AND b.payout_queue_id = $2\n ORDER BY b.created_at, b.id, e.sequence FOR UPDATE", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "id", - "type_info": "Uuid" - }, - { - "ordinal": 1, - "name": "account_id", - "type_info": "Uuid" - }, - { - "ordinal": 2, - "name": "wallet_id", - "type_info": "Uuid" - }, - { - "ordinal": 3, - "name": "payout_queue_id", - "type_info": "Uuid" - }, - { - "ordinal": 4, - "name": "batch_id", - "type_info": "Uuid" - }, - { - "ordinal": 5, - "name": "profile_id", - "type_info": "Uuid" - }, - { - "ordinal": 6, - "name": "external_id", - "type_info": "Varchar" - }, - { - "ordinal": 7, - "name": "created_at", - "type_info": "Timestamptz" - }, - { - "ordinal": 8, - "name": "sequence", - "type_info": "Int4" - }, - { - "ordinal": 9, - "name": "event", - "type_info": "Jsonb" - } - ], - "parameters": { - "Left": [ - "Uuid", - "Uuid" - ] - }, - "nullable": [ - false, - false, - false, - false, - true, - false, - false, - false, - false, - false - ] - }, - "hash": "55ca43169585550b32c40d2136f479bc62922fc3d77e2473ba7232fad46f491a" -} diff --git a/.sqlx/query-56245d97b2e9a48700f079f567191a943aacf384d483a205195fd54362179348.json b/.sqlx/query-56245d97b2e9a48700f079f567191a943aacf384d483a205195fd54362179348.json new file mode 100644 index 00000000..6d7e117c --- /dev/null +++ b/.sqlx/query-56245d97b2e9a48700f079f567191a943aacf384d483a205195fd54362179348.json @@ -0,0 +1,57 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM bria_addresses WHERE kind = $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $2 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_address_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + { + "Custom": { + "name": "keychainkind", + "kind": { + "Enum": [ + "external", + "internal" + ] + } + } + }, + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "56245d97b2e9a48700f079f567191a943aacf384d483a205195fd54362179348" +} diff --git a/.sqlx/query-56d5a9bb547f49305d360044132faf625c162539dc7460bb9a99202e245192cb.json b/.sqlx/query-56d5a9bb547f49305d360044132faf625c162539dc7460bb9a99202e245192cb.json new file mode 100644 index 00000000..82f9db44 --- /dev/null +++ b/.sqlx/query-56d5a9bb547f49305d360044132faf625c162539dc7460bb9a99202e245192cb.json @@ -0,0 +1,50 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (\n SELECT *\n FROM bria_addresses\n WHERE account_id = $1 AND wallet_id = $2 AND kind = 'external'\n AND (COALESCE((created_at, id) > ($4, $3), $3 IS NULL))\n ORDER BY created_at, id) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $5 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_address_events e ON i.id = e.id ORDER BY i.created_at, i.id, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Uuid", + "Uuid", + "Timestamptz", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "56d5a9bb547f49305d360044132faf625c162539dc7460bb9a99202e245192cb" +} diff --git a/.sqlx/query-593323e63055f2d9bd582985fd48f145d4005a8b1de856a8664f00bab143e8ae.json b/.sqlx/query-593323e63055f2d9bd582985fd48f145d4005a8b1de856a8664f00bab143e8ae.json new file mode 100644 index 00000000..7d28b1ff --- /dev/null +++ b/.sqlx/query-593323e63055f2d9bd582985fd48f145d4005a8b1de856a8664f00bab143e8ae.json @@ -0,0 +1,47 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM bria_addresses WHERE wallet_id = $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $2 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_address_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "593323e63055f2d9bd582985fd48f145d4005a8b1de856a8664f00bab143e8ae" +} diff --git a/.sqlx/query-5a520520a9bd611ae87e57bdb5b6e8a14f63396dbce8ad30e9fe53211f08037b.json b/.sqlx/query-5a520520a9bd611ae87e57bdb5b6e8a14f63396dbce8ad30e9fe53211f08037b.json new file mode 100644 index 00000000..83aca234 --- /dev/null +++ b/.sqlx/query-5a520520a9bd611ae87e57bdb5b6e8a14f63396dbce8ad30e9fe53211f08037b.json @@ -0,0 +1,18 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO bria_xpubs (id, account_id, name, fingerprint, created_at) VALUES ($1, $2, $3, $4, COALESCE($5, NOW()))", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Uuid", + "Varchar", + "Bytea", + "Timestamptz" + ] + }, + "nullable": [] + }, + "hash": "5a520520a9bd611ae87e57bdb5b6e8a14f63396dbce8ad30e9fe53211f08037b" +} diff --git a/.sqlx/query-5df3e700d6abe2e53d1f282e4e29b808c5810b493044a8097e20fcd9de0f17d1.json b/.sqlx/query-5df3e700d6abe2e53d1f282e4e29b808c5810b493044a8097e20fcd9de0f17d1.json deleted file mode 100644 index e11f8d6d..00000000 --- a/.sqlx/query-5df3e700d6abe2e53d1f282e4e29b808c5810b493044a8097e20fcd9de0f17d1.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n SELECT b.*, e.sequence, e.event_type, e.event\n FROM bria_signing_sessions b\n JOIN bria_signing_session_events e ON b.id = e.id\n WHERE account_id = $1 AND batch_id = $2\n ORDER BY b.id, sequence", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "id", - "type_info": "Uuid" - }, - { - "ordinal": 1, - "name": "account_id", - "type_info": "Uuid" - }, - { - "ordinal": 2, - "name": "batch_id", - "type_info": "Uuid" - }, - { - "ordinal": 3, - "name": "xpub_fingerprint", - "type_info": "Bytea" - }, - { - "ordinal": 4, - "name": "sequence", - "type_info": "Int4" - }, - { - "ordinal": 5, - "name": "event_type", - "type_info": "Varchar" - }, - { - "ordinal": 6, - "name": "event", - "type_info": "Jsonb" - } - ], - "parameters": { - "Left": [ - "Uuid", - "Uuid" - ] - }, - "nullable": [ - false, - false, - false, - false, - false, - false, - false - ] - }, - "hash": "5df3e700d6abe2e53d1f282e4e29b808c5810b493044a8097e20fcd9de0f17d1" -} diff --git a/.sqlx/query-619d3dbbf8890d02af8ec73faf9c846b671d492594c4648a744923a9c698285d.json b/.sqlx/query-619d3dbbf8890d02af8ec73faf9c846b671d492594c4648a744923a9c698285d.json new file mode 100644 index 00000000..025bbe46 --- /dev/null +++ b/.sqlx/query-619d3dbbf8890d02af8ec73faf9c846b671d492594c4648a744923a9c698285d.json @@ -0,0 +1,47 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM bria_addresses WHERE account_id = $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $2 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_address_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "619d3dbbf8890d02af8ec73faf9c846b671d492594c4648a744923a9c698285d" +} diff --git a/.sqlx/query-6342025cec28f3494d84abd198aee2ba0be98637ff24d795ecda1a2986dde453.json b/.sqlx/query-6342025cec28f3494d84abd198aee2ba0be98637ff24d795ecda1a2986dde453.json new file mode 100644 index 00000000..5ee10968 --- /dev/null +++ b/.sqlx/query-6342025cec28f3494d84abd198aee2ba0be98637ff24d795ecda1a2986dde453.json @@ -0,0 +1,47 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM bria_addresses WHERE address = $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $2 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_address_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Text", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "6342025cec28f3494d84abd198aee2ba0be98637ff24d795ecda1a2986dde453" +} diff --git a/.sqlx/query-640cb941e8bc937e7c03ade967c55fb36c6e4a98a93b2b6d493b1ba70aa09ad2.json b/.sqlx/query-640cb941e8bc937e7c03ade967c55fb36c6e4a98a93b2b6d493b1ba70aa09ad2.json new file mode 100644 index 00000000..f0b2f650 --- /dev/null +++ b/.sqlx/query-640cb941e8bc937e7c03ade967c55fb36c6e4a98a93b2b6d493b1ba70aa09ad2.json @@ -0,0 +1,48 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (\n SELECT *\n FROM bria_addresses\n WHERE account_id = $1 AND address = $2) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $3 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_address_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "640cb941e8bc937e7c03ade967c55fb36c6e4a98a93b2b6d493b1ba70aa09ad2" +} diff --git a/.sqlx/query-6410d6d28f9f27588505ca95ac67fdec18f377bd0fc9d1d33c31f3f0b79d459d.json b/.sqlx/query-6410d6d28f9f27588505ca95ac67fdec18f377bd0fc9d1d33c31f3f0b79d459d.json new file mode 100644 index 00000000..7f768a4d --- /dev/null +++ b/.sqlx/query-6410d6d28f9f27588505ca95ac67fdec18f377bd0fc9d1d33c31f3f0b79d459d.json @@ -0,0 +1,49 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT created_at, id FROM bria_payout_queues WHERE (COALESCE((created_at, id) > ($3, $2), $2 IS NULL)) ORDER BY created_at ASC, id ASC LIMIT $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $4 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_payout_queue_events e ON i.id = e.id ORDER BY i.created_at asc, i.id asc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Int8", + "Uuid", + "Timestamptz", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "6410d6d28f9f27588505ca95ac67fdec18f377bd0fc9d1d33c31f3f0b79d459d" +} diff --git a/.sqlx/query-64e1397e479b21af86d7c24f14bd3004685915c5f1f2f166a78ffd437d1808f8.json b/.sqlx/query-64e1397e479b21af86d7c24f14bd3004685915c5f1f2f166a78ffd437d1808f8.json deleted file mode 100644 index 8482ddf9..00000000 --- a/.sqlx/query-64e1397e479b21af86d7c24f14bd3004685915c5f1f2f166a78ffd437d1808f8.json +++ /dev/null @@ -1,77 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n SELECT b.*, e.sequence, e.event\n FROM bria_payouts b\n JOIN bria_payout_events e ON b.id = e.id\n WHERE b.account_id = $1 AND b.batch_id = $2\n ORDER BY b.created_at, b.id, e.sequence", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "id", - "type_info": "Uuid" - }, - { - "ordinal": 1, - "name": "account_id", - "type_info": "Uuid" - }, - { - "ordinal": 2, - "name": "wallet_id", - "type_info": "Uuid" - }, - { - "ordinal": 3, - "name": "payout_queue_id", - "type_info": "Uuid" - }, - { - "ordinal": 4, - "name": "batch_id", - "type_info": "Uuid" - }, - { - "ordinal": 5, - "name": "profile_id", - "type_info": "Uuid" - }, - { - "ordinal": 6, - "name": "external_id", - "type_info": "Varchar" - }, - { - "ordinal": 7, - "name": "created_at", - "type_info": "Timestamptz" - }, - { - "ordinal": 8, - "name": "sequence", - "type_info": "Int4" - }, - { - "ordinal": 9, - "name": "event", - "type_info": "Jsonb" - } - ], - "parameters": { - "Left": [ - "Uuid", - "Uuid" - ] - }, - "nullable": [ - false, - false, - false, - false, - true, - false, - false, - false, - false, - false - ] - }, - "hash": "64e1397e479b21af86d7c24f14bd3004685915c5f1f2f166a78ffd437d1808f8" -} diff --git a/.sqlx/query-651c7f85cde2b21940a6d78ac5b2e33e910a69ab164432e6cf4cbad42aabb6c8.json b/.sqlx/query-651c7f85cde2b21940a6d78ac5b2e33e910a69ab164432e6cf4cbad42aabb6c8.json new file mode 100644 index 00000000..6900eb83 --- /dev/null +++ b/.sqlx/query-651c7f85cde2b21940a6d78ac5b2e33e910a69ab164432e6cf4cbad42aabb6c8.json @@ -0,0 +1,49 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT created_at, id FROM bria_profiles WHERE (COALESCE((created_at, id) < ($3, $2), $2 IS NULL)) ORDER BY created_at DESC, id DESC LIMIT $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $4 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_profile_events e ON i.id = e.id ORDER BY i.created_at desc, i.id desc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Int8", + "Uuid", + "Timestamptz", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "651c7f85cde2b21940a6d78ac5b2e33e910a69ab164432e6cf4cbad42aabb6c8" +} diff --git a/.sqlx/query-65983b64c9a35cb2869757d3d734053ce507f6ba50564e05606c4b153cdec4f7.json b/.sqlx/query-65983b64c9a35cb2869757d3d734053ce507f6ba50564e05606c4b153cdec4f7.json deleted file mode 100644 index ad0fe4b0..00000000 --- a/.sqlx/query-65983b64c9a35cb2869757d3d734053ce507f6ba50564e05606c4b153cdec4f7.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "SELECT b.*, e.sequence, e.event\n FROM bria_xpubs b\n JOIN bria_xpub_events e ON b.id = e.id\n ORDER BY b.id, e.sequence", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "id", - "type_info": "Uuid" - }, - { - "ordinal": 1, - "name": "account_id", - "type_info": "Uuid" - }, - { - "ordinal": 2, - "name": "name", - "type_info": "Varchar" - }, - { - "ordinal": 3, - "name": "fingerprint", - "type_info": "Bytea" - }, - { - "ordinal": 4, - "name": "created_at", - "type_info": "Timestamptz" - }, - { - "ordinal": 5, - "name": "sequence", - "type_info": "Int4" - }, - { - "ordinal": 6, - "name": "event", - "type_info": "Jsonb" - } - ], - "parameters": { - "Left": [] - }, - "nullable": [ - false, - false, - false, - false, - false, - false, - false - ] - }, - "hash": "65983b64c9a35cb2869757d3d734053ce507f6ba50564e05606c4b153cdec4f7" -} diff --git a/.sqlx/query-659b0e11d8ed5120ab4151c46b8ca2d990d2c9684cc57fdd495e5b563c338437.json b/.sqlx/query-659b0e11d8ed5120ab4151c46b8ca2d990d2c9684cc57fdd495e5b563c338437.json new file mode 100644 index 00000000..568723a5 --- /dev/null +++ b/.sqlx/query-659b0e11d8ed5120ab4151c46b8ca2d990d2c9684cc57fdd495e5b563c338437.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE bria_profiles SET name = $2 WHERE id = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Varchar" + ] + }, + "nullable": [] + }, + "hash": "659b0e11d8ed5120ab4151c46b8ca2d990d2c9684cc57fdd495e5b563c338437" +} diff --git a/.sqlx/query-67a94493771ad889e590e34119af5a4dcbcc639b64db76868f18c282496fd9d8.json b/.sqlx/query-67a94493771ad889e590e34119af5a4dcbcc639b64db76868f18c282496fd9d8.json new file mode 100644 index 00000000..e0ccd24a --- /dev/null +++ b/.sqlx/query-67a94493771ad889e590e34119af5a4dcbcc639b64db76868f18c282496fd9d8.json @@ -0,0 +1,47 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM bria_payouts WHERE batch_id = $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $2 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_payout_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "67a94493771ad889e590e34119af5a4dcbcc639b64db76868f18c282496fd9d8" +} diff --git a/.sqlx/query-68b14c073e8cf6ba8e9ab0eec3196ddaf5431985cacecc4ded972cbdd76c0ea0.json b/.sqlx/query-68b14c073e8cf6ba8e9ab0eec3196ddaf5431985cacecc4ded972cbdd76c0ea0.json new file mode 100644 index 00000000..a82b0b52 --- /dev/null +++ b/.sqlx/query-68b14c073e8cf6ba8e9ab0eec3196ddaf5431985cacecc4ded972cbdd76c0ea0.json @@ -0,0 +1,47 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM bria_addresses WHERE profile_id = $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $2 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_address_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "68b14c073e8cf6ba8e9ab0eec3196ddaf5431985cacecc4ded972cbdd76c0ea0" +} diff --git a/.sqlx/query-69bd5e490e0e0a1eff1fda2616f73e89a70fb1b35fe55b36fe4ba7a6b72d0c7f.json b/.sqlx/query-69bd5e490e0e0a1eff1fda2616f73e89a70fb1b35fe55b36fe4ba7a6b72d0c7f.json new file mode 100644 index 00000000..0c5722f4 --- /dev/null +++ b/.sqlx/query-69bd5e490e0e0a1eff1fda2616f73e89a70fb1b35fe55b36fe4ba7a6b72d0c7f.json @@ -0,0 +1,47 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM bria_addresses WHERE external_id = $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $2 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_address_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Text", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "69bd5e490e0e0a1eff1fda2616f73e89a70fb1b35fe55b36fe4ba7a6b72d0c7f" +} diff --git a/.sqlx/query-6c752d8fc85a3062ed39cbbed6e7d9729de1727487bd8e71e0e00ffcf1f4db1b.json b/.sqlx/query-6c752d8fc85a3062ed39cbbed6e7d9729de1727487bd8e71e0e00ffcf1f4db1b.json deleted file mode 100644 index 892a59d9..00000000 --- a/.sqlx/query-6c752d8fc85a3062ed39cbbed6e7d9729de1727487bd8e71e0e00ffcf1f4db1b.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n SELECT b.*, e.sequence, e.event\n FROM bria_payout_queues b\n JOIN bria_payout_queue_events e ON b.id = e.id\n WHERE account_id = $1\n ORDER BY b.id, e.sequence", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "id", - "type_info": "Uuid" - }, - { - "ordinal": 1, - "name": "account_id", - "type_info": "Uuid" - }, - { - "ordinal": 2, - "name": "name", - "type_info": "Varchar" - }, - { - "ordinal": 3, - "name": "created_at", - "type_info": "Timestamptz" - }, - { - "ordinal": 4, - "name": "sequence", - "type_info": "Int4" - }, - { - "ordinal": 5, - "name": "event", - "type_info": "Jsonb" - } - ], - "parameters": { - "Left": [ - "Uuid" - ] - }, - "nullable": [ - false, - false, - false, - false, - false, - false - ] - }, - "hash": "6c752d8fc85a3062ed39cbbed6e7d9729de1727487bd8e71e0e00ffcf1f4db1b" -} diff --git a/.sqlx/query-6fa7a9326c5d6e6c6df0ca32ccc19d8087435b01729b10c9bf03d9fece190620.json b/.sqlx/query-6fa7a9326c5d6e6c6df0ca32ccc19d8087435b01729b10c9bf03d9fece190620.json new file mode 100644 index 00000000..cb6fb9f5 --- /dev/null +++ b/.sqlx/query-6fa7a9326c5d6e6c6df0ca32ccc19d8087435b01729b10c9bf03d9fece190620.json @@ -0,0 +1,47 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM bria_signing_sessions WHERE account_id = $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $2 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_signing_session_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "6fa7a9326c5d6e6c6df0ca32ccc19d8087435b01729b10c9bf03d9fece190620" +} diff --git a/.sqlx/query-7296151c0d2387a0894ec37e082664d7d63ef81e673db3dfaa7a882c34ba8d25.json b/.sqlx/query-7296151c0d2387a0894ec37e082664d7d63ef81e673db3dfaa7a882c34ba8d25.json deleted file mode 100644 index bb607dc6..00000000 --- a/.sqlx/query-7296151c0d2387a0894ec37e082664d7d63ef81e673db3dfaa7a882c34ba8d25.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "INSERT INTO bria_xpubs\n (id, account_id, name, fingerprint)\n VALUES ($1, $2, $3, $4)", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Uuid", - "Uuid", - "Varchar", - "Bytea" - ] - }, - "nullable": [] - }, - "hash": "7296151c0d2387a0894ec37e082664d7d63ef81e673db3dfaa7a882c34ba8d25" -} diff --git a/.sqlx/query-73e923f09d1669e337752eff676842a5247b8f632258c8344c78cf9eb63aadb7.json b/.sqlx/query-73e923f09d1669e337752eff676842a5247b8f632258c8344c78cf9eb63aadb7.json new file mode 100644 index 00000000..bef53f0b --- /dev/null +++ b/.sqlx/query-73e923f09d1669e337752eff676842a5247b8f632258c8344c78cf9eb63aadb7.json @@ -0,0 +1,47 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM bria_payout_queues WHERE id = ANY($1)) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $2 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_payout_queue_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "UuidArray", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "73e923f09d1669e337752eff676842a5247b8f632258c8344c78cf9eb63aadb7" +} diff --git a/.sqlx/query-747102dbe477b86627debbdddb9f30884dcb2e8bf06603f4a96240b364fb4b9f.json b/.sqlx/query-747102dbe477b86627debbdddb9f30884dcb2e8bf06603f4a96240b364fb4b9f.json deleted file mode 100644 index 94170bbc..00000000 --- a/.sqlx/query-747102dbe477b86627debbdddb9f30884dcb2e8bf06603f4a96240b364fb4b9f.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "SELECT b.*, e.sequence, e.event\n FROM bria_xpubs b\n JOIN bria_xpub_events e ON b.id = e.id\n WHERE account_id = $1\n ORDER BY b.id, e.sequence", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "id", - "type_info": "Uuid" - }, - { - "ordinal": 1, - "name": "account_id", - "type_info": "Uuid" - }, - { - "ordinal": 2, - "name": "name", - "type_info": "Varchar" - }, - { - "ordinal": 3, - "name": "fingerprint", - "type_info": "Bytea" - }, - { - "ordinal": 4, - "name": "created_at", - "type_info": "Timestamptz" - }, - { - "ordinal": 5, - "name": "sequence", - "type_info": "Int4" - }, - { - "ordinal": 6, - "name": "event", - "type_info": "Jsonb" - } - ], - "parameters": { - "Left": [ - "Uuid" - ] - }, - "nullable": [ - false, - false, - false, - false, - false, - false, - false - ] - }, - "hash": "747102dbe477b86627debbdddb9f30884dcb2e8bf06603f4a96240b364fb4b9f" -} diff --git a/.sqlx/query-74e5556f4ce33703b1f885b77025944a11182e90c444f05d7590b2f8cf6388d4.json b/.sqlx/query-74e5556f4ce33703b1f885b77025944a11182e90c444f05d7590b2f8cf6388d4.json new file mode 100644 index 00000000..5cecc3e3 --- /dev/null +++ b/.sqlx/query-74e5556f4ce33703b1f885b77025944a11182e90c444f05d7590b2f8cf6388d4.json @@ -0,0 +1,49 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT created_at, id FROM bria_wallets WHERE (COALESCE((created_at, id) < ($3, $2), $2 IS NULL)) ORDER BY created_at DESC, id DESC LIMIT $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $4 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_wallet_events e ON i.id = e.id ORDER BY i.created_at desc, i.id desc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Int8", + "Uuid", + "Timestamptz", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "74e5556f4ce33703b1f885b77025944a11182e90c444f05d7590b2f8cf6388d4" +} diff --git a/.sqlx/query-754a9e381f4f1380f333aa10d4736056af57b2963edfc3ca8d75bfc7927b8a28.json b/.sqlx/query-754a9e381f4f1380f333aa10d4736056af57b2963edfc3ca8d75bfc7927b8a28.json new file mode 100644 index 00000000..e801fef2 --- /dev/null +++ b/.sqlx/query-754a9e381f4f1380f333aa10d4736056af57b2963edfc3ca8d75bfc7927b8a28.json @@ -0,0 +1,50 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT account_id, created_at, id FROM bria_wallets WHERE ((account_id = $1) AND (COALESCE((created_at, id) > ($4, $3), $3 IS NULL))) ORDER BY created_at ASC, id ASC LIMIT $2) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $5 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_wallet_events e ON i.id = e.id ORDER BY i.created_at asc, i.id asc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Int8", + "Uuid", + "Timestamptz", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "754a9e381f4f1380f333aa10d4736056af57b2963edfc3ca8d75bfc7927b8a28" +} diff --git a/.sqlx/query-79e09f688287c0e77c5d52fd4f3834f1d2f3bc009f86e3f5c4f948392f077555.json b/.sqlx/query-79e09f688287c0e77c5d52fd4f3834f1d2f3bc009f86e3f5c4f948392f077555.json new file mode 100644 index 00000000..f3d3bce1 --- /dev/null +++ b/.sqlx/query-79e09f688287c0e77c5d52fd4f3834f1d2f3bc009f86e3f5c4f948392f077555.json @@ -0,0 +1,50 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT account_id, created_at, id FROM bria_profiles WHERE ((account_id = $1) AND (COALESCE((created_at, id) < ($4, $3), $3 IS NULL))) ORDER BY created_at DESC, id DESC LIMIT $2) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $5 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_profile_events e ON i.id = e.id ORDER BY i.created_at desc, i.id desc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Int8", + "Uuid", + "Timestamptz", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "79e09f688287c0e77c5d52fd4f3834f1d2f3bc009f86e3f5c4f948392f077555" +} diff --git a/.sqlx/query-7bc59c8ce644a8ee34259fcb48cc67ca55a129d5c98b1a9bf0080d3ee0188fee.json b/.sqlx/query-7bc59c8ce644a8ee34259fcb48cc67ca55a129d5c98b1a9bf0080d3ee0188fee.json new file mode 100644 index 00000000..0593e255 --- /dev/null +++ b/.sqlx/query-7bc59c8ce644a8ee34259fcb48cc67ca55a129d5c98b1a9bf0080d3ee0188fee.json @@ -0,0 +1,26 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO bria_address_events (id, recorded_at, sequence, event_type, event) SELECT $1, COALESCE($2, NOW()), ROW_NUMBER() OVER () + $3, unnested.event_type, unnested.event FROM UNNEST($4::TEXT[], $5::JSONB[]) AS unnested(event_type, event) RETURNING recorded_at", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Timestamptz", + "Int8", + "TextArray", + "JsonbArray" + ] + }, + "nullable": [ + false + ] + }, + "hash": "7bc59c8ce644a8ee34259fcb48cc67ca55a129d5c98b1a9bf0080d3ee0188fee" +} diff --git a/.sqlx/query-7c0ecd129f976df38b788e7e89b54d10632d96210d4dd59e4eeba1fd71117348.json b/.sqlx/query-7c0ecd129f976df38b788e7e89b54d10632d96210d4dd59e4eeba1fd71117348.json deleted file mode 100644 index 76d096ba..00000000 --- a/.sqlx/query-7c0ecd129f976df38b788e7e89b54d10632d96210d4dd59e4eeba1fd71117348.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n SELECT b.id, e.sequence, e.event\n FROM bria_addresses b\n JOIN bria_address_events e ON b.id = e.id\n WHERE account_id = $1 AND external_id = $2\n ORDER BY b.created_at, b.id, sequence", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "id", - "type_info": "Uuid" - }, - { - "ordinal": 1, - "name": "sequence", - "type_info": "Int4" - }, - { - "ordinal": 2, - "name": "event", - "type_info": "Jsonb" - } - ], - "parameters": { - "Left": [ - "Uuid", - "Text" - ] - }, - "nullable": [ - false, - false, - false - ] - }, - "hash": "7c0ecd129f976df38b788e7e89b54d10632d96210d4dd59e4eeba1fd71117348" -} diff --git a/.sqlx/query-8088ec5ad2424a142a976b47a26625ac25b90d86ae8cf2a0757c9b5fbc277559.json b/.sqlx/query-8088ec5ad2424a142a976b47a26625ac25b90d86ae8cf2a0757c9b5fbc277559.json new file mode 100644 index 00000000..7e000f78 --- /dev/null +++ b/.sqlx/query-8088ec5ad2424a142a976b47a26625ac25b90d86ae8cf2a0757c9b5fbc277559.json @@ -0,0 +1,48 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (\n SELECT *\n FROM bria_xpubs\n WHERE account_id = $1 AND name = $2) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $3 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_xpub_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "8088ec5ad2424a142a976b47a26625ac25b90d86ae8cf2a0757c9b5fbc277559" +} diff --git a/.sqlx/query-813653d1aaa7ba4d6b4f8ce356f0898f1c086e63fa7a35a0ef16920621a2135a.json b/.sqlx/query-813653d1aaa7ba4d6b4f8ce356f0898f1c086e63fa7a35a0ef16920621a2135a.json deleted file mode 100644 index ebd65abe..00000000 --- a/.sqlx/query-813653d1aaa7ba4d6b4f8ce356f0898f1c086e63fa7a35a0ef16920621a2135a.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "SELECT p.id, e.sequence, e.event_type, e.event\n FROM bria_profiles p\n JOIN bria_profile_events e ON p.id = e.id\n WHERE p.account_id = $1 AND p.name = $2\n ORDER BY p.id, sequence", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "id", - "type_info": "Uuid" - }, - { - "ordinal": 1, - "name": "sequence", - "type_info": "Int4" - }, - { - "ordinal": 2, - "name": "event_type", - "type_info": "Varchar" - }, - { - "ordinal": 3, - "name": "event", - "type_info": "Jsonb" - } - ], - "parameters": { - "Left": [ - "Uuid", - "Text" - ] - }, - "nullable": [ - false, - false, - false, - false - ] - }, - "hash": "813653d1aaa7ba4d6b4f8ce356f0898f1c086e63fa7a35a0ef16920621a2135a" -} diff --git a/.sqlx/query-82ba0a25e509214930d78806f91d7c0a741716334f567da9f0bd7252a8a85fff.json b/.sqlx/query-82ba0a25e509214930d78806f91d7c0a741716334f567da9f0bd7252a8a85fff.json deleted file mode 100644 index dd1737c3..00000000 --- a/.sqlx/query-82ba0a25e509214930d78806f91d7c0a741716334f567da9f0bd7252a8a85fff.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n WITH payouts AS (\n SELECT *\n FROM bria_payouts\n WHERE account_id = $1 AND wallet_id = $2\n ORDER BY created_at DESC, id\n LIMIT $3 OFFSET $4\n )\n SELECT p.*, e.sequence, e.event\n FROM payouts p\n JOIN bria_payout_events e ON p.id = e.id\n ORDER BY p.created_at DESC, p.id, e.sequence\n ", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "id", - "type_info": "Uuid" - }, - { - "ordinal": 1, - "name": "account_id", - "type_info": "Uuid" - }, - { - "ordinal": 2, - "name": "wallet_id", - "type_info": "Uuid" - }, - { - "ordinal": 3, - "name": "payout_queue_id", - "type_info": "Uuid" - }, - { - "ordinal": 4, - "name": "batch_id", - "type_info": "Uuid" - }, - { - "ordinal": 5, - "name": "profile_id", - "type_info": "Uuid" - }, - { - "ordinal": 6, - "name": "external_id", - "type_info": "Varchar" - }, - { - "ordinal": 7, - "name": "created_at", - "type_info": "Timestamptz" - }, - { - "ordinal": 8, - "name": "sequence", - "type_info": "Int4" - }, - { - "ordinal": 9, - "name": "event", - "type_info": "Jsonb" - } - ], - "parameters": { - "Left": [ - "Uuid", - "Uuid", - "Int8", - "Int8" - ] - }, - "nullable": [ - false, - false, - false, - false, - true, - false, - false, - false, - false, - false - ] - }, - "hash": "82ba0a25e509214930d78806f91d7c0a741716334f567da9f0bd7252a8a85fff" -} diff --git a/.sqlx/query-839e3df591c13563d89a06f0b31a559bf4f8df385640d94522c32af78c1d9f86.json b/.sqlx/query-839e3df591c13563d89a06f0b31a559bf4f8df385640d94522c32af78c1d9f86.json new file mode 100644 index 00000000..2f5b29ab --- /dev/null +++ b/.sqlx/query-839e3df591c13563d89a06f0b31a559bf4f8df385640d94522c32af78c1d9f86.json @@ -0,0 +1,17 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO bria_wallets (id, name, account_id, created_at) VALUES ($1, $2, $3, COALESCE($4, NOW()))", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Varchar", + "Uuid", + "Timestamptz" + ] + }, + "nullable": [] + }, + "hash": "839e3df591c13563d89a06f0b31a559bf4f8df385640d94522c32af78c1d9f86" +} diff --git a/.sqlx/query-8420a910396dae3967aac75e1ca9d98c7e2d5918b4c35509875a8c0f484868d1.json b/.sqlx/query-8420a910396dae3967aac75e1ca9d98c7e2d5918b4c35509875a8c0f484868d1.json new file mode 100644 index 00000000..733722e2 --- /dev/null +++ b/.sqlx/query-8420a910396dae3967aac75e1ca9d98c7e2d5918b4c35509875a8c0f484868d1.json @@ -0,0 +1,48 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (\n SELECT *\n FROM bria_payouts\n WHERE account_id = $1 AND id = $2\n FOR UPDATE) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $3 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_payout_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Uuid", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "8420a910396dae3967aac75e1ca9d98c7e2d5918b4c35509875a8c0f484868d1" +} diff --git a/.sqlx/query-8457bdb0419366f289fb8c02d6c89a68b26af13f5bf87ee838647e3d887a074d.json b/.sqlx/query-8457bdb0419366f289fb8c02d6c89a68b26af13f5bf87ee838647e3d887a074d.json deleted file mode 100644 index c91c75f6..00000000 --- a/.sqlx/query-8457bdb0419366f289fb8c02d6c89a68b26af13f5bf87ee838647e3d887a074d.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n SELECT b.*, e.sequence, e.event\n FROM bria_wallets b\n JOIN bria_wallet_events e ON b.id = e.id\n WHERE b.id = ANY($1)\n ORDER BY b.id, e.sequence", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "id", - "type_info": "Uuid" - }, - { - "ordinal": 1, - "name": "account_id", - "type_info": "Uuid" - }, - { - "ordinal": 2, - "name": "name", - "type_info": "Varchar" - }, - { - "ordinal": 3, - "name": "created_at", - "type_info": "Timestamptz" - }, - { - "ordinal": 4, - "name": "sequence", - "type_info": "Int4" - }, - { - "ordinal": 5, - "name": "event", - "type_info": "Jsonb" - } - ], - "parameters": { - "Left": [ - "UuidArray" - ] - }, - "nullable": [ - false, - false, - false, - false, - false, - false - ] - }, - "hash": "8457bdb0419366f289fb8c02d6c89a68b26af13f5bf87ee838647e3d887a074d" -} diff --git a/.sqlx/query-84d91e20f5d28bbab272e4d481b359c634703516e9ea01223db85d95b4744870.json b/.sqlx/query-84d91e20f5d28bbab272e4d481b359c634703516e9ea01223db85d95b4744870.json new file mode 100644 index 00000000..f1b654c7 --- /dev/null +++ b/.sqlx/query-84d91e20f5d28bbab272e4d481b359c634703516e9ea01223db85d95b4744870.json @@ -0,0 +1,47 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM bria_wallets WHERE name = $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $2 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_wallet_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Text", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "84d91e20f5d28bbab272e4d481b359c634703516e9ea01223db85d95b4744870" +} diff --git a/.sqlx/query-89eb48e57e3bd851f7be9e177da99107e86eeb4e9c1c0884dbed1b39af235de3.json b/.sqlx/query-89eb48e57e3bd851f7be9e177da99107e86eeb4e9c1c0884dbed1b39af235de3.json new file mode 100644 index 00000000..a0c4d2ef --- /dev/null +++ b/.sqlx/query-89eb48e57e3bd851f7be9e177da99107e86eeb4e9c1c0884dbed1b39af235de3.json @@ -0,0 +1,47 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM bria_payouts WHERE profile_id = $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $2 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_payout_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "89eb48e57e3bd851f7be9e177da99107e86eeb4e9c1c0884dbed1b39af235de3" +} diff --git a/.sqlx/query-8bed18f3ad626ecf4f87a4f40f9bb33bd35105facfcdea1a16bcb5cc8edb82b8.json b/.sqlx/query-8bed18f3ad626ecf4f87a4f40f9bb33bd35105facfcdea1a16bcb5cc8edb82b8.json new file mode 100644 index 00000000..b5a4d9f6 --- /dev/null +++ b/.sqlx/query-8bed18f3ad626ecf4f87a4f40f9bb33bd35105facfcdea1a16bcb5cc8edb82b8.json @@ -0,0 +1,18 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO bria_signing_sessions (id, batch_id, account_id, xpub_fingerprint, created_at) VALUES ($1, $2, $3, $4, COALESCE($5, NOW()))", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Uuid", + "Uuid", + "Bytea", + "Timestamptz" + ] + }, + "nullable": [] + }, + "hash": "8bed18f3ad626ecf4f87a4f40f9bb33bd35105facfcdea1a16bcb5cc8edb82b8" +} diff --git a/.sqlx/query-8cce80df3c9d7536556247bf40d2a9e30acca15fdcf381dd6a89853f95960fef.json b/.sqlx/query-8cce80df3c9d7536556247bf40d2a9e30acca15fdcf381dd6a89853f95960fef.json new file mode 100644 index 00000000..04ada43a --- /dev/null +++ b/.sqlx/query-8cce80df3c9d7536556247bf40d2a9e30acca15fdcf381dd6a89853f95960fef.json @@ -0,0 +1,47 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM bria_signing_sessions WHERE xpub_fingerprint = $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $2 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_signing_session_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Bytea", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "8cce80df3c9d7536556247bf40d2a9e30acca15fdcf381dd6a89853f95960fef" +} diff --git a/.sqlx/query-8d382d165e54a659f3afeaf155e2981e6f4172ce7b7b8d4d66ea8021cd6c88d4.json b/.sqlx/query-8d382d165e54a659f3afeaf155e2981e6f4172ce7b7b8d4d66ea8021cd6c88d4.json new file mode 100644 index 00000000..6cba081b --- /dev/null +++ b/.sqlx/query-8d382d165e54a659f3afeaf155e2981e6f4172ce7b7b8d4d66ea8021cd6c88d4.json @@ -0,0 +1,47 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM bria_payout_queues WHERE account_id = $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $2 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_payout_queue_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "8d382d165e54a659f3afeaf155e2981e6f4172ce7b7b8d4d66ea8021cd6c88d4" +} diff --git a/.sqlx/query-8d68beea7322d53f605613244f5ea717e83e70970404850f745d94ed3e26b012.json b/.sqlx/query-8d68beea7322d53f605613244f5ea717e83e70970404850f745d94ed3e26b012.json new file mode 100644 index 00000000..942e2e63 --- /dev/null +++ b/.sqlx/query-8d68beea7322d53f605613244f5ea717e83e70970404850f745d94ed3e26b012.json @@ -0,0 +1,49 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT created_at, id FROM bria_addresses WHERE (COALESCE((created_at, id) < ($3, $2), $2 IS NULL)) ORDER BY created_at DESC, id DESC LIMIT $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $4 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_address_events e ON i.id = e.id ORDER BY i.created_at desc, i.id desc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Int8", + "Uuid", + "Timestamptz", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "8d68beea7322d53f605613244f5ea717e83e70970404850f745d94ed3e26b012" +} diff --git a/.sqlx/query-8da2c300e2c276f0838877f4ac213e524b6fb53e4e52d80c90aeb6d27b59472b.json b/.sqlx/query-8da2c300e2c276f0838877f4ac213e524b6fb53e4e52d80c90aeb6d27b59472b.json new file mode 100644 index 00000000..a9c35aa9 --- /dev/null +++ b/.sqlx/query-8da2c300e2c276f0838877f4ac213e524b6fb53e4e52d80c90aeb6d27b59472b.json @@ -0,0 +1,49 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT account_id, id FROM bria_wallets WHERE ((account_id = $1) AND (COALESCE(id > $3, true))) ORDER BY id ASC LIMIT $2) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $4 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_wallet_events e ON i.id = e.id ORDER BY i.id asc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Int8", + "Uuid", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "8da2c300e2c276f0838877f4ac213e524b6fb53e4e52d80c90aeb6d27b59472b" +} diff --git a/.sqlx/query-8dba7efce7de6cbe27b17bae89eff8625492bbe3ce21e7aa12c1c4bbd43cc5e3.json b/.sqlx/query-8dba7efce7de6cbe27b17bae89eff8625492bbe3ce21e7aa12c1c4bbd43cc5e3.json deleted file mode 100644 index d7d3532a..00000000 --- a/.sqlx/query-8dba7efce7de6cbe27b17bae89eff8625492bbe3ce21e7aa12c1c4bbd43cc5e3.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n SELECT b.id, e.sequence, e.event\n FROM bria_addresses b\n JOIN bria_address_events e ON b.id = e.id\n WHERE account_id = $1 AND address = $2\n ORDER BY b.created_at, b.id, sequence", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "id", - "type_info": "Uuid" - }, - { - "ordinal": 1, - "name": "sequence", - "type_info": "Int4" - }, - { - "ordinal": 2, - "name": "event", - "type_info": "Jsonb" - } - ], - "parameters": { - "Left": [ - "Uuid", - "Text" - ] - }, - "nullable": [ - false, - false, - false - ] - }, - "hash": "8dba7efce7de6cbe27b17bae89eff8625492bbe3ce21e7aa12c1c4bbd43cc5e3" -} diff --git a/.sqlx/query-8ddc2ea9bc99f7b4b1c004147c0f651ae0346f631b2393d5f4e45f9f18c5e20c.json b/.sqlx/query-8ddc2ea9bc99f7b4b1c004147c0f651ae0346f631b2393d5f4e45f9f18c5e20c.json deleted file mode 100644 index b0803609..00000000 --- a/.sqlx/query-8ddc2ea9bc99f7b4b1c004147c0f651ae0346f631b2393d5f4e45f9f18c5e20c.json +++ /dev/null @@ -1,77 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n SELECT b.*, e.sequence, e.event\n FROM bria_payouts b\n JOIN bria_payout_events e ON b.id = e.id\n WHERE account_id = $1 AND b.external_id = $2\n ORDER BY b.created_at, b.id, e.sequence", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "id", - "type_info": "Uuid" - }, - { - "ordinal": 1, - "name": "account_id", - "type_info": "Uuid" - }, - { - "ordinal": 2, - "name": "wallet_id", - "type_info": "Uuid" - }, - { - "ordinal": 3, - "name": "payout_queue_id", - "type_info": "Uuid" - }, - { - "ordinal": 4, - "name": "batch_id", - "type_info": "Uuid" - }, - { - "ordinal": 5, - "name": "profile_id", - "type_info": "Uuid" - }, - { - "ordinal": 6, - "name": "external_id", - "type_info": "Varchar" - }, - { - "ordinal": 7, - "name": "created_at", - "type_info": "Timestamptz" - }, - { - "ordinal": 8, - "name": "sequence", - "type_info": "Int4" - }, - { - "ordinal": 9, - "name": "event", - "type_info": "Jsonb" - } - ], - "parameters": { - "Left": [ - "Uuid", - "Text" - ] - }, - "nullable": [ - false, - false, - false, - false, - true, - false, - false, - false, - false, - false - ] - }, - "hash": "8ddc2ea9bc99f7b4b1c004147c0f651ae0346f631b2393d5f4e45f9f18c5e20c" -} diff --git a/.sqlx/query-8e3974b17ab74e96b834e82593e5540aedf3a772ffcf06983e57b85849a6920d.json b/.sqlx/query-8e3974b17ab74e96b834e82593e5540aedf3a772ffcf06983e57b85849a6920d.json new file mode 100644 index 00000000..3d87e42f --- /dev/null +++ b/.sqlx/query-8e3974b17ab74e96b834e82593e5540aedf3a772ffcf06983e57b85849a6920d.json @@ -0,0 +1,47 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM bria_payout_queues WHERE name = $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $2 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_payout_queue_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Text", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "8e3974b17ab74e96b834e82593e5540aedf3a772ffcf06983e57b85849a6920d" +} diff --git a/.sqlx/query-8e4f7e84cfe51ef1d96cca775484a615467540ce6400d8a1a0f281ebcfcb0914.json b/.sqlx/query-8e4f7e84cfe51ef1d96cca775484a615467540ce6400d8a1a0f281ebcfcb0914.json new file mode 100644 index 00000000..dd192f1c --- /dev/null +++ b/.sqlx/query-8e4f7e84cfe51ef1d96cca775484a615467540ce6400d8a1a0f281ebcfcb0914.json @@ -0,0 +1,47 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM bria_payout_queues WHERE id = $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $2 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_payout_queue_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "8e4f7e84cfe51ef1d96cca775484a615467540ce6400d8a1a0f281ebcfcb0914" +} diff --git a/.sqlx/query-914a4e691e66ffebf6a3826358b035d1fbb1cb58570d3ffce6fdcd2ee98d7754.json b/.sqlx/query-914a4e691e66ffebf6a3826358b035d1fbb1cb58570d3ffce6fdcd2ee98d7754.json new file mode 100644 index 00000000..411ee866 --- /dev/null +++ b/.sqlx/query-914a4e691e66ffebf6a3826358b035d1fbb1cb58570d3ffce6fdcd2ee98d7754.json @@ -0,0 +1,47 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM bria_payouts WHERE account_id = $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $2 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_payout_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "914a4e691e66ffebf6a3826358b035d1fbb1cb58570d3ffce6fdcd2ee98d7754" +} diff --git a/.sqlx/query-918f542fb54a94b1b44d84064afc45f2216292d36205ea145014c06a4d795939.json b/.sqlx/query-918f542fb54a94b1b44d84064afc45f2216292d36205ea145014c06a4d795939.json new file mode 100644 index 00000000..ba1cde0a --- /dev/null +++ b/.sqlx/query-918f542fb54a94b1b44d84064afc45f2216292d36205ea145014c06a4d795939.json @@ -0,0 +1,50 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT account_id, created_at, id FROM bria_profiles WHERE ((account_id = $1) AND (COALESCE((created_at, id) > ($4, $3), $3 IS NULL))) ORDER BY created_at ASC, id ASC LIMIT $2) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $5 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_profile_events e ON i.id = e.id ORDER BY i.created_at asc, i.id asc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Int8", + "Uuid", + "Timestamptz", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "918f542fb54a94b1b44d84064afc45f2216292d36205ea145014c06a4d795939" +} diff --git a/.sqlx/query-933623d4358ba31ba8d7190fdee7deabf19d4205592b96fd6e11594cc8ef027b.json b/.sqlx/query-933623d4358ba31ba8d7190fdee7deabf19d4205592b96fd6e11594cc8ef027b.json new file mode 100644 index 00000000..7d77b50e --- /dev/null +++ b/.sqlx/query-933623d4358ba31ba8d7190fdee7deabf19d4205592b96fd6e11594cc8ef027b.json @@ -0,0 +1,47 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM bria_signing_sessions WHERE id = ANY($1)) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $2 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_signing_session_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "UuidArray", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "933623d4358ba31ba8d7190fdee7deabf19d4205592b96fd6e11594cc8ef027b" +} diff --git a/.sqlx/query-9a2b2debb16baddba43e014451b6e0bdfdc49d66dd759985b95a1779aeee93ae.json b/.sqlx/query-9a2b2debb16baddba43e014451b6e0bdfdc49d66dd759985b95a1779aeee93ae.json new file mode 100644 index 00000000..5656af5c --- /dev/null +++ b/.sqlx/query-9a2b2debb16baddba43e014451b6e0bdfdc49d66dd759985b95a1779aeee93ae.json @@ -0,0 +1,49 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT account_id, id FROM bria_payout_queues WHERE ((account_id = $1) AND (COALESCE(id < $3, true))) ORDER BY id DESC LIMIT $2) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $4 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_payout_queue_events e ON i.id = e.id ORDER BY i.id desc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Int8", + "Uuid", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "9a2b2debb16baddba43e014451b6e0bdfdc49d66dd759985b95a1779aeee93ae" +} diff --git a/.sqlx/query-eb52716de47fe5a66c500d1bcd11bbb76b1d897bce46674bf97fc5e11c1133d9.json b/.sqlx/query-9d7db85c1b9a773f7605b9afc8487bc61d0784a24b3850ad29654d4682cc6ff2.json similarity index 50% rename from .sqlx/query-eb52716de47fe5a66c500d1bcd11bbb76b1d897bce46674bf97fc5e11c1133d9.json rename to .sqlx/query-9d7db85c1b9a773f7605b9afc8487bc61d0784a24b3850ad29654d4682cc6ff2.json index f73bcee1..ea090b45 100644 --- a/.sqlx/query-eb52716de47fe5a66c500d1bcd11bbb76b1d897bce46674bf97fc5e11c1133d9.json +++ b/.sqlx/query-9d7db85c1b9a773f7605b9afc8487bc61d0784a24b3850ad29654d4682cc6ff2.json @@ -1,53 +1,47 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT b.*, e.sequence, e.event\n FROM bria_payout_queues b\n JOIN bria_payout_queue_events e ON b.id = e.id\n WHERE account_id = $1 AND name = $2\n ORDER BY e.sequence", + "query": "WITH entities AS (SELECT id FROM bria_wallets WHERE id = $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $2 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_wallet_events e ON i.id = e.id ORDER BY i.id, e.sequence", "describe": { "columns": [ { "ordinal": 0, - "name": "id", + "name": "entity_id: Repo__Id", "type_info": "Uuid" }, { "ordinal": 1, - "name": "account_id", - "type_info": "Uuid" + "name": "sequence", + "type_info": "Int4" }, { "ordinal": 2, - "name": "name", - "type_info": "Varchar" + "name": "event", + "type_info": "Jsonb" }, { "ordinal": 3, - "name": "created_at", - "type_info": "Timestamptz" + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" }, { "ordinal": 4, - "name": "sequence", - "type_info": "Int4" - }, - { - "ordinal": 5, - "name": "event", - "type_info": "Jsonb" + "name": "recorded_at", + "type_info": "Timestamptz" } ], "parameters": { "Left": [ "Uuid", - "Text" + "Bool" ] }, "nullable": [ false, false, false, - false, - false, + null, false ] }, - "hash": "eb52716de47fe5a66c500d1bcd11bbb76b1d897bce46674bf97fc5e11c1133d9" + "hash": "9d7db85c1b9a773f7605b9afc8487bc61d0784a24b3850ad29654d4682cc6ff2" } diff --git a/.sqlx/query-a058cbc5f52a218ed02f0e163a0b2ae2bceb907599767b008e62da99b3eda013.json b/.sqlx/query-a058cbc5f52a218ed02f0e163a0b2ae2bceb907599767b008e62da99b3eda013.json new file mode 100644 index 00000000..b710c899 --- /dev/null +++ b/.sqlx/query-a058cbc5f52a218ed02f0e163a0b2ae2bceb907599767b008e62da99b3eda013.json @@ -0,0 +1,49 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT account_id, id FROM bria_payout_queues WHERE ((account_id = $1) AND (COALESCE(id > $3, true))) ORDER BY id ASC LIMIT $2) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $4 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_payout_queue_events e ON i.id = e.id ORDER BY i.id asc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Int8", + "Uuid", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "a058cbc5f52a218ed02f0e163a0b2ae2bceb907599767b008e62da99b3eda013" +} diff --git a/.sqlx/query-a2d860909e1587d9841dde47da88db794ebe87976c216efef7014d21ce8c4a35.json b/.sqlx/query-a2d860909e1587d9841dde47da88db794ebe87976c216efef7014d21ce8c4a35.json new file mode 100644 index 00000000..d110c4c8 --- /dev/null +++ b/.sqlx/query-a2d860909e1587d9841dde47da88db794ebe87976c216efef7014d21ce8c4a35.json @@ -0,0 +1,47 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM bria_payouts WHERE wallet_id = $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $2 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_payout_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "a2d860909e1587d9841dde47da88db794ebe87976c216efef7014d21ce8c4a35" +} diff --git a/.sqlx/query-a4f80cfdd4472ffc74a315fb9262ac73205efffa8a12e57753d6ae48ad097c41.json b/.sqlx/query-a4f80cfdd4472ffc74a315fb9262ac73205efffa8a12e57753d6ae48ad097c41.json deleted file mode 100644 index 2a92d8c2..00000000 --- a/.sqlx/query-a4f80cfdd4472ffc74a315fb9262ac73205efffa8a12e57753d6ae48ad097c41.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "SELECT id FROM bria_xpubs WHERE account_id = $1 AND fingerprint = $2", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "id", - "type_info": "Uuid" - } - ], - "parameters": { - "Left": [ - "Uuid", - "Bytea" - ] - }, - "nullable": [ - false - ] - }, - "hash": "a4f80cfdd4472ffc74a315fb9262ac73205efffa8a12e57753d6ae48ad097c41" -} diff --git a/.sqlx/query-a6c7c05a71de4e77ab7e798d784b2c40bf51598dd23600aae6d9c0821d2299a8.json b/.sqlx/query-a6c7c05a71de4e77ab7e798d784b2c40bf51598dd23600aae6d9c0821d2299a8.json new file mode 100644 index 00000000..b1c8b9df --- /dev/null +++ b/.sqlx/query-a6c7c05a71de4e77ab7e798d784b2c40bf51598dd23600aae6d9c0821d2299a8.json @@ -0,0 +1,47 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM bria_profiles WHERE name = $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $2 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_profile_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Text", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "a6c7c05a71de4e77ab7e798d784b2c40bf51598dd23600aae6d9c0821d2299a8" +} diff --git a/.sqlx/query-a7dea8e751999c43bffaf46c89454f667e58934943e5505f5835147fb062bb1d.json b/.sqlx/query-a7dea8e751999c43bffaf46c89454f667e58934943e5505f5835147fb062bb1d.json new file mode 100644 index 00000000..e3b9c55f --- /dev/null +++ b/.sqlx/query-a7dea8e751999c43bffaf46c89454f667e58934943e5505f5835147fb062bb1d.json @@ -0,0 +1,49 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT created_at, id FROM bria_payouts WHERE (COALESCE((created_at, id) < ($3, $2), $2 IS NULL)) ORDER BY created_at DESC, id DESC LIMIT $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $4 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_payout_events e ON i.id = e.id ORDER BY i.created_at desc, i.id desc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Int8", + "Uuid", + "Timestamptz", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "a7dea8e751999c43bffaf46c89454f667e58934943e5505f5835147fb062bb1d" +} diff --git a/.sqlx/query-a961ea487a0ede93f4848288efa855f425b4cfd6459e38c47a2d06c24ac95b19.json b/.sqlx/query-a961ea487a0ede93f4848288efa855f425b4cfd6459e38c47a2d06c24ac95b19.json new file mode 100644 index 00000000..7dfe96e9 --- /dev/null +++ b/.sqlx/query-a961ea487a0ede93f4848288efa855f425b4cfd6459e38c47a2d06c24ac95b19.json @@ -0,0 +1,47 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM bria_xpubs WHERE fingerprint = $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $2 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_xpub_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Bytea", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "a961ea487a0ede93f4848288efa855f425b4cfd6459e38c47a2d06c24ac95b19" +} diff --git a/.sqlx/query-aa048e4d6c645163c3276040283095ccf865219ca3384909081a7003495d7ac7.json b/.sqlx/query-aa048e4d6c645163c3276040283095ccf865219ca3384909081a7003495d7ac7.json new file mode 100644 index 00000000..06ee01e7 --- /dev/null +++ b/.sqlx/query-aa048e4d6c645163c3276040283095ccf865219ca3384909081a7003495d7ac7.json @@ -0,0 +1,48 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (\n SELECT *\n FROM bria_addresses\n WHERE account_id = $1 AND external_id = $2) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $3 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_address_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "aa048e4d6c645163c3276040283095ccf865219ca3384909081a7003495d7ac7" +} diff --git a/.sqlx/query-ad2bb2e98d01a3d21efe5ae284787c34a4524341b8590da66bae227f628f1dc4.json b/.sqlx/query-ad2bb2e98d01a3d21efe5ae284787c34a4524341b8590da66bae227f628f1dc4.json new file mode 100644 index 00000000..3770ec8a --- /dev/null +++ b/.sqlx/query-ad2bb2e98d01a3d21efe5ae284787c34a4524341b8590da66bae227f628f1dc4.json @@ -0,0 +1,49 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT created_at, id FROM bria_payout_queues WHERE (COALESCE((created_at, id) < ($3, $2), $2 IS NULL)) ORDER BY created_at DESC, id DESC LIMIT $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $4 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_payout_queue_events e ON i.id = e.id ORDER BY i.created_at desc, i.id desc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Int8", + "Uuid", + "Timestamptz", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "ad2bb2e98d01a3d21efe5ae284787c34a4524341b8590da66bae227f628f1dc4" +} diff --git a/.sqlx/query-adb7610f5ac193ef0c70d0a8d3eb5b59f2693c65024f5dc70323c5f7b3a84ecd.json b/.sqlx/query-adb7610f5ac193ef0c70d0a8d3eb5b59f2693c65024f5dc70323c5f7b3a84ecd.json new file mode 100644 index 00000000..bccaeca3 --- /dev/null +++ b/.sqlx/query-adb7610f5ac193ef0c70d0a8d3eb5b59f2693c65024f5dc70323c5f7b3a84ecd.json @@ -0,0 +1,48 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (\n SELECT *\n FROM bria_xpubs\n WHERE account_id = $1 AND fingerprint = $2) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $3 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_xpub_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Bytea", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "adb7610f5ac193ef0c70d0a8d3eb5b59f2693c65024f5dc70323c5f7b3a84ecd" +} diff --git a/.sqlx/query-52f5cc540e8fc84b86957397d59684b8049ed1342f4050e7d9a7a9f2553ba4cf.json b/.sqlx/query-ae852494e0d316dc752573af56c244561b6045c05d49299717b6f6421319d8da.json similarity index 59% rename from .sqlx/query-52f5cc540e8fc84b86957397d59684b8049ed1342f4050e7d9a7a9f2553ba4cf.json rename to .sqlx/query-ae852494e0d316dc752573af56c244561b6045c05d49299717b6f6421319d8da.json index 556f2f2a..ea914b74 100644 --- a/.sqlx/query-52f5cc540e8fc84b86957397d59684b8049ed1342f4050e7d9a7a9f2553ba4cf.json +++ b/.sqlx/query-ae852494e0d316dc752573af56c244561b6045c05d49299717b6f6421319d8da.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "INSERT INTO bria_addresses\n (id, account_id, wallet_id, keychain_id, profile_id, address, kind, external_id)\n VALUES ($1, $2, $3, $4, $5, $6, $7, $8)", + "query": "INSERT INTO bria_addresses (id, wallet_id, account_id, keychain_id, profile_id, address, kind, external_id, created_at) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, COALESCE($9, NOW()))", "describe": { "columns": [], "parameters": { @@ -22,10 +22,11 @@ } } }, - "Varchar" + "Varchar", + "Timestamptz" ] }, "nullable": [] }, - "hash": "52f5cc540e8fc84b86957397d59684b8049ed1342f4050e7d9a7a9f2553ba4cf" + "hash": "ae852494e0d316dc752573af56c244561b6045c05d49299717b6f6421319d8da" } diff --git a/.sqlx/query-af3afa78e97f2421e8ac08f644a21f602fc3983147a6121e7bd857b6f4b3196b.json b/.sqlx/query-af3afa78e97f2421e8ac08f644a21f602fc3983147a6121e7bd857b6f4b3196b.json new file mode 100644 index 00000000..afd6dd39 --- /dev/null +++ b/.sqlx/query-af3afa78e97f2421e8ac08f644a21f602fc3983147a6121e7bd857b6f4b3196b.json @@ -0,0 +1,49 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT created_at, id FROM bria_profiles WHERE (COALESCE((created_at, id) > ($3, $2), $2 IS NULL)) ORDER BY created_at ASC, id ASC LIMIT $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $4 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_profile_events e ON i.id = e.id ORDER BY i.created_at asc, i.id asc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Int8", + "Uuid", + "Timestamptz", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "af3afa78e97f2421e8ac08f644a21f602fc3983147a6121e7bd857b6f4b3196b" +} diff --git a/.sqlx/query-b096f4dfed5c2f2f95450e60d53c77389f5a2c1c9fe867561f81a6b2577cb9cd.json b/.sqlx/query-b096f4dfed5c2f2f95450e60d53c77389f5a2c1c9fe867561f81a6b2577cb9cd.json new file mode 100644 index 00000000..295df9ff --- /dev/null +++ b/.sqlx/query-b096f4dfed5c2f2f95450e60d53c77389f5a2c1c9fe867561f81a6b2577cb9cd.json @@ -0,0 +1,48 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM bria_xpubs WHERE (COALESCE(id > $2, true)) ORDER BY id ASC LIMIT $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $3 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_xpub_events e ON i.id = e.id ORDER BY i.id asc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Int8", + "Uuid", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "b096f4dfed5c2f2f95450e60d53c77389f5a2c1c9fe867561f81a6b2577cb9cd" +} diff --git a/.sqlx/query-b2456b87a130d720dc00e7d102f639208a9a3a4befb53d63dbbed098cf7f2b22.json b/.sqlx/query-b2456b87a130d720dc00e7d102f639208a9a3a4befb53d63dbbed098cf7f2b22.json new file mode 100644 index 00000000..c973d214 --- /dev/null +++ b/.sqlx/query-b2456b87a130d720dc00e7d102f639208a9a3a4befb53d63dbbed098cf7f2b22.json @@ -0,0 +1,47 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM bria_payouts WHERE id = ANY($1)) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $2 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_payout_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "UuidArray", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "b2456b87a130d720dc00e7d102f639208a9a3a4befb53d63dbbed098cf7f2b22" +} diff --git a/.sqlx/query-b2acd44a7a822541f637c19587ffe1151b1738fa6a0f8566a6509081ace0f83f.json b/.sqlx/query-b2acd44a7a822541f637c19587ffe1151b1738fa6a0f8566a6509081ace0f83f.json new file mode 100644 index 00000000..c7ab1249 --- /dev/null +++ b/.sqlx/query-b2acd44a7a822541f637c19587ffe1151b1738fa6a0f8566a6509081ace0f83f.json @@ -0,0 +1,48 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM bria_profiles WHERE (COALESCE(id < $2, true)) ORDER BY id DESC LIMIT $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $3 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_profile_events e ON i.id = e.id ORDER BY i.id desc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Int8", + "Uuid", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "b2acd44a7a822541f637c19587ffe1151b1738fa6a0f8566a6509081ace0f83f" +} diff --git a/.sqlx/query-b3e0a7791167b3a74ea4ba95f05597b8d33f3a020c7e6088d218a7094c8bc0b1.json b/.sqlx/query-b3e0a7791167b3a74ea4ba95f05597b8d33f3a020c7e6088d218a7094c8bc0b1.json new file mode 100644 index 00000000..732378b1 --- /dev/null +++ b/.sqlx/query-b3e0a7791167b3a74ea4ba95f05597b8d33f3a020c7e6088d218a7094c8bc0b1.json @@ -0,0 +1,48 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM bria_xpubs WHERE (COALESCE(id < $2, true)) ORDER BY id DESC LIMIT $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $3 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_xpub_events e ON i.id = e.id ORDER BY i.id desc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Int8", + "Uuid", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "b3e0a7791167b3a74ea4ba95f05597b8d33f3a020c7e6088d218a7094c8bc0b1" +} diff --git a/.sqlx/query-b76793d1c0e83bf77ea8502b825970fb7f1f8427ecd7ae3919c90ff031129a5c.json b/.sqlx/query-b76793d1c0e83bf77ea8502b825970fb7f1f8427ecd7ae3919c90ff031129a5c.json new file mode 100644 index 00000000..b64f5da7 --- /dev/null +++ b/.sqlx/query-b76793d1c0e83bf77ea8502b825970fb7f1f8427ecd7ae3919c90ff031129a5c.json @@ -0,0 +1,50 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (\n SELECT *\n FROM bria_signing_sessions\n WHERE account_id = $1 AND batch_id = $2\n AND (COALESCE((created_at, id) > ($4, $3), $3 IS NULL))\n ORDER BY created_at, id) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $5 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_signing_session_events e ON i.id = e.id ORDER BY i.created_at, i.id, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Uuid", + "Uuid", + "Timestamptz", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "b76793d1c0e83bf77ea8502b825970fb7f1f8427ecd7ae3919c90ff031129a5c" +} diff --git a/.sqlx/query-b76859ee4c1ac6aecb03e51acd0860e548b73560822008f3de7f85d22c610cea.json b/.sqlx/query-b76859ee4c1ac6aecb03e51acd0860e548b73560822008f3de7f85d22c610cea.json new file mode 100644 index 00000000..b2f0ce09 --- /dev/null +++ b/.sqlx/query-b76859ee4c1ac6aecb03e51acd0860e548b73560822008f3de7f85d22c610cea.json @@ -0,0 +1,47 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM bria_addresses WHERE keychain_id = $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $2 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_address_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "b76859ee4c1ac6aecb03e51acd0860e548b73560822008f3de7f85d22c610cea" +} diff --git a/.sqlx/query-b84f3323f9b4dcebc263f0970fc41b00f5f4500ffe5cb8aa5c60e6319cb93dad.json b/.sqlx/query-b84f3323f9b4dcebc263f0970fc41b00f5f4500ffe5cb8aa5c60e6319cb93dad.json new file mode 100644 index 00000000..0451d056 --- /dev/null +++ b/.sqlx/query-b84f3323f9b4dcebc263f0970fc41b00f5f4500ffe5cb8aa5c60e6319cb93dad.json @@ -0,0 +1,26 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO bria_wallet_events (id, recorded_at, sequence, event_type, event) SELECT $1, COALESCE($2, NOW()), ROW_NUMBER() OVER () + $3, unnested.event_type, unnested.event FROM UNNEST($4::TEXT[], $5::JSONB[]) AS unnested(event_type, event) RETURNING recorded_at", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Timestamptz", + "Int8", + "TextArray", + "JsonbArray" + ] + }, + "nullable": [ + false + ] + }, + "hash": "b84f3323f9b4dcebc263f0970fc41b00f5f4500ffe5cb8aa5c60e6319cb93dad" +} diff --git a/.sqlx/query-bac453e06ae1ceebef3012cf0119ec13fcc982c544b3fde38f557b264dea6e9a.json b/.sqlx/query-bac453e06ae1ceebef3012cf0119ec13fcc982c544b3fde38f557b264dea6e9a.json deleted file mode 100644 index 6926cdfe..00000000 --- a/.sqlx/query-bac453e06ae1ceebef3012cf0119ec13fcc982c544b3fde38f557b264dea6e9a.json +++ /dev/null @@ -1,77 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n SELECT b.*, e.sequence, e.event\n FROM bria_payouts b\n JOIN bria_payout_events e ON b.id = e.id\n WHERE account_id = $1 AND b.id = $2\n ORDER BY b.created_at, b.id, e.sequence", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "id", - "type_info": "Uuid" - }, - { - "ordinal": 1, - "name": "account_id", - "type_info": "Uuid" - }, - { - "ordinal": 2, - "name": "wallet_id", - "type_info": "Uuid" - }, - { - "ordinal": 3, - "name": "payout_queue_id", - "type_info": "Uuid" - }, - { - "ordinal": 4, - "name": "batch_id", - "type_info": "Uuid" - }, - { - "ordinal": 5, - "name": "profile_id", - "type_info": "Uuid" - }, - { - "ordinal": 6, - "name": "external_id", - "type_info": "Varchar" - }, - { - "ordinal": 7, - "name": "created_at", - "type_info": "Timestamptz" - }, - { - "ordinal": 8, - "name": "sequence", - "type_info": "Int4" - }, - { - "ordinal": 9, - "name": "event", - "type_info": "Jsonb" - } - ], - "parameters": { - "Left": [ - "Uuid", - "Uuid" - ] - }, - "nullable": [ - false, - false, - false, - false, - true, - false, - false, - false, - false, - false - ] - }, - "hash": "bac453e06ae1ceebef3012cf0119ec13fcc982c544b3fde38f557b264dea6e9a" -} diff --git a/.sqlx/query-bb41a1baad3437ccece94bba7774571ae7f9a953aba799e1ca60ed5285273358.json b/.sqlx/query-bb41a1baad3437ccece94bba7774571ae7f9a953aba799e1ca60ed5285273358.json new file mode 100644 index 00000000..7b8d6df7 --- /dev/null +++ b/.sqlx/query-bb41a1baad3437ccece94bba7774571ae7f9a953aba799e1ca60ed5285273358.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE bria_payouts SET batch_id = $2 WHERE id = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Uuid" + ] + }, + "nullable": [] + }, + "hash": "bb41a1baad3437ccece94bba7774571ae7f9a953aba799e1ca60ed5285273358" +} diff --git a/.sqlx/query-bc0d7ecc4cdf9c97692f98022eb4ca4ca8db761aea38aa34397767a4533e80e2.json b/.sqlx/query-bc0d7ecc4cdf9c97692f98022eb4ca4ca8db761aea38aa34397767a4533e80e2.json new file mode 100644 index 00000000..e5d62e07 --- /dev/null +++ b/.sqlx/query-bc0d7ecc4cdf9c97692f98022eb4ca4ca8db761aea38aa34397767a4533e80e2.json @@ -0,0 +1,49 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT account_id, id FROM bria_profiles WHERE ((account_id = $1) AND (COALESCE(id > $3, true))) ORDER BY id ASC LIMIT $2) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $4 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_profile_events e ON i.id = e.id ORDER BY i.id asc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Int8", + "Uuid", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "bc0d7ecc4cdf9c97692f98022eb4ca4ca8db761aea38aa34397767a4533e80e2" +} diff --git a/.sqlx/query-be18ca32819fdda44a36323ced8e6aa95532db9cf1714814e6f15bfb56ae791f.json b/.sqlx/query-be18ca32819fdda44a36323ced8e6aa95532db9cf1714814e6f15bfb56ae791f.json deleted file mode 100644 index 35f4a141..00000000 --- a/.sqlx/query-be18ca32819fdda44a36323ced8e6aa95532db9cf1714814e6f15bfb56ae791f.json +++ /dev/null @@ -1,77 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n SELECT b.*, e.sequence, e.event\n FROM bria_payouts b\n JOIN bria_payout_events e ON b.id = e.id\n WHERE account_id = $1 AND b.id = $2\n ORDER BY b.created_at, b.id, e.sequence\n FOR UPDATE", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "id", - "type_info": "Uuid" - }, - { - "ordinal": 1, - "name": "account_id", - "type_info": "Uuid" - }, - { - "ordinal": 2, - "name": "wallet_id", - "type_info": "Uuid" - }, - { - "ordinal": 3, - "name": "payout_queue_id", - "type_info": "Uuid" - }, - { - "ordinal": 4, - "name": "batch_id", - "type_info": "Uuid" - }, - { - "ordinal": 5, - "name": "profile_id", - "type_info": "Uuid" - }, - { - "ordinal": 6, - "name": "external_id", - "type_info": "Varchar" - }, - { - "ordinal": 7, - "name": "created_at", - "type_info": "Timestamptz" - }, - { - "ordinal": 8, - "name": "sequence", - "type_info": "Int4" - }, - { - "ordinal": 9, - "name": "event", - "type_info": "Jsonb" - } - ], - "parameters": { - "Left": [ - "Uuid", - "Uuid" - ] - }, - "nullable": [ - false, - false, - false, - false, - true, - false, - false, - false, - false, - false - ] - }, - "hash": "be18ca32819fdda44a36323ced8e6aa95532db9cf1714814e6f15bfb56ae791f" -} diff --git a/.sqlx/query-be83933711f722bcea5bfe413a247d5bdab8edf29399f48895ceb66f15cb1992.json b/.sqlx/query-be83933711f722bcea5bfe413a247d5bdab8edf29399f48895ceb66f15cb1992.json new file mode 100644 index 00000000..3a5c9429 --- /dev/null +++ b/.sqlx/query-be83933711f722bcea5bfe413a247d5bdab8edf29399f48895ceb66f15cb1992.json @@ -0,0 +1,48 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM bria_signing_sessions WHERE (COALESCE(id > $2, true)) ORDER BY id ASC LIMIT $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $3 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_signing_session_events e ON i.id = e.id ORDER BY i.id asc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Int8", + "Uuid", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "be83933711f722bcea5bfe413a247d5bdab8edf29399f48895ceb66f15cb1992" +} diff --git a/.sqlx/query-c5e396c1f3318661f0118b1c822a1f9efd4a735ea07c8c8188304fddded337f0.json b/.sqlx/query-c5e396c1f3318661f0118b1c822a1f9efd4a735ea07c8c8188304fddded337f0.json new file mode 100644 index 00000000..4ff45593 --- /dev/null +++ b/.sqlx/query-c5e396c1f3318661f0118b1c822a1f9efd4a735ea07c8c8188304fddded337f0.json @@ -0,0 +1,47 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM bria_addresses WHERE id = $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $2 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_address_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "c5e396c1f3318661f0118b1c822a1f9efd4a735ea07c8c8188304fddded337f0" +} diff --git a/.sqlx/query-c6f45dda03e5c4528b258803197918e2252327a5bfb302e719c426c95805b185.json b/.sqlx/query-c6f45dda03e5c4528b258803197918e2252327a5bfb302e719c426c95805b185.json new file mode 100644 index 00000000..6891f0c0 --- /dev/null +++ b/.sqlx/query-c6f45dda03e5c4528b258803197918e2252327a5bfb302e719c426c95805b185.json @@ -0,0 +1,47 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM bria_xpubs WHERE account_id = $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $2 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_xpub_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "c6f45dda03e5c4528b258803197918e2252327a5bfb302e719c426c95805b185" +} diff --git a/.sqlx/query-c7a51ac39c0f5d65b360ed9400f6827f7769e081d0f37a44a14aba4efff518ca.json b/.sqlx/query-c7a51ac39c0f5d65b360ed9400f6827f7769e081d0f37a44a14aba4efff518ca.json new file mode 100644 index 00000000..9308435b --- /dev/null +++ b/.sqlx/query-c7a51ac39c0f5d65b360ed9400f6827f7769e081d0f37a44a14aba4efff518ca.json @@ -0,0 +1,47 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM bria_xpubs WHERE id = ANY($1)) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $2 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_xpub_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "UuidArray", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "c7a51ac39c0f5d65b360ed9400f6827f7769e081d0f37a44a14aba4efff518ca" +} diff --git a/.sqlx/query-c9d627366eb3cef8fab5cf514472db4c14c5ba76fba31b88c6816f212173b568.json b/.sqlx/query-c9d627366eb3cef8fab5cf514472db4c14c5ba76fba31b88c6816f212173b568.json new file mode 100644 index 00000000..05acb427 --- /dev/null +++ b/.sqlx/query-c9d627366eb3cef8fab5cf514472db4c14c5ba76fba31b88c6816f212173b568.json @@ -0,0 +1,26 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO bria_signing_session_events (id, recorded_at, sequence, event_type, event) SELECT $1, COALESCE($2, NOW()), ROW_NUMBER() OVER () + $3, unnested.event_type, unnested.event FROM UNNEST($4::TEXT[], $5::JSONB[]) AS unnested(event_type, event) RETURNING recorded_at", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Timestamptz", + "Int8", + "TextArray", + "JsonbArray" + ] + }, + "nullable": [ + false + ] + }, + "hash": "c9d627366eb3cef8fab5cf514472db4c14c5ba76fba31b88c6816f212173b568" +} diff --git a/.sqlx/query-ccbffcf0dc4fec403b76afecafd708decb30f8c3124db79f2444a18754fe77a3.json b/.sqlx/query-ccbffcf0dc4fec403b76afecafd708decb30f8c3124db79f2444a18754fe77a3.json deleted file mode 100644 index 115da513..00000000 --- a/.sqlx/query-ccbffcf0dc4fec403b76afecafd708decb30f8c3124db79f2444a18754fe77a3.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n SELECT b.*, e.sequence, e.event\n FROM bria_wallets b\n JOIN bria_wallet_events e ON b.id = e.id\n WHERE account_id = $1\n ORDER BY e.sequence", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "id", - "type_info": "Uuid" - }, - { - "ordinal": 1, - "name": "account_id", - "type_info": "Uuid" - }, - { - "ordinal": 2, - "name": "name", - "type_info": "Varchar" - }, - { - "ordinal": 3, - "name": "created_at", - "type_info": "Timestamptz" - }, - { - "ordinal": 4, - "name": "sequence", - "type_info": "Int4" - }, - { - "ordinal": 5, - "name": "event", - "type_info": "Jsonb" - } - ], - "parameters": { - "Left": [ - "Uuid" - ] - }, - "nullable": [ - false, - false, - false, - false, - false, - false - ] - }, - "hash": "ccbffcf0dc4fec403b76afecafd708decb30f8c3124db79f2444a18754fe77a3" -} diff --git a/.sqlx/query-cceef64b1a4d7d1102d916a5c9654d7af96faf5adddceed9e5844c823ddf83c2.json b/.sqlx/query-cceef64b1a4d7d1102d916a5c9654d7af96faf5adddceed9e5844c823ddf83c2.json deleted file mode 100644 index 02c317d1..00000000 --- a/.sqlx/query-cceef64b1a4d7d1102d916a5c9654d7af96faf5adddceed9e5844c823ddf83c2.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "SELECT count(*) FROM bria_profile_events", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "count", - "type_info": "Int8" - } - ], - "parameters": { - "Left": [] - }, - "nullable": [ - null - ] - }, - "hash": "cceef64b1a4d7d1102d916a5c9654d7af96faf5adddceed9e5844c823ddf83c2" -} diff --git a/.sqlx/query-cdf731397d32cea6dbd5a9599580ed820b65a67dc90f91ef92ce9bba2a6d321a.json b/.sqlx/query-cdf731397d32cea6dbd5a9599580ed820b65a67dc90f91ef92ce9bba2a6d321a.json deleted file mode 100644 index 8664cb69..00000000 --- a/.sqlx/query-cdf731397d32cea6dbd5a9599580ed820b65a67dc90f91ef92ce9bba2a6d321a.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "SELECT p.id, e.sequence, e.event_type, e.event\n FROM bria_profiles p\n JOIN bria_profile_events e ON p.id = e.id\n WHERE p.account_id = $1\n ORDER BY p.id, sequence", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "id", - "type_info": "Uuid" - }, - { - "ordinal": 1, - "name": "sequence", - "type_info": "Int4" - }, - { - "ordinal": 2, - "name": "event_type", - "type_info": "Varchar" - }, - { - "ordinal": 3, - "name": "event", - "type_info": "Jsonb" - } - ], - "parameters": { - "Left": [ - "Uuid" - ] - }, - "nullable": [ - false, - false, - false, - false - ] - }, - "hash": "cdf731397d32cea6dbd5a9599580ed820b65a67dc90f91ef92ce9bba2a6d321a" -} diff --git a/.sqlx/query-ce970302baac6e8c40bc86cb76f6f108c86636b29d82e6dd378a8a3943d27c00.json b/.sqlx/query-ce970302baac6e8c40bc86cb76f6f108c86636b29d82e6dd378a8a3943d27c00.json new file mode 100644 index 00000000..3d48342b --- /dev/null +++ b/.sqlx/query-ce970302baac6e8c40bc86cb76f6f108c86636b29d82e6dd378a8a3943d27c00.json @@ -0,0 +1,48 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM bria_payouts WHERE (COALESCE(id < $2, true)) ORDER BY id DESC LIMIT $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $3 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_payout_events e ON i.id = e.id ORDER BY i.id desc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Int8", + "Uuid", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "ce970302baac6e8c40bc86cb76f6f108c86636b29d82e6dd378a8a3943d27c00" +} diff --git a/.sqlx/query-d3e778df5c710e4a574d4370e9220c1e80629cae9b09138a36e773fbab222af9.json b/.sqlx/query-d3e778df5c710e4a574d4370e9220c1e80629cae9b09138a36e773fbab222af9.json new file mode 100644 index 00000000..a9754aba --- /dev/null +++ b/.sqlx/query-d3e778df5c710e4a574d4370e9220c1e80629cae9b09138a36e773fbab222af9.json @@ -0,0 +1,48 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (\n SELECT *\n FROM bria_wallets\n WHERE account_id = $1 and name = $2) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $3 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_wallet_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "d3e778df5c710e4a574d4370e9220c1e80629cae9b09138a36e773fbab222af9" +} diff --git a/.sqlx/query-d423fc9d8f7296e2278cd7f32b5f8775140e69530c135335ff2b5e75f2a5bb6c.json b/.sqlx/query-d423fc9d8f7296e2278cd7f32b5f8775140e69530c135335ff2b5e75f2a5bb6c.json deleted file mode 100644 index 43382c71..00000000 --- a/.sqlx/query-d423fc9d8f7296e2278cd7f32b5f8775140e69530c135335ff2b5e75f2a5bb6c.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "INSERT INTO bria_profiles (id, account_id, name)\n VALUES ($1, $2, $3)", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Uuid", - "Uuid", - "Varchar" - ] - }, - "nullable": [] - }, - "hash": "d423fc9d8f7296e2278cd7f32b5f8775140e69530c135335ff2b5e75f2a5bb6c" -} diff --git a/.sqlx/query-d496cf25d1cda0b828a38d5cadb5e4147862a381e5a4a665d89ff939ed3202e8.json b/.sqlx/query-d496cf25d1cda0b828a38d5cadb5e4147862a381e5a4a665d89ff939ed3202e8.json new file mode 100644 index 00000000..c4a3d23b --- /dev/null +++ b/.sqlx/query-d496cf25d1cda0b828a38d5cadb5e4147862a381e5a4a665d89ff939ed3202e8.json @@ -0,0 +1,49 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT account_id, id FROM bria_wallets WHERE ((account_id = $1) AND (COALESCE(id < $3, true))) ORDER BY id DESC LIMIT $2) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $4 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_wallet_events e ON i.id = e.id ORDER BY i.id desc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Int8", + "Uuid", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "d496cf25d1cda0b828a38d5cadb5e4147862a381e5a4a665d89ff939ed3202e8" +} diff --git a/.sqlx/query-df78a011d9504ba44689ab1b5a065f98e396df5c8784ec265f14f39ecdbf8878.json b/.sqlx/query-df78a011d9504ba44689ab1b5a065f98e396df5c8784ec265f14f39ecdbf8878.json new file mode 100644 index 00000000..bc07a869 --- /dev/null +++ b/.sqlx/query-df78a011d9504ba44689ab1b5a065f98e396df5c8784ec265f14f39ecdbf8878.json @@ -0,0 +1,26 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO bria_payout_events (id, recorded_at, sequence, event_type, event) SELECT $1, COALESCE($2, NOW()), ROW_NUMBER() OVER () + $3, unnested.event_type, unnested.event FROM UNNEST($4::TEXT[], $5::JSONB[]) AS unnested(event_type, event) RETURNING recorded_at", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Timestamptz", + "Int8", + "TextArray", + "JsonbArray" + ] + }, + "nullable": [ + false + ] + }, + "hash": "df78a011d9504ba44689ab1b5a065f98e396df5c8784ec265f14f39ecdbf8878" +} diff --git a/.sqlx/query-e242e2e88ddc0e8ed38a845bb5e2e3c63f1ac297e60827a133507ab83a3d864f.json b/.sqlx/query-e242e2e88ddc0e8ed38a845bb5e2e3c63f1ac297e60827a133507ab83a3d864f.json new file mode 100644 index 00000000..272288b5 --- /dev/null +++ b/.sqlx/query-e242e2e88ddc0e8ed38a845bb5e2e3c63f1ac297e60827a133507ab83a3d864f.json @@ -0,0 +1,47 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM bria_payouts WHERE external_id = $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $2 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_payout_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Text", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "e242e2e88ddc0e8ed38a845bb5e2e3c63f1ac297e60827a133507ab83a3d864f" +} diff --git a/.sqlx/query-e2d3033999e9a08a6be9fa533c48bf96d4df8f3b2143e2f85e2f9997e07b9680.json b/.sqlx/query-e2d3033999e9a08a6be9fa533c48bf96d4df8f3b2143e2f85e2f9997e07b9680.json deleted file mode 100644 index d65aee40..00000000 --- a/.sqlx/query-e2d3033999e9a08a6be9fa533c48bf96d4df8f3b2143e2f85e2f9997e07b9680.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "SELECT id, account_id, name FROM bria_profiles", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "id", - "type_info": "Uuid" - }, - { - "ordinal": 1, - "name": "account_id", - "type_info": "Uuid" - }, - { - "ordinal": 2, - "name": "name", - "type_info": "Varchar" - } - ], - "parameters": { - "Left": [] - }, - "nullable": [ - false, - false, - false - ] - }, - "hash": "e2d3033999e9a08a6be9fa533c48bf96d4df8f3b2143e2f85e2f9997e07b9680" -} diff --git a/.sqlx/query-e6123fc759e994b430db0a55d0e4440e35ceeac30413886efd8cba47dbf73bf3.json b/.sqlx/query-e6123fc759e994b430db0a55d0e4440e35ceeac30413886efd8cba47dbf73bf3.json new file mode 100644 index 00000000..353acc96 --- /dev/null +++ b/.sqlx/query-e6123fc759e994b430db0a55d0e4440e35ceeac30413886efd8cba47dbf73bf3.json @@ -0,0 +1,48 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (\n SELECT *\n FROM bria_profiles\n WHERE account_id = $1 and name = $2) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $3 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_profile_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "e6123fc759e994b430db0a55d0e4440e35ceeac30413886efd8cba47dbf73bf3" +} diff --git a/.sqlx/query-e798350f5e65e7d3bc35bcaf2bf2d3b4d4ac0fe166f303ea904a1ae4167ecc26.json b/.sqlx/query-e798350f5e65e7d3bc35bcaf2bf2d3b4d4ac0fe166f303ea904a1ae4167ecc26.json new file mode 100644 index 00000000..60f6a34b --- /dev/null +++ b/.sqlx/query-e798350f5e65e7d3bc35bcaf2bf2d3b4d4ac0fe166f303ea904a1ae4167ecc26.json @@ -0,0 +1,47 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM bria_profiles WHERE id = $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $2 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_profile_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "e798350f5e65e7d3bc35bcaf2bf2d3b4d4ac0fe166f303ea904a1ae4167ecc26" +} diff --git a/.sqlx/query-e79c15d7aa0bedfa0d09031c882c500caacf0b694f71c5748702668d76ec0e6e.json b/.sqlx/query-e79c15d7aa0bedfa0d09031c882c500caacf0b694f71c5748702668d76ec0e6e.json new file mode 100644 index 00000000..c686ff05 --- /dev/null +++ b/.sqlx/query-e79c15d7aa0bedfa0d09031c882c500caacf0b694f71c5748702668d76ec0e6e.json @@ -0,0 +1,47 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM bria_signing_sessions WHERE id = $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $2 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_signing_session_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "e79c15d7aa0bedfa0d09031c882c500caacf0b694f71c5748702668d76ec0e6e" +} diff --git a/.sqlx/query-e8b1a7a0220a8539bcdcc790f092bf7c16227b5ad43c60ebc90c1d84d47d8218.json b/.sqlx/query-e8b1a7a0220a8539bcdcc790f092bf7c16227b5ad43c60ebc90c1d84d47d8218.json new file mode 100644 index 00000000..38ec6ce9 --- /dev/null +++ b/.sqlx/query-e8b1a7a0220a8539bcdcc790f092bf7c16227b5ad43c60ebc90c1d84d47d8218.json @@ -0,0 +1,49 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT account_id, id FROM bria_xpubs WHERE ((account_id = $1) AND (COALESCE(id > $3, true))) ORDER BY id ASC LIMIT $2) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $4 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_xpub_events e ON i.id = e.id ORDER BY i.id asc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Int8", + "Uuid", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "e8b1a7a0220a8539bcdcc790f092bf7c16227b5ad43c60ebc90c1d84d47d8218" +} diff --git a/.sqlx/query-ed1bcc219902cc44f65aca4faa73243ea4eabbc9ec72f57c9b312f93864f9f6e.json b/.sqlx/query-ed1bcc219902cc44f65aca4faa73243ea4eabbc9ec72f57c9b312f93864f9f6e.json new file mode 100644 index 00000000..a26dbbb9 --- /dev/null +++ b/.sqlx/query-ed1bcc219902cc44f65aca4faa73243ea4eabbc9ec72f57c9b312f93864f9f6e.json @@ -0,0 +1,48 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (\n SELECT *\n FROM bria_payout_queues\n WHERE account_id = $1 and name = $2) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $3 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_payout_queue_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "ed1bcc219902cc44f65aca4faa73243ea4eabbc9ec72f57c9b312f93864f9f6e" +} diff --git a/.sqlx/query-f17ac54fd1f2c48007492d8b12471e21daf1b9f0057be6f197a2654b90bb6b5e.json b/.sqlx/query-f17ac54fd1f2c48007492d8b12471e21daf1b9f0057be6f197a2654b90bb6b5e.json new file mode 100644 index 00000000..5de1dc5a --- /dev/null +++ b/.sqlx/query-f17ac54fd1f2c48007492d8b12471e21daf1b9f0057be6f197a2654b90bb6b5e.json @@ -0,0 +1,49 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT created_at, id FROM bria_xpubs WHERE (COALESCE((created_at, id) > ($3, $2), $2 IS NULL)) ORDER BY created_at ASC, id ASC LIMIT $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $4 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_xpub_events e ON i.id = e.id ORDER BY i.created_at asc, i.id asc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Int8", + "Uuid", + "Timestamptz", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "f17ac54fd1f2c48007492d8b12471e21daf1b9f0057be6f197a2654b90bb6b5e" +} diff --git a/.sqlx/query-f4c6df4bfca4287add9b9f19df9d2555cc6a3917021892dd7a32652d0fa3637d.json b/.sqlx/query-f4c6df4bfca4287add9b9f19df9d2555cc6a3917021892dd7a32652d0fa3637d.json deleted file mode 100644 index 76fc3e00..00000000 --- a/.sqlx/query-f4c6df4bfca4287add9b9f19df9d2555cc6a3917021892dd7a32652d0fa3637d.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n SELECT b.id, e.sequence, e.event\n FROM bria_addresses b\n JOIN bria_address_events e ON b.id = e.id\n WHERE account_id = $1 AND wallet_id = $2 AND kind = 'external'\n ORDER BY b.created_at, b.id, sequence", - "describe": { - "columns": [ - { - "ordinal": 0, - "name": "id", - "type_info": "Uuid" - }, - { - "ordinal": 1, - "name": "sequence", - "type_info": "Int4" - }, - { - "ordinal": 2, - "name": "event", - "type_info": "Jsonb" - } - ], - "parameters": { - "Left": [ - "Uuid", - "Uuid" - ] - }, - "nullable": [ - false, - false, - false - ] - }, - "hash": "f4c6df4bfca4287add9b9f19df9d2555cc6a3917021892dd7a32652d0fa3637d" -} diff --git a/.sqlx/query-f52220882898fd73d3aa6448a4927018785b3968859146cdf0352ee2f4c3efea.json b/.sqlx/query-f52220882898fd73d3aa6448a4927018785b3968859146cdf0352ee2f4c3efea.json new file mode 100644 index 00000000..ea6c35b5 --- /dev/null +++ b/.sqlx/query-f52220882898fd73d3aa6448a4927018785b3968859146cdf0352ee2f4c3efea.json @@ -0,0 +1,15 @@ +{ + "db_name": "PostgreSQL", + "query": "UPDATE bria_addresses SET external_id = $2 WHERE id = $1", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Varchar" + ] + }, + "nullable": [] + }, + "hash": "f52220882898fd73d3aa6448a4927018785b3968859146cdf0352ee2f4c3efea" +} diff --git a/.sqlx/query-f5faad8826ac896171feab735386c36acff3c8b20d9ef193e3c6d882d9cdf8e0.json b/.sqlx/query-f5faad8826ac896171feab735386c36acff3c8b20d9ef193e3c6d882d9cdf8e0.json new file mode 100644 index 00000000..0e1c140d --- /dev/null +++ b/.sqlx/query-f5faad8826ac896171feab735386c36acff3c8b20d9ef193e3c6d882d9cdf8e0.json @@ -0,0 +1,47 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM bria_wallets WHERE id = ANY($1)) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $2 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_wallet_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "UuidArray", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "f5faad8826ac896171feab735386c36acff3c8b20d9ef193e3c6d882d9cdf8e0" +} diff --git a/.sqlx/query-f8335c1c83acfb90bdcafe951727867f5f0b7da9571bd124597311d8d58e09cc.json b/.sqlx/query-f8335c1c83acfb90bdcafe951727867f5f0b7da9571bd124597311d8d58e09cc.json new file mode 100644 index 00000000..ebb6b883 --- /dev/null +++ b/.sqlx/query-f8335c1c83acfb90bdcafe951727867f5f0b7da9571bd124597311d8d58e09cc.json @@ -0,0 +1,47 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT id FROM bria_xpubs WHERE name = $1) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $2 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_xpub_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Text", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "f8335c1c83acfb90bdcafe951727867f5f0b7da9571bd124597311d8d58e09cc" +} diff --git a/.sqlx/query-f969a21220e0d0a16b91b9b8038a683989c95c6c87d45762aca3515e2961f954.json b/.sqlx/query-f969a21220e0d0a16b91b9b8038a683989c95c6c87d45762aca3515e2961f954.json new file mode 100644 index 00000000..5fcb647d --- /dev/null +++ b/.sqlx/query-f969a21220e0d0a16b91b9b8038a683989c95c6c87d45762aca3515e2961f954.json @@ -0,0 +1,50 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT account_id, created_at, id FROM bria_payout_queues WHERE ((account_id = $1) AND (COALESCE((created_at, id) > ($4, $3), $3 IS NULL))) ORDER BY created_at ASC, id ASC LIMIT $2) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $5 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_payout_queue_events e ON i.id = e.id ORDER BY i.created_at asc, i.id asc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Int8", + "Uuid", + "Timestamptz", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "f969a21220e0d0a16b91b9b8038a683989c95c6c87d45762aca3515e2961f954" +} diff --git a/.sqlx/query-fa20681958de2a9b7764665edde5dbc0f5f839a0ea33b48dfdc2214966dd8efa.json b/.sqlx/query-fa20681958de2a9b7764665edde5dbc0f5f839a0ea33b48dfdc2214966dd8efa.json deleted file mode 100644 index 1dca32c1..00000000 --- a/.sqlx/query-fa20681958de2a9b7764665edde5dbc0f5f839a0ea33b48dfdc2214966dd8efa.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n INSERT INTO bria_payout_queues (id, account_id, name)\n VALUES ($1, $2, $3)\n ", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Uuid", - "Uuid", - "Varchar" - ] - }, - "nullable": [] - }, - "hash": "fa20681958de2a9b7764665edde5dbc0f5f839a0ea33b48dfdc2214966dd8efa" -} diff --git a/.sqlx/query-fc287215a78fd84cd9c251d99c34816dda6607c8d306f9dfddcda69756561a3c.json b/.sqlx/query-fc287215a78fd84cd9c251d99c34816dda6607c8d306f9dfddcda69756561a3c.json new file mode 100644 index 00000000..fbf5abed --- /dev/null +++ b/.sqlx/query-fc287215a78fd84cd9c251d99c34816dda6607c8d306f9dfddcda69756561a3c.json @@ -0,0 +1,50 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (SELECT account_id, created_at, id FROM bria_wallets WHERE ((account_id = $1) AND (COALESCE((created_at, id) < ($4, $3), $3 IS NULL))) ORDER BY created_at DESC, id DESC LIMIT $2) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $5 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_wallet_events e ON i.id = e.id ORDER BY i.created_at desc, i.id desc, i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Int8", + "Uuid", + "Timestamptz", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "fc287215a78fd84cd9c251d99c34816dda6607c8d306f9dfddcda69756561a3c" +} diff --git a/.sqlx/query-fc739d082a692121896a3df20aa6ea59f9ad7dfb7daefe8c9ee3c57616f8e411.json b/.sqlx/query-fc739d082a692121896a3df20aa6ea59f9ad7dfb7daefe8c9ee3c57616f8e411.json new file mode 100644 index 00000000..a88670e9 --- /dev/null +++ b/.sqlx/query-fc739d082a692121896a3df20aa6ea59f9ad7dfb7daefe8c9ee3c57616f8e411.json @@ -0,0 +1,26 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO bria_xpub_events (id, recorded_at, sequence, event_type, event) SELECT $1, COALESCE($2, NOW()), ROW_NUMBER() OVER () + $3, unnested.event_type, unnested.event FROM UNNEST($4::TEXT[], $5::JSONB[]) AS unnested(event_type, event) RETURNING recorded_at", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Timestamptz", + "Int8", + "TextArray", + "JsonbArray" + ] + }, + "nullable": [ + false + ] + }, + "hash": "fc739d082a692121896a3df20aa6ea59f9ad7dfb7daefe8c9ee3c57616f8e411" +} diff --git a/.sqlx/query-fdda9164b8cebcca5c74f339d8ba71921ebe2149abb550bf8b00d2018c02c820.json b/.sqlx/query-fdda9164b8cebcca5c74f339d8ba71921ebe2149abb550bf8b00d2018c02c820.json new file mode 100644 index 00000000..e545f14a --- /dev/null +++ b/.sqlx/query-fdda9164b8cebcca5c74f339d8ba71921ebe2149abb550bf8b00d2018c02c820.json @@ -0,0 +1,48 @@ +{ + "db_name": "PostgreSQL", + "query": "WITH entities AS (\n SELECT *\n FROM bria_payouts \n WHERE account_id = $1 AND external_id = $2) SELECT i.id AS \"entity_id: Repo__Id\", e.sequence, e.event, CASE WHEN $3 THEN e.context ELSE NULL::jsonb END as \"context: es_entity::ContextData\", e.recorded_at FROM entities i JOIN bria_payout_events e ON i.id = e.id ORDER BY i.id, e.sequence", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "entity_id: Repo__Id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "sequence", + "type_info": "Int4" + }, + { + "ordinal": 2, + "name": "event", + "type_info": "Jsonb" + }, + { + "ordinal": 3, + "name": "context: es_entity::ContextData", + "type_info": "Jsonb" + }, + { + "ordinal": 4, + "name": "recorded_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": [ + "Uuid", + "Text", + "Bool" + ] + }, + "nullable": [ + false, + false, + false, + null, + false + ] + }, + "hash": "fdda9164b8cebcca5c74f339d8ba71921ebe2149abb550bf8b00d2018c02c820" +} diff --git a/.sqlx/query-fe3f391ef20bab7af3fd3c5559d500932f5b281df15f6984a9773061a967cb29.json b/.sqlx/query-fe3f391ef20bab7af3fd3c5559d500932f5b281df15f6984a9773061a967cb29.json new file mode 100644 index 00000000..9775111e --- /dev/null +++ b/.sqlx/query-fe3f391ef20bab7af3fd3c5559d500932f5b281df15f6984a9773061a967cb29.json @@ -0,0 +1,17 @@ +{ + "db_name": "PostgreSQL", + "query": "INSERT INTO bria_payout_queues (id, name, account_id, created_at) VALUES ($1, $2, $3, COALESCE($4, NOW()))", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Varchar", + "Uuid", + "Timestamptz" + ] + }, + "nullable": [] + }, + "hash": "fe3f391ef20bab7af3fd3c5559d500932f5b281df15f6984a9773061a967cb29" +} diff --git a/Cargo.lock b/Cargo.lock index c7d9b24a..6f16b1c0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -18,7 +18,7 @@ version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" dependencies = [ - "getrandom 0.2.16", + "getrandom 0.2.17", "once_cell", "version_check", ] @@ -111,9 +111,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.100" +version = "1.0.102" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61" +checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" [[package]] name = "anymap2" @@ -155,7 +155,7 @@ checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.117", ] [[package]] @@ -166,7 +166,7 @@ checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.117", ] [[package]] @@ -237,7 +237,7 @@ dependencies = [ "axum-core 0.4.5", "bytes", "futures-util", - "http 1.3.1", + "http 1.4.0", "http-body 1.0.1", "http-body-util", "itoa", @@ -249,7 +249,7 @@ dependencies = [ "rustversion", "serde", "sync_wrapper 1.0.2", - "tower 0.5.2", + "tower 0.5.3", "tower-layer", "tower-service", ] @@ -280,7 +280,7 @@ dependencies = [ "async-trait", "bytes", "futures-util", - "http 1.3.1", + "http 1.4.0", "http-body 1.0.1", "http-body-util", "mime", @@ -311,9 +311,9 @@ checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "base64ct" -version = "1.8.0" +version = "1.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55248b47b0caf0546f7988906588779981c43bb1bc9d0c44087278f80cdb44ba" +checksum = "2af50177e190e07a26ab74f8b1efbfe2ef87da2116221318cb1c2e82baf7de06" [[package]] name = "bdk" @@ -325,7 +325,7 @@ dependencies = [ "bdk-macros", "bitcoin", "electrum-client", - "getrandom 0.2.16", + "getrandom 0.2.17", "js-sys", "log", "miniscript", @@ -433,13 +433,22 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.10.0" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3" +checksum = "843867be96c8daad0d758b57df9392b6d8d271134fce549de6ce169ff98a92af" dependencies = [ "serde_core", ] +[[package]] +name = "bitmaps" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "031043d04099746d8db04daf1fa424b2bc8bd69d92b25962dcde24da39ab64a2" +dependencies = [ + "typenum", +] + [[package]] name = "bitvec" version = "1.0.1" @@ -463,9 +472,9 @@ dependencies = [ [[package]] name = "borsh" -version = "1.5.7" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad8646f98db542e39fc66e68a20b2144f6a732636df7c2354e74645faaa433ce" +checksum = "d1da5ab77c1437701eeff7c88d968729e7766172279eab0676857b3d63af7a6f" dependencies = [ "borsh-derive", "cfg_aliases", @@ -473,15 +482,15 @@ dependencies = [ [[package]] name = "borsh-derive" -version = "1.5.7" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdd1d3c0c2f5833f22386f252fe8ed005c7f59fdcddeef025c01b4c3b9fd9ac3" +checksum = "0686c856aa6aac0c4498f936d7d6a02df690f614c03e4d906d1018062b5c5e2c" dependencies = [ "once_cell", "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.117", ] [[package]] @@ -498,6 +507,7 @@ dependencies = [ "clap", "derive_builder", "electrum-client", + "es-entity", "fedimint-tonic-lnd", "futures", "hex", @@ -540,9 +550,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.19.0" +version = "3.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43" +checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb" [[package]] name = "bytecheck" @@ -605,7 +615,7 @@ dependencies = [ "darling 0.20.11", "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.117", ] [[package]] @@ -616,9 +626,9 @@ checksum = "ade8366b8bd5ba243f0a58f036cc0ca8a2f069cff1a2351ef1cac6b083e16fc0" [[package]] name = "cc" -version = "1.2.46" +version = "1.2.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97463e1064cb1b1c1384ad0a0b9c8abd0988e2a91f52606c80ef14aadb63e36" +checksum = "aebf35691d1bfb0ac386a69bac2fde4dd276fb618cf8bf4f5318fe285e821bb2" dependencies = [ "find-msvc-tools", "shlex", @@ -662,9 +672,9 @@ dependencies = [ [[package]] name = "chrono" -version = "0.4.42" +version = "0.4.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "145052bdd345b87320e369255277e3fb5152762ad123a901ef5c262dd38fe8d2" +checksum = "c673075a2e0e5f4a1dde27ce9dee1ea4558c7ffe648f576438a20ca1d2acc4b0" dependencies = [ "iana-time-zone", "js-sys", @@ -687,9 +697,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.52" +version = "4.5.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa8120877db0e5c011242f96806ce3c94e0737ab8108532a76a3300a01db2ab8" +checksum = "2797f34da339ce31042b27d23607e051786132987f595b02ba4f6a6dffb7030a" dependencies = [ "clap_builder", "clap_derive", @@ -697,9 +707,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.52" +version = "4.5.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02576b399397b659c26064fbc92a75fede9d18ffd5f80ca1cd74ddab167016e1" +checksum = "24a241312cea5059b13574bb9b3861cabf758b879c15190b37b6d6fd63ab6876" dependencies = [ "anstream", "anstyle", @@ -709,21 +719,21 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.49" +version = "4.5.55" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a0b5487afeab2deb2ff4e03a807ad1a03ac532ff5a2cee5d86884440c7f7671" +checksum = "a92793da1a46a5f2a02a6f4c46c6496b28c43638adea8306fcb0caa1634f24e5" dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.117", ] [[package]] name = "clap_lex" -version = "0.7.6" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d" +checksum = "3a822ea5bc7590f9d40f1ba12c0dc3c2760f3482c6984db1573ad11031420831" [[package]] name = "colorchoice" @@ -746,6 +756,15 @@ version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" +[[package]] +name = "convert_case" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baaaa0ecca5b51987b9423ccdc971514dd8b0bb7b4060b983d3664dad3f1f89f" +dependencies = [ + "unicode-segmentation", +] + [[package]] name = "core-foundation-sys" version = "0.8.7" @@ -763,9 +782,9 @@ dependencies = [ [[package]] name = "crc" -version = "3.3.0" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9710d3b3739c2e349eb44fe848ad0b7c8cb1e42bd87ee49371df2f7acaf3e675" +checksum = "5eb8a2a1cd12ab0d987a5d5e825195d372001a4094a0376319d5a0ad71c1ba0d" dependencies = [ "crc-catalog", ] @@ -851,7 +870,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.110", + "syn 2.0.117", ] [[package]] @@ -865,7 +884,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.110", + "syn 2.0.117", ] [[package]] @@ -876,7 +895,7 @@ checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" dependencies = [ "darling_core 0.20.11", "quote", - "syn 2.0.110", + "syn 2.0.117", ] [[package]] @@ -887,7 +906,7 @@ checksum = "d38308df82d1080de0afee5d069fa14b0326a88c14f15c5ccda35b4a6c414c81" dependencies = [ "darling_core 0.21.3", "quote", - "syn 2.0.110", + "syn 2.0.117", ] [[package]] @@ -903,9 +922,9 @@ dependencies = [ [[package]] name = "deranged" -version = "0.5.5" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ececcb659e7ba858fb4f10388c250a7252eb0a27373f1a72b8748afdd248e587" +checksum = "7cd812cc2bc1d69d4764bd80df88b4317eaef9e773c75226407d9bc0876b211c" dependencies = [ "powerfmt", "serde_core", @@ -929,7 +948,7 @@ dependencies = [ "darling 0.20.11", "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.117", ] [[package]] @@ -939,7 +958,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" dependencies = [ "derive_builder_core", - "syn 2.0.110", + "syn 2.0.117", ] [[package]] @@ -962,7 +981,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.117", ] [[package]] @@ -1013,9 +1032,9 @@ dependencies = [ [[package]] name = "ena" -version = "0.14.3" +version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d248bdd43ce613d87415282f69b9bb99d947d290b10962dd6c56233312c2ad5" +checksum = "eabffdaee24bd1bf95c5ef7cec31260444317e72ea56c4c91750e8b7ee58d5f1" dependencies = [ "log", ] @@ -1028,9 +1047,9 @@ checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] name = "erased-serde" -version = "0.4.9" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89e8918065695684b2b0702da20382d5ae6065cf3327bc2d6436bd49a71ce9f3" +checksum = "d2add8a07dd6a8d93ff627029c51de145e12686fbc36ecb298ac22e74cf02dec" dependencies = [ "serde", "serde_core", @@ -1047,6 +1066,39 @@ dependencies = [ "windows-sys 0.61.2", ] +[[package]] +name = "es-entity" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a9b69f9008c88168f4200e4b53a5a24030ca263cc26e1b035e0002b5002e971" +dependencies = [ + "chrono", + "derive_builder", + "es-entity-macros", + "im", + "pin-project", + "serde", + "serde_json", + "sqlx", + "thiserror 2.0.18", + "uuid", +] + +[[package]] +name = "es-entity-macros" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e360d04783bba4161e1d11040bdad40f4cfd4c3caf7129b50a2b5b5faa0afbf" +dependencies = [ + "convert_case", + "darling 0.21.3", + "pluralizer", + "proc-macro2", + "quote", + "regex", + "syn 2.0.117", +] + [[package]] name = "etcetera" version = "0.8.0" @@ -1097,9 +1149,9 @@ dependencies = [ [[package]] name = "find-msvc-tools" -version = "0.1.5" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a3076410a55c90011c298b04d0cfa770b00fa04e1e3c97d3f6c9de105a03844" +checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" [[package]] name = "fixedbitset" @@ -1130,6 +1182,12 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" + [[package]] name = "form_urlencoded" version = "1.2.2" @@ -1157,9 +1215,9 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "futures" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" +checksum = "8b147ee9d1f6d097cef9ce628cd2ee62288d963e16fb287bd9286455b241382d" dependencies = [ "futures-channel", "futures-core", @@ -1172,9 +1230,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" +checksum = "07bbe89c50d7a535e539b8c17bc0b49bdb77747034daa8087407d655f3f7cc1d" dependencies = [ "futures-core", "futures-sink", @@ -1182,15 +1240,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" +checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d" [[package]] name = "futures-executor" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" +checksum = "baf29c38818342a3b26b5b923639e7b1f4a61fc5e76102d4b1981c6dc7a7579d" dependencies = [ "futures-core", "futures-task", @@ -1210,38 +1268,38 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" +checksum = "cecba35d7ad927e23624b22ad55235f2239cfa44fd10428eecbeba6d6a717718" [[package]] name = "futures-macro" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" +checksum = "e835b70203e41293343137df5c0664546da5745f82ec9b84d40be8336958447b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.117", ] [[package]] name = "futures-sink" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" +checksum = "c39754e157331b013978ec91992bde1ac089843443c49cbc7f46150b0fad0893" [[package]] name = "futures-task" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" +checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393" [[package]] name = "futures-util" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" +checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6" dependencies = [ "futures-channel", "futures-core", @@ -1251,7 +1309,6 @@ dependencies = [ "futures-task", "memchr", "pin-project-lite", - "pin-utils", "slab", ] @@ -1276,9 +1333,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" dependencies = [ "cfg-if", "js-sys", @@ -1296,11 +1353,24 @@ dependencies = [ "cfg-if", "js-sys", "libc", - "r-efi", + "r-efi 5.3.0", "wasip2", "wasm-bindgen", ] +[[package]] +name = "getrandom" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0de51e6874e94e7bf76d726fc5d13ba782deca734ff60d5bb2fb2607c7406555" +dependencies = [ + "cfg-if", + "libc", + "r-efi 6.0.0", + "wasip2", + "wasip3", +] + [[package]] name = "glob" version = "0.3.3" @@ -1319,7 +1389,7 @@ dependencies = [ "futures-sink", "futures-util", "http 0.2.12", - "indexmap 2.12.0", + "indexmap 2.13.0", "slab", "tokio", "tokio-util", @@ -1328,17 +1398,17 @@ dependencies = [ [[package]] name = "h2" -version = "0.4.12" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3c0b69cfcb4e1b9f1bf2f53f95f766e4661169728ec61cd3fe5a0166f2d1386" +checksum = "2f44da3a8150a6703ed5d34e164b875fd14c2cdab9af1252a9a1020bde2bdc54" dependencies = [ "atomic-waker", "bytes", "fnv", "futures-core", "futures-sink", - "http 1.3.1", - "indexmap 2.12.0", + "http 1.4.0", + "indexmap 2.13.0", "slab", "tokio", "tokio-util", @@ -1366,9 +1436,18 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.16.0" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +dependencies = [ + "foldhash", +] + +[[package]] +name = "hashbrown" +version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" [[package]] name = "hashlink" @@ -1437,12 +1516,11 @@ dependencies = [ [[package]] name = "http" -version = "1.3.1" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4a85d31aea989eead29a3aaf9e1115a180df8282431156e533de47660892565" +checksum = "e3ba2a386d7f85a81f119ad7498ebe444d2e22c2af0b86b069416ace48b3311a" dependencies = [ "bytes", - "fnv", "itoa", ] @@ -1464,7 +1542,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" dependencies = [ "bytes", - "http 1.3.1", + "http 1.4.0", ] [[package]] @@ -1475,7 +1553,7 @@ checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a" dependencies = [ "bytes", "futures-core", - "http 1.3.1", + "http 1.4.0", "http-body 1.0.1", "pin-project-lite", ] @@ -1526,8 +1604,8 @@ dependencies = [ "bytes", "futures-channel", "futures-core", - "h2 0.4.12", - "http 1.3.1", + "h2 0.4.13", + "http 1.4.0", "http-body 1.0.1", "httparse", "httpdate", @@ -1559,15 +1637,15 @@ version = "0.27.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3c93eb611681b207e1fe55d5a71ecf91572ec8a6705cdb6857f7d8d5242cf58" dependencies = [ - "http 1.3.1", + "http 1.4.0", "hyper 1.8.1", "hyper-util", - "rustls 0.23.35", + "rustls 0.23.37", "rustls-pki-types", "tokio", "tokio-rustls 0.26.4", "tower-service", - "webpki-roots 1.0.4", + "webpki-roots 1.0.6", ] [[package]] @@ -1597,23 +1675,22 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.18" +version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52e9a2a24dc5c6821e71a7030e1e14b7b632acac55c40e9d2e082c621261bb56" +checksum = "96547c2556ec9d12fb1578c4eaf448b04993e7fb79cbaad930a656880a6bdfa0" dependencies = [ "base64 0.22.1", "bytes", "futures-channel", - "futures-core", "futures-util", - "http 1.3.1", + "http 1.4.0", "http-body 1.0.1", "hyper 1.8.1", "ipnet", "libc", "percent-encoding", "pin-project-lite", - "socket2 0.5.10", + "socket2 0.6.3", "tokio", "tower-service", "tracing", @@ -1621,9 +1698,9 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.64" +version = "0.1.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33e57f83510bb73707521ebaffa789ec8caf86f9657cad665b092b581d40e9fb" +checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -1691,9 +1768,9 @@ checksum = "7aedcccd01fc5fe81e6b489c15b247b8b0690feb23304303a9e560f37efc560a" [[package]] name = "icu_properties" -version = "2.1.1" +version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e93fcd3157766c0c8da2f8cff6ce651a31f0810eaa1c51ec363ef790bbb5fb99" +checksum = "020bfc02fe870ec3a66d93e677ccca0562506e5872c650f893269e08615d74ec" dependencies = [ "icu_collections", "icu_locale_core", @@ -1705,9 +1782,9 @@ dependencies = [ [[package]] name = "icu_properties_data" -version = "2.1.1" +version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02845b3647bb045f1100ecd6480ff52f34c35f82d9880e029d329c21d1054899" +checksum = "616c294cf8d725c6afcd8f55abc17c56464ef6211f9ed59cccffe534129c77af" [[package]] name = "icu_provider" @@ -1724,6 +1801,12 @@ dependencies = [ "zerovec", ] +[[package]] +name = "id-arena" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954" + [[package]] name = "ident_case" version = "1.0.1" @@ -1751,6 +1834,21 @@ dependencies = [ "icu_properties", ] +[[package]] +name = "im" +version = "15.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0acd33ff0285af998aaf9b57342af478078f53492322fafc47450e09397e0e9" +dependencies = [ + "bitmaps", + "rand_core 0.6.4", + "rand_xoshiro", + "serde", + "sized-chunks", + "typenum", + "version_check", +] + [[package]] name = "indexmap" version = "1.9.3" @@ -1764,12 +1862,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.12.0" +version = "2.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6717a8d2a5a929a1a2eb43a12812498ed141a0bcfb7e8f7844fbdbe4303bba9f" +checksum = "7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017" dependencies = [ "equivalent", - "hashbrown 0.16.0", + "hashbrown 0.16.1", "serde", "serde_core", ] @@ -1797,24 +1895,24 @@ dependencies = [ [[package]] name = "inventory" -version = "0.3.21" +version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc61209c082fbeb19919bee74b176221b27223e27b65d781eb91af24eb1fb46e" +checksum = "009ae045c87e7082cb72dab0ccd01ae075dd00141ddc108f43a0ea150a9e7227" dependencies = [ "rustversion", ] [[package]] name = "ipnet" -version = "2.11.0" +version = "2.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" +checksum = "d98f6fed1fde3f8c21bc40a1abb88dd75e67924f9cffc3ef95607bad8017f8e2" [[package]] name = "iri-string" -version = "0.7.9" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f867b9d1d896b67beb18518eda36fdb77a32ea590de864f1325b294a6d14397" +checksum = "c91338f0783edbd6195decb37bae672fd3b165faffb89bf7b9e6942f8b1a731a" dependencies = [ "memchr", "serde", @@ -1846,15 +1944,15 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.15" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" +checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2" [[package]] name = "js-sys" -version = "0.3.82" +version = "0.3.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b011eec8cc36da2aab2d5cff675ec18454fad408585853910a202391cf9f8e65" +checksum = "b49715b7073f385ba4bc528e5747d02e66cb39c6146efb66b781f131f0fb399c" dependencies = [ "once_cell", "wasm-bindgen", @@ -1873,9 +1971,9 @@ dependencies = [ [[package]] name = "keccak" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" +checksum = "cb26cec98cce3a3d96cbb7bced3c4b16e3d13f27ec56dbd62cbc8f39cfb9d653" dependencies = [ "cpufeatures", ] @@ -1921,27 +2019,34 @@ dependencies = [ "spin", ] +[[package]] +name = "leb128fmt" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" + [[package]] name = "libc" -version = "0.2.177" +version = "0.2.183" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976" +checksum = "b5b646652bf6661599e1da8901b3b9522896f01e736bad5f723fe7a3a27f899d" [[package]] name = "libm" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de" +checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" [[package]] name = "libredox" -version = "0.1.10" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "416f7e718bdb06000964960ffa43b4335ad4012ae8b99060261aa4a8088d5ccb" +checksum = "1744e39d1d6a9948f4f388969627434e31128196de472883b39f148769bfe30a" dependencies = [ - "bitflags 2.10.0", + "bitflags 2.11.0", "libc", - "redox_syscall 0.5.18", + "plain", + "redox_syscall 0.7.3", ] [[package]] @@ -1957,9 +2062,9 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.11.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039" +checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" [[package]] name = "litemap" @@ -1978,9 +2083,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.28" +version = "0.4.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432" +checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" [[package]] name = "lru-slab" @@ -2015,9 +2120,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.7.6" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" +checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" [[package]] name = "mime" @@ -2044,9 +2149,9 @@ dependencies = [ [[package]] name = "mio" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69d83b0086dc8ecf3ce9ae2874b2d1290252e2a30720bea58a5c6639b0092873" +checksum = "a69bcab0ad47271a0234d9422b131806bf3968021e5dc9328caf2d4cd58557fc" dependencies = [ "libc", "wasi", @@ -2176,7 +2281,7 @@ checksum = "10a8a7f5f6ba7c1b286c2fbca0454eaba116f63bbe69ed250b642d36fbb04d80" dependencies = [ "async-trait", "bytes", - "http 1.3.1", + "http 1.4.0", "opentelemetry", "reqwest", ] @@ -2189,7 +2294,7 @@ checksum = "91cf61a1868dacc576bf2b2a1c3e9ab150af7272909e80085c3173384fe11f76" dependencies = [ "async-trait", "futures-core", - "http 1.3.1", + "http 1.4.0", "opentelemetry", "opentelemetry-http", "opentelemetry-proto", @@ -2317,7 +2422,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" dependencies = [ "fixedbitset 0.4.2", - "indexmap 2.12.0", + "indexmap 2.13.0", ] [[package]] @@ -2327,7 +2432,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3672b37090dbd86368a4145bc067582552b29c27377cad4e0a306c97f9bd7772" dependencies = [ "fixedbitset 0.5.7", - "indexmap 2.12.0", + "indexmap 2.13.0", ] [[package]] @@ -2347,29 +2452,29 @@ checksum = "5be167a7af36ee22fe3115051bc51f6e6c7054c9348e28deb4f49bd6f705a315" [[package]] name = "pin-project" -version = "1.1.10" +version = "1.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677f1add503faace112b9f1373e43e9e054bfdd22ff1a63c1bc485eaec6a6a8a" +checksum = "f1749c7ed4bcaf4c3d0a3efc28538844fb29bcdd7d2b67b2be7e20ba861ff517" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.10" +version = "1.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861" +checksum = "d9b20ed30f105399776b9c883e68e536ef602a16ae6f596d2c473591d6ad64c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.117", ] [[package]] name = "pin-project-lite" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" [[package]] name = "pin-utils" @@ -2404,6 +2509,22 @@ version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" +[[package]] +name = "plain" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" + +[[package]] +name = "pluralizer" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b3eba432a00a1f6c16f39147847a870e94e2e9b992759b503e330efec778cbe" +dependencies = [ + "once_cell", + "regex", +] + [[package]] name = "poly1305" version = "0.8.0" @@ -2452,23 +2573,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" dependencies = [ "proc-macro2", - "syn 2.0.110", + "syn 2.0.117", ] [[package]] name = "proc-macro-crate" -version = "3.4.0" +version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "219cb19e96be00ab2e37d6e299658a0cfa83e52429179969b0f0121b4ac46983" +checksum = "e67ba7e9b2b56446f1d419b1d807906278ffa1a658a8a5d8a39dcb1f5a78614f" dependencies = [ "toml_edit", ] [[package]] name = "proc-macro2" -version = "1.0.103" +version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ee95bc4ef87b8d5ba32e8b7714ccc834865276eab0aed5c9958d00ec45f49e8" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" dependencies = [ "unicode-ident", ] @@ -2510,7 +2631,7 @@ dependencies = [ "prost 0.12.6", "prost-types", "regex", - "syn 2.0.110", + "syn 2.0.117", "tempfile", ] @@ -2524,7 +2645,7 @@ dependencies = [ "itertools 0.12.1", "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.117", ] [[package]] @@ -2534,10 +2655,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a56d757972c98b346a9b766e3f02746cde6dd1cd1d1d563472929fdd74bec4d" dependencies = [ "anyhow", - "itertools 0.12.1", + "itertools 0.14.0", "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.117", ] [[package]] @@ -2637,9 +2758,9 @@ dependencies = [ "quinn-proto", "quinn-udp", "rustc-hash", - "rustls 0.23.35", - "socket2 0.5.10", - "thiserror 2.0.17", + "rustls 0.23.37", + "socket2 0.6.3", + "thiserror 2.0.18", "tokio", "tracing", "web-time", @@ -2647,9 +2768,9 @@ dependencies = [ [[package]] name = "quinn-proto" -version = "0.11.13" +version = "0.11.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1906b49b0c3bc04b5fe5d86a77925ae6524a19b816ae38ce1e426255f1d8a31" +checksum = "434b42fec591c96ef50e21e886936e66d3cc3f737104fdb9b737c40ffb94c098" dependencies = [ "bytes", "getrandom 0.3.4", @@ -2657,10 +2778,10 @@ dependencies = [ "rand 0.9.2", "ring", "rustc-hash", - "rustls 0.23.35", + "rustls 0.23.37", "rustls-pki-types", "slab", - "thiserror 2.0.17", + "thiserror 2.0.18", "tinyvec", "tracing", "web-time", @@ -2675,16 +2796,16 @@ dependencies = [ "cfg_aliases", "libc", "once_cell", - "socket2 0.5.10", + "socket2 0.6.3", "tracing", "windows-sys 0.60.2", ] [[package]] name = "quote" -version = "1.0.42" +version = "1.0.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a338cc41d27e6cc6dce6cefc13a0729dfbb81c262b1f519331575dd80ef3067f" +checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" dependencies = [ "proc-macro2", ] @@ -2695,6 +2816,12 @@ version = "5.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" +[[package]] +name = "r-efi" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" + [[package]] name = "radium" version = "0.7.0" @@ -2719,7 +2846,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1" dependencies = [ "rand_chacha 0.9.0", - "rand_core 0.9.3", + "rand_core 0.9.5", ] [[package]] @@ -2739,7 +2866,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" dependencies = [ "ppv-lite86", - "rand_core 0.9.3", + "rand_core 0.9.5", ] [[package]] @@ -2748,18 +2875,27 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.16", + "getrandom 0.2.17", ] [[package]] name = "rand_core" -version = "0.9.3" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" +checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c" dependencies = [ "getrandom 0.3.4", ] +[[package]] +name = "rand_xoshiro" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f97cdb2a36ed4183de61b2f824cc45c9f1037f28afe0a322e9fff4c108b5aaa" +dependencies = [ + "rand_core 0.6.4", +] + [[package]] name = "redox_syscall" version = "0.2.16" @@ -2775,7 +2911,16 @@ version = "0.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" dependencies = [ - "bitflags 2.10.0", + "bitflags 2.11.0", +] + +[[package]] +name = "redox_syscall" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce70a74e890531977d37e532c34d45e9055d2409ed08ddba14529471ed0be16" +dependencies = [ + "bitflags 2.11.0", ] [[package]] @@ -2795,14 +2940,14 @@ checksum = "b7186006dcb21920990093f30e3dea63b7d6e977bf1256be20c3563a5db070da" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.117", ] [[package]] name = "regex" -version = "1.12.2" +version = "1.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "843bc0191f75f3e22651ae5f1e72939ab2f72a4bc30fa80a066bd66edefc24d4" +checksum = "e10754a14b9137dd7b1e3e5b0493cc9171fdd105e0ab477f51b72e7f3ac0e276" dependencies = [ "aho-corasick", "memchr", @@ -2812,9 +2957,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5276caf25ac86c8d810222b3dbb938e512c55c6831a10f3e6ed1c93b84041f1c" +checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f" dependencies = [ "aho-corasick", "memchr", @@ -2823,9 +2968,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.8" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58" +checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a" [[package]] name = "rend" @@ -2838,16 +2983,16 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.12.24" +version = "0.12.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d0946410b9f7b082a427e4ef5c8ff541a88b357bc6c637c40db3a68ac70a36f" +checksum = "eddd3ca559203180a307f12d114c268abf583f59b03cb906fd0b3ff8646c1147" dependencies = [ "base64 0.22.1", "bytes", "futures-channel", "futures-core", "futures-util", - "http 1.3.1", + "http 1.4.0", "http-body 1.0.1", "http-body-util", "hyper 1.8.1", @@ -2858,7 +3003,7 @@ dependencies = [ "percent-encoding", "pin-project-lite", "quinn", - "rustls 0.23.35", + "rustls 0.23.37", "rustls-pki-types", "serde", "serde_json", @@ -2866,14 +3011,14 @@ dependencies = [ "sync_wrapper 1.0.2", "tokio", "tokio-rustls 0.26.4", - "tower 0.5.2", + "tower 0.5.3", "tower-http", "tower-service", "url", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", - "webpki-roots 1.0.4", + "webpki-roots 1.0.6", ] [[package]] @@ -2884,7 +3029,7 @@ checksum = "562ceb5a604d3f7c885a792d42c199fd8af239d0a51b2fa6a78aafa092452b04" dependencies = [ "anyhow", "async-trait", - "http 1.3.1", + "http 1.4.0", "reqwest", "serde", "thiserror 1.0.69", @@ -2901,8 +3046,8 @@ dependencies = [ "async-trait", "chrono", "futures", - "getrandom 0.2.16", - "http 1.3.1", + "getrandom 0.2.17", + "http 1.4.0", "hyper 1.8.1", "parking_lot 0.11.2", "reqwest", @@ -2932,7 +3077,7 @@ checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" dependencies = [ "cc", "cfg-if", - "getrandom 0.2.16", + "getrandom 0.2.17", "libc", "untrusted", "windows-sys 0.52.0", @@ -2969,9 +3114,9 @@ dependencies = [ [[package]] name = "rsa" -version = "0.9.9" +version = "0.9.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40a0376c50d0358279d9d643e4bf7b7be212f1f4ff1da9070a7b54d22ef75c88" +checksum = "b8573f03f5883dcaebdfcf4725caa1ecb9c15b2ef50c43a07b816e06799bb12d" dependencies = [ "const-oid", "digest", @@ -2989,9 +3134,9 @@ dependencies = [ [[package]] name = "rust_decimal" -version = "1.39.0" +version = "1.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35affe401787a9bd846712274d97654355d21b2a2c092a3139aabe31e9022282" +checksum = "61f703d19852dbf87cbc513643fa81428361eb6940f1ac14fd58155d295a3eb0" dependencies = [ "arrayvec", "borsh", @@ -3005,12 +3150,12 @@ dependencies = [ [[package]] name = "rust_decimal_macros" -version = "1.39.0" +version = "1.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae8c0cb48f413ebe24dc2d148788e0efbe09ba3e011d9277162f2eaf8e1069a3" +checksum = "74a5a6f027e892c7a035c6fddb50435a1fbf5a734ffc0c2a9fed4d0221440519" dependencies = [ "quote", - "syn 2.0.110", + "syn 2.0.117", ] [[package]] @@ -3021,11 +3166,11 @@ checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" [[package]] name = "rustix" -version = "1.1.2" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd15f8a2c5551a84d56efdc1cd049089e409ac19a3072d5037a17fd70719ff3e" +checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" dependencies = [ - "bitflags 2.10.0", + "bitflags 2.11.0", "errno", "libc", "linux-raw-sys", @@ -3046,14 +3191,14 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.35" +version = "0.23.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "533f54bc6a7d4f647e46ad909549eda97bf5afc1585190ef692b4286b198bd8f" +checksum = "758025cb5fccfd3bc2fd74708fd4682be41d99e5dff73c377c0646c6012c73a4" dependencies = [ "once_cell", "ring", "rustls-pki-types", - "rustls-webpki 0.103.8", + "rustls-webpki 0.103.9", "subtle", "zeroize", ] @@ -3078,9 +3223,9 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.13.0" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94182ad936a0c91c324cd46c6511b9510ed16af436d7b5bab34beab0afd55f7a" +checksum = "be040f8b0a225e40375822a563fa9524378b9d63112f53e19ffff34df5d33fdd" dependencies = [ "web-time", "zeroize", @@ -3098,9 +3243,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.103.8" +version = "0.103.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ffdfa2f5286e2247234e03f680868ac2815974dc39e00ea15adc445d0aafe52" +checksum = "d7df23109aa6c1567d1c575b9952556388da57401e4ace1d15f79eedad0d8f53" dependencies = [ "ring", "rustls-pki-types", @@ -3115,19 +3260,18 @@ checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" [[package]] name = "rusty-money" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b28f881005eac7ad8d46b6f075da5f322bd7f4f83a38720fc069694ddadd683" +checksum = "08cda49b2c0126c2672b3886d66552ce3bfa47a9bd4473a5c53acd061270bc17" dependencies = [ "rust_decimal", - "rust_decimal_macros", ] [[package]] name = "ryu" -version = "1.0.20" +version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" +checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" [[package]] name = "same-file" @@ -3161,9 +3305,9 @@ dependencies = [ [[package]] name = "schemars" -version = "1.1.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9558e172d4e8533736ba97870c4b2cd63f84b382a3d6eb063da41b91cce17289" +checksum = "a2b42f36aa1cd011945615b92222f6bf73c599a102a300334cd7f8dbeec726cc" dependencies = [ "dyn-clone", "ref-cast", @@ -3220,6 +3364,12 @@ dependencies = [ "cc", ] +[[package]] +name = "semver" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2" + [[package]] name = "serde" version = "1.0.228" @@ -3247,20 +3397,20 @@ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.117", ] [[package]] name = "serde_json" -version = "1.0.145" +version = "1.0.149" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c" +checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" dependencies = [ "itoa", "memchr", - "ryu", "serde", "serde_core", + "zmij", ] [[package]] @@ -3277,17 +3427,17 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.16.0" +version = "3.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10574371d41b0d9b2cff89418eda27da52bcaff2cc8741db26382a77c29131f1" +checksum = "381b283ce7bc6b476d903296fb59d0d36633652b633b27f64db4fb46dcbfc3b9" dependencies = [ "base64 0.22.1", "chrono", "hex", "indexmap 1.9.3", - "indexmap 2.12.0", + "indexmap 2.13.0", "schemars 0.9.0", - "schemars 1.1.0", + "schemars 1.2.1", "serde_core", "serde_json", "serde_with_macros", @@ -3296,14 +3446,14 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.16.0" +version = "3.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08a72d8216842fdd57820dc78d840bef99248e35fb2554ff923319e60f2d686b" +checksum = "a6d4e30573c8cb306ed6ab1dca8423eec9a463ea0e155f45399455e0368b27e0" dependencies = [ "darling 0.21.3", "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.117", ] [[package]] @@ -3312,7 +3462,7 @@ version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ - "indexmap 2.12.0", + "indexmap 2.13.0", "itoa", "ryu", "serde", @@ -3321,11 +3471,12 @@ dependencies = [ [[package]] name = "serial_test" -version = "3.2.0" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b258109f244e1d6891bf1053a55d63a5cd4f8f4c30cf9a1280989f80e7a1fa9" +checksum = "911bd979bf1070a3f3aa7b691a3b3e9968f339ceeec89e08c280a8a22207a32f" dependencies = [ - "futures", + "futures-executor", + "futures-util", "log", "once_cell", "parking_lot 0.12.5", @@ -3335,13 +3486,13 @@ dependencies = [ [[package]] name = "serial_test_derive" -version = "3.2.0" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d69265a08751de7844521fd15003ae0a888e035773ba05695c5c759a6f89eef" +checksum = "0a7d91949b85b0d2fb687445e448b40d322b6b3e4af6b44a29b21d9a5f33e6d9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.117", ] [[package]] @@ -3393,10 +3544,11 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "signal-hook-registry" -version = "1.4.6" +version = "1.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2a4719bff48cee6b39d12c020eeb490953ad2443b7055bd0b21fca26bd8c28b" +checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b" dependencies = [ + "errno", "libc", ] @@ -3418,15 +3570,25 @@ checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" [[package]] name = "siphasher" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" +checksum = "b2aa850e253778c88a04c3d7323b043aeda9d3e30d5971937c1855769763678e" + +[[package]] +name = "sized-chunks" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16d69225bde7a69b235da73377861095455d298f2b970996eec25ddbb42b3d1e" +dependencies = [ + "bitmaps", + "typenum", +] [[package]] name = "slab" -version = "0.4.11" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a2ae44ef20feb57a68b23d846850f861394c2e02dc425a50098ae8c90267589" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" [[package]] name = "sled" @@ -3465,12 +3627,12 @@ dependencies = [ [[package]] name = "socket2" -version = "0.6.1" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17129e116933cf371d018bb80ae557e889637989d8638274fb25622827b03881" +checksum = "3a766e1110788c36f4fa1c2b71b387a7815aa65f88ce0229841826633d93723e" dependencies = [ "libc", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -3537,14 +3699,14 @@ dependencies = [ "hashbrown 0.14.5", "hashlink", "hex", - "indexmap 2.12.0", + "indexmap 2.13.0", "log", "memchr", "once_cell", "paste", "percent-encoding", "rust_decimal", - "rustls 0.23.35", + "rustls 0.23.37", "rustls-pemfile 2.2.0", "serde", "serde_json", @@ -3618,7 +3780,7 @@ dependencies = [ "quote", "sqlx-core", "sqlx-macros-core", - "syn 2.0.110", + "syn 2.0.117", ] [[package]] @@ -3641,7 +3803,7 @@ dependencies = [ "sqlx-mysql", "sqlx-postgres", "sqlx-sqlite", - "syn 2.0.110", + "syn 2.0.117", "tempfile", "tokio", "url", @@ -3655,7 +3817,7 @@ checksum = "64bb4714269afa44aef2755150a0fc19d756fb580a67db8885608cf02f47d06a" dependencies = [ "atoi", "base64 0.22.1", - "bitflags 2.10.0", + "bitflags 2.11.0", "byteorder", "bytes", "chrono", @@ -3700,7 +3862,7 @@ checksum = "6fa91a732d854c5d7726349bb4bb879bb9478993ceb764247660aee25f67c2f8" dependencies = [ "atoi", "base64 0.22.1", - "bitflags 2.10.0", + "bitflags 2.11.0", "byteorder", "chrono", "crc", @@ -3839,9 +4001,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.110" +version = "2.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a99801b5bd34ede4cf3fc688c5919368fea4e4814a4664359503e6015b280aea" +checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" dependencies = [ "proc-macro2", "quote", @@ -3871,7 +4033,7 @@ checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.117", ] [[package]] @@ -3882,12 +4044,12 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" -version = "3.23.0" +version = "3.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d31c77bdf42a745371d260a26ca7163f1e0924b64afa0b688e61b5a9fa02f16" +checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" dependencies = [ "fastrand", - "getrandom 0.3.4", + "getrandom 0.4.2", "once_cell", "rustix", "windows-sys 0.61.2", @@ -3895,9 +4057,9 @@ dependencies = [ [[package]] name = "term" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2111ef44dae28680ae9752bb89409e7310ca33a8c621ebe7b106cf5c928b3ac0" +checksum = "d8c27177b12a6399ffc08b98f76f7c9a1f4fe9fc967c784c5a071fa8d93cf7e1" dependencies = [ "windows-sys 0.61.2", ] @@ -3913,11 +4075,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.17" +version = "2.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8" +checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4" dependencies = [ - "thiserror-impl 2.0.17", + "thiserror-impl 2.0.18", ] [[package]] @@ -3928,18 +4090,18 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.117", ] [[package]] name = "thiserror-impl" -version = "2.0.17" +version = "2.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913" +checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.117", ] [[package]] @@ -4009,9 +4171,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.48.0" +version = "1.50.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff360e02eab121e0bc37a2d3b4d4dc622e6eda3a8e5253d5435ecf5bd4c68408" +checksum = "27ad5e34374e03cfffefc301becb44e9dc3c17584f414349ebe29ed26661822d" dependencies = [ "bytes", "libc", @@ -4019,7 +4181,7 @@ dependencies = [ "parking_lot 0.12.5", "pin-project-lite", "signal-hook-registry", - "socket2 0.6.1", + "socket2 0.6.3", "tokio-macros", "windows-sys 0.61.2", ] @@ -4036,13 +4198,13 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.6.0" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af407857209536a95c8e56f8231ef2c2e2aff839b22e07a1ffcbc617e9db9fa5" +checksum = "5c55a2eff8b69ce66c84f85e1da1c233edc36ceb85a2058d11b0d6a3c7e7569c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.117", ] [[package]] @@ -4061,15 +4223,15 @@ version = "0.26.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1729aa945f29d91ba541258c8df89027d5792d85a8841fb65e8bf0f4ede4ef61" dependencies = [ - "rustls 0.23.35", + "rustls 0.23.37", "tokio", ] [[package]] name = "tokio-stream" -version = "0.1.17" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eca58d7bba4a75707817a2c44174253f9236b2d5fbd055602e9d5c07c139a047" +checksum = "32da49809aab5c3bc678af03902d4ccddea2a87d028d86392a4b1560c6906c70" dependencies = [ "futures-core", "pin-project-lite", @@ -4079,9 +4241,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.17" +version = "0.7.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2efa149fe76073d6e8fd97ef4f4eca7b67f599660115591483572e406e165594" +checksum = "9ae9cec805b01e8fc3fd2fe289f89149a9b66dd16786abd8b19cfa7b48cb0098" dependencies = [ "bytes", "futures-core", @@ -4092,20 +4254,20 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.7.3" +version = "1.0.0+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2cdb639ebbc97961c51720f858597f7f24c4fc295327923af55b74c3c724533" +checksum = "32c2555c699578a4f59f0cc68e5116c8d7cabbd45e1409b989d4be085b53f13e" dependencies = [ "serde_core", ] [[package]] name = "toml_edit" -version = "0.23.7" +version = "0.25.4+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6485ef6d0d9b5d0ec17244ff7eb05310113c3f316f2d14200d4de56b3cb98f8d" +checksum = "7193cbd0ce53dc966037f54351dbbcf0d5a642c7f0038c382ef9e677ce8c13f2" dependencies = [ - "indexmap 2.12.0", + "indexmap 2.13.0", "toml_datetime", "toml_parser", "winnow", @@ -4113,9 +4275,9 @@ dependencies = [ [[package]] name = "toml_parser" -version = "1.0.4" +version = "1.0.9+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0cbe268d35bdb4bb5a56a2de88d0ad0eb70af5384a99d648cd4b3d04039800e" +checksum = "702d4415e08923e7e1ef96cd5727c0dfed80b4d2fa25db9647fe5eb6f7c5a4c4" dependencies = [ "winnow", ] @@ -4188,8 +4350,8 @@ dependencies = [ "axum 0.7.9", "base64 0.22.1", "bytes", - "h2 0.4.12", - "http 1.3.1", + "h2 0.4.13", + "http 1.4.0", "http-body 1.0.1", "http-body-util", "hyper 1.8.1", @@ -4217,7 +4379,7 @@ dependencies = [ "proc-macro2", "prost-build", "quote", - "syn 2.0.110", + "syn 2.0.117", ] [[package]] @@ -4230,7 +4392,7 @@ dependencies = [ "proc-macro2", "prost-build", "quote", - "syn 2.0.110", + "syn 2.0.117", ] [[package]] @@ -4268,9 +4430,9 @@ dependencies = [ [[package]] name = "tower" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9" +checksum = "ebe5ef63511595f1344e2d5cfa636d973292adc0eec1f0ad45fae9f0851ab1d4" dependencies = [ "futures-core", "futures-util", @@ -4283,18 +4445,18 @@ dependencies = [ [[package]] name = "tower-http" -version = "0.6.6" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adc82fd73de2a9722ac5da747f12383d2bfdb93591ee6c58486e0097890f05f2" +checksum = "d4e6559d53cc268e5031cd8429d05415bc4cb4aefc4aa5d6cc35fbf5b924a1f8" dependencies = [ - "bitflags 2.10.0", + "bitflags 2.11.0", "bytes", "futures-util", - "http 1.3.1", + "http 1.4.0", "http-body 1.0.1", "iri-string", "pin-project-lite", - "tower 0.5.2", + "tower 0.5.3", "tower-layer", "tower-service", ] @@ -4313,9 +4475,9 @@ checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" [[package]] name = "tracing" -version = "0.1.41" +version = "0.1.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" +checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" dependencies = [ "log", "pin-project-lite", @@ -4325,20 +4487,20 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.30" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81383ab64e72a7a8b8e13130c49e3dab29def6d0c7d76a03087b3cf71c5c6903" +checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.117", ] [[package]] name = "tracing-core" -version = "0.1.34" +version = "0.1.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9d12581f227e93f094d3af2ae690a574abb8a2b9b7a96e7cfe9647b2b617678" +checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" dependencies = [ "once_cell", "valuable", @@ -4385,9 +4547,9 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.20" +version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2054a14f5307d601f88daf0553e1cbf472acc4f2c51afab632431cdcd72124d5" +checksum = "2f30143827ddab0d256fd843b7a66d164e9f271cfa0dde49142c5ca0ca291f1e" dependencies = [ "matchers", "nu-ansi-term", @@ -4443,7 +4605,7 @@ checksum = "27a7a9b72ba121f6f1f6c3632b85604cac41aedb5ddc70accbebb6cac83de846" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.117", ] [[package]] @@ -4454,9 +4616,9 @@ checksum = "5c1cb5db39152898a79168971543b1cb5020dff7fe43c8dc468b0885f5e29df5" [[package]] name = "unicode-ident" -version = "1.0.22" +version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" [[package]] name = "unicode-normalization" @@ -4473,6 +4635,12 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7df058c713841ad818f1dc5d3fd88063241cc61f49f5fbea4b951e8cf5a8d71d" +[[package]] +name = "unicode-segmentation" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" + [[package]] name = "unicode-xid" version = "0.2.6" @@ -4509,9 +4677,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.5.7" +version = "2.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08bc136a29a3d1758e07a9cca267be308aeebf5cfd5a10f3f67ab2097683ef5b" +checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" dependencies = [ "form_urlencoded", "idna", @@ -4533,13 +4701,13 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" -version = "1.18.1" +version = "1.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f87b8aa10b915a06587d0dec516c282ff295b475d94abf425d62b57710070a2" +checksum = "a68d3c8f01c0cfa54a75291d83601161799e4a89a39e0929f4b0354d88757a37" dependencies = [ - "getrandom 0.3.4", + "getrandom 0.4.2", "js-sys", - "serde", + "serde_core", "wasm-bindgen", ] @@ -4588,9 +4756,18 @@ checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" [[package]] name = "wasip2" -version = "1.0.1+wasi-0.2.4" +version = "1.0.2+wasi-0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0562428422c63773dad2c345a1882263bbf4d65cf3f42e90921f787ef5ad58e7" +checksum = "9517f9239f02c069db75e65f174b3da828fe5f5b945c4dd26bd25d89c03ebcf5" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "wasip3" +version = "0.4.0+wasi-0.3.0-rc-2026-01-06" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5" dependencies = [ "wit-bindgen", ] @@ -4603,9 +4780,9 @@ checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b" [[package]] name = "wasm-bindgen" -version = "0.2.105" +version = "0.2.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da95793dfc411fbbd93f5be7715b0578ec61fe87cb1a42b12eb625caa5c5ea60" +checksum = "6532f9a5c1ece3798cb1c2cfdba640b9b3ba884f5db45973a6f442510a87d38e" dependencies = [ "cfg-if", "once_cell", @@ -4616,11 +4793,12 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.55" +version = "0.4.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "551f88106c6d5e7ccc7cd9a16f312dd3b5d36ea8b4954304657d5dfba115d4a0" +checksum = "e9c5522b3a28661442748e09d40924dfb9ca614b21c00d3fd135720e48b67db8" dependencies = [ "cfg-if", + "futures-util", "js-sys", "once_cell", "wasm-bindgen", @@ -4629,9 +4807,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.105" +version = "0.2.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04264334509e04a7bf8690f2384ef5265f05143a4bff3889ab7a3269adab59c2" +checksum = "18a2d50fcf105fb33bb15f00e7a77b772945a2ee45dcf454961fd843e74c18e6" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -4639,26 +4817,48 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.105" +version = "0.2.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "420bc339d9f322e562942d52e115d57e950d12d88983a14c79b86859ee6c7ebc" +checksum = "03ce4caeaac547cdf713d280eda22a730824dd11e6b8c3ca9e42247b25c631e3" dependencies = [ "bumpalo", "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.117", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.105" +version = "0.2.114" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76f218a38c84bcb33c25ec7059b07847d465ce0e0a76b995e134a45adcb6af76" +checksum = "75a326b8c223ee17883a4251907455a2431acc2791c98c26279376490c378c16" dependencies = [ "unicode-ident", ] +[[package]] +name = "wasm-encoder" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319" +dependencies = [ + "leb128fmt", + "wasmparser", +] + +[[package]] +name = "wasm-metadata" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909" +dependencies = [ + "anyhow", + "indexmap 2.13.0", + "wasm-encoder", + "wasmparser", +] + [[package]] name = "wasm-timer" version = "0.2.5" @@ -4674,11 +4874,23 @@ dependencies = [ "web-sys", ] +[[package]] +name = "wasmparser" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe" +dependencies = [ + "bitflags 2.11.0", + "hashbrown 0.15.5", + "indexmap 2.13.0", + "semver", +] + [[package]] name = "web-sys" -version = "0.3.82" +version = "0.3.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a1f95c0d03a47f4ae1f7a64643a6bb97465d9b740f0fa8f90ea33915c99a9a1" +checksum = "854ba17bb104abfb26ba36da9729addc7ce7f06f5c0f90f3c391f8461cca21f9" dependencies = [ "js-sys", "wasm-bindgen", @@ -4719,14 +4931,14 @@ version = "0.26.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "521bc38abb08001b01866da9f51eb7c5d647a19260e00054a8c7fd5f9e57f7a9" dependencies = [ - "webpki-roots 1.0.4", + "webpki-roots 1.0.6", ] [[package]] name = "webpki-roots" -version = "1.0.4" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2878ef029c47c6e8cf779119f20fcf52bde7ad42a731b2a304bc221df17571e" +checksum = "22cfaf3c063993ff62e73cb4311efde4db1efb31ab78a3e5c457939ad5cc0bed" dependencies = [ "rustls-pki-types", ] @@ -4793,7 +5005,7 @@ checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.117", ] [[package]] @@ -4804,7 +5016,7 @@ checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.117", ] [[package]] @@ -5055,18 +5267,100 @@ checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" [[package]] name = "winnow" -version = "0.7.13" +version = "0.7.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21a0236b59786fed61e2a80582dd500fe61f18b5dca67a4a067d0bc9039339cf" +checksum = "df79d97927682d2fd8adb29682d1140b343be4ac0f08fd68b7765d9c059d3945" dependencies = [ "memchr", ] [[package]] name = "wit-bindgen" -version = "0.46.0" +version = "0.51.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59" +checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" +dependencies = [ + "wit-bindgen-rust-macro", +] + +[[package]] +name = "wit-bindgen-core" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc" +dependencies = [ + "anyhow", + "heck", + "wit-parser", +] + +[[package]] +name = "wit-bindgen-rust" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21" +dependencies = [ + "anyhow", + "heck", + "indexmap 2.13.0", + "prettyplease", + "syn 2.0.117", + "wasm-metadata", + "wit-bindgen-core", + "wit-component", +] + +[[package]] +name = "wit-bindgen-rust-macro" +version = "0.51.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c0f9bfd77e6a48eccf51359e3ae77140a7f50b1e2ebfe62422d8afdaffab17a" +dependencies = [ + "anyhow", + "prettyplease", + "proc-macro2", + "quote", + "syn 2.0.117", + "wit-bindgen-core", + "wit-bindgen-rust", +] + +[[package]] +name = "wit-component" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2" +dependencies = [ + "anyhow", + "bitflags 2.11.0", + "indexmap 2.13.0", + "log", + "serde", + "serde_derive", + "serde_json", + "wasm-encoder", + "wasm-metadata", + "wasmparser", + "wit-parser", +] + +[[package]] +name = "wit-parser" +version = "0.244.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736" +dependencies = [ + "anyhow", + "id-arena", + "indexmap 2.13.0", + "log", + "semver", + "serde", + "serde_derive", + "serde_json", + "unicode-xid", + "wasmparser", +] [[package]] name = "writeable" @@ -5102,28 +5396,28 @@ checksum = "b659052874eb698efe5b9e8cf382204678a0086ebf46982b79d6ca3182927e5d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.117", "synstructure", ] [[package]] name = "zerocopy" -version = "0.8.27" +version = "0.8.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0894878a5fa3edfd6da3f88c4805f4c8558e2b996227a3d864f47fe11e38282c" +checksum = "f2578b716f8a7a858b7f02d5bd870c14bf4ddbbcf3a4c05414ba6503640505e3" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.8.27" +version = "0.8.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88d2b8d9c68ad2b9e4340d7832716a4d21a22a1154777ad56ea55c51a9cf3831" +checksum = "7e6cc098ea4d3bd6246687de65af3f920c430e236bee1e3bf2e441463f08a02f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.117", ] [[package]] @@ -5143,7 +5437,7 @@ checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.117", "synstructure", ] @@ -5183,5 +5477,11 @@ checksum = "eadce39539ca5cb3985590102671f2567e659fca9666581ad3411d59207951f3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.110", + "syn 2.0.117", ] + +[[package]] +name = "zmij" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" diff --git a/Cargo.toml b/Cargo.toml index 230a8b9d..1ea04665 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,6 +8,7 @@ edition = "2021" fail-on-warnings = [] [dependencies] +es-entity = "0.9.0" sqlx-ledger = { version = "=0.11.14", features = ["otel"] } anyhow = "1.0.82" diff --git a/Makefile b/Makefile index 020ca3fe..80d4abf0 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,9 @@ watch: next-watch: cargo watch -s 'cargo nextest run' +test-integration: reset-deps + cargo nextest run --verbose --locked + check-code: SQLX_OFFLINE=true cargo fmt --check --all SQLX_OFFLINE=true cargo clippy --all-features @@ -17,7 +20,7 @@ check-code: local-daemon: SIGNER_ENCRYPTION_KEY="0000000000000000000000000000000000000000000000000000000000000000" \ - cargo run --bin bria daemon --config ./tests/e2e/bria.local.yml run + cargo run --bin bria daemon --config ./bats/bria.local.yml run build-x86_64-unknown-linux-musl-release: SQLX_OFFLINE=true cargo build --release --locked --target x86_64-unknown-linux-musl @@ -47,7 +50,7 @@ test-in-ci: start-deps e2e-tests-in-container: git config --global --add safe.directory /repo # otherwise bats complains SQLX_OFFLINE=true cargo build --locked - bats -t tests/e2e + bats -t bats e2e: clean-deps build start-deps - bats -t tests/e2e + bats -t bats diff --git a/tests/e2e/bitcoind_multisig2_signer_descriptors.json b/bats/bitcoind_multisig2_signer_descriptors.json similarity index 100% rename from tests/e2e/bitcoind_multisig2_signer_descriptors.json rename to bats/bitcoind_multisig2_signer_descriptors.json diff --git a/tests/e2e/bitcoind_multisig_signer_descriptors.json b/bats/bitcoind_multisig_signer_descriptors.json similarity index 100% rename from tests/e2e/bitcoind_multisig_signer_descriptors.json rename to bats/bitcoind_multisig_signer_descriptors.json diff --git a/tests/e2e/bitcoind_signer_descriptors.json b/bats/bitcoind_signer_descriptors.json similarity index 100% rename from tests/e2e/bitcoind_signer_descriptors.json rename to bats/bitcoind_signer_descriptors.json diff --git a/tests/e2e/bitcoind_sync.bats b/bats/bitcoind_sync.bats similarity index 99% rename from tests/e2e/bitcoind_sync.bats rename to bats/bitcoind_sync.bats index 2799c971..15ee5767 100644 --- a/tests/e2e/bitcoind_sync.bats +++ b/bats/bitcoind_sync.bats @@ -14,6 +14,8 @@ teardown_file() { stop_daemon } +BATS_TEST_RETRIES=5 + @test "bitcoind_signer_sync: Generates the same address" { bitcoind_signer_address=$(bitcoin_signer_cli getnewaddress) bria_address=$(bria_cmd new-address -w default | jq -r '.address') diff --git a/tests/e2e/bria.docker.yml b/bats/bria.docker.yml similarity index 100% rename from tests/e2e/bria.docker.yml rename to bats/bria.docker.yml diff --git a/tests/e2e/bria.local.yml b/bats/bria.local.yml similarity index 100% rename from tests/e2e/bria.local.yml rename to bats/bria.local.yml diff --git a/tests/e2e/helpers.bash b/bats/helpers.bash similarity index 85% rename from tests/e2e/helpers.bash rename to bats/helpers.bash index a299408d..740ab1c8 100644 --- a/tests/e2e/helpers.bash +++ b/bats/helpers.bash @@ -1,5 +1,6 @@ REPO_ROOT=$(git rev-parse --show-toplevel) COMPOSE_PROJECT_NAME="${COMPOSE_PROJECT_NAME:-${REPO_ROOT##*/}}" +DOCKER_ENGINE="${DOCKER_ENGINE:-docker}" SIGNER_ENCRYPTION_KEY="0000000000000000000000000000000000000000000000000000000000000000" BRIA_HOME="${BRIA_HOME:-.bria}" export PG_CON="${PG_CON:-${DATABASE_URL}}" @@ -52,11 +53,11 @@ cached_encumbered_outgoing() { } bitcoin_cli() { - docker exec "${COMPOSE_PROJECT_NAME}-bitcoind-1" bitcoin-cli $@ + ${DOCKER_ENGINE} exec "${COMPOSE_PROJECT_NAME}-bitcoind-1" bitcoin-cli $@ } bitcoin_signer_cli() { - docker exec "${COMPOSE_PROJECT_NAME}-bitcoind-signer-1" bitcoin-cli $@ + ${DOCKER_ENGINE} exec "${COMPOSE_PROJECT_NAME}-bitcoind-signer-1" bitcoin-cli $@ } convert_btc_to_sats() { @@ -80,19 +81,19 @@ bitcoin_signer_cli_send_all_utxos () { lnd_cli() { - docker exec "${COMPOSE_PROJECT_NAME}-lnd-1" lncli -n regtest $@ + ${DOCKER_ENGINE} exec "${COMPOSE_PROJECT_NAME}-lnd-1" lncli -n regtest $@ } reset_pg() { - docker exec "${COMPOSE_PROJECT_NAME}-postgres-1" psql $PG_CON -c "DROP SCHEMA public CASCADE" - docker exec "${COMPOSE_PROJECT_NAME}-postgres-1" psql $PG_CON -c "CREATE SCHEMA public" + ${DOCKER_ENGINE} exec "${COMPOSE_PROJECT_NAME}-postgres-1" psql $PG_CON -c "DROP SCHEMA public CASCADE" + ${DOCKER_ENGINE} exec "${COMPOSE_PROJECT_NAME}-postgres-1" psql $PG_CON -c "CREATE SCHEMA public" } restart_bitcoin_stack() { - docker compose ${COMPOSE_FILE_ARG} rm -sfv bitcoind bitcoind-signer lnd fulcrum mempool || true + ${DOCKER_ENGINE} compose ${COMPOSE_FILE_ARG} rm -sfv bitcoind bitcoind-signer lnd fulcrum mempool || true # Running this twice has sometimes bitcoind is dangling in CI - docker compose ${COMPOSE_FILE_ARG} rm -sfv bitcoind bitcoind-signer lnd fulcrum mempool || true - docker compose ${COMPOSE_FILE_ARG} up -d bitcoind bitcoind-signer lnd fulcrum mempool + ${DOCKER_ENGINE} compose ${COMPOSE_FILE_ARG} rm -sfv bitcoind bitcoind-signer lnd fulcrum mempool || true + ${DOCKER_ENGINE} compose ${COMPOSE_FILE_ARG} up -d bitcoind bitcoind-signer lnd fulcrum mempool retry 10 1 lnd_cli getinfo } @@ -104,17 +105,17 @@ bitcoind_init() { if [[ "${wallet}" == "default" ]]; then bitcoin_signer_cli createwallet "default" || true - bitcoin_signer_cli -rpcwallet=default importdescriptors "$(cat ${REPO_ROOT}/tests/e2e/bitcoind_signer_descriptors.json)" + bitcoin_signer_cli -rpcwallet=default importdescriptors "$(cat ${REPO_ROOT}/bats/bitcoind_signer_descriptors.json)" elif [[ "${wallet}" == "multisig" ]]; then bitcoin_signer_cli createwallet "multisig" || true - bitcoin_signer_cli -rpcwallet=multisig importdescriptors "$(cat ${REPO_ROOT}/tests/e2e/bitcoind_multisig_signer_descriptors.json)" + bitcoin_signer_cli -rpcwallet=multisig importdescriptors "$(cat ${REPO_ROOT}/bats/bitcoind_multisig_signer_descriptors.json)" bitcoin_signer_cli createwallet "multisig2" || true - bitcoin_signer_cli -rpcwallet=multisig2 importdescriptors "$(cat ${REPO_ROOT}/tests/e2e/bitcoind_multisig2_signer_descriptors.json)" + bitcoin_signer_cli -rpcwallet=multisig2 importdescriptors "$(cat ${REPO_ROOT}/bats/bitcoind_multisig2_signer_descriptors.json)" fi } start_daemon() { - SIGNER_ENCRYPTION_KEY="${SIGNER_ENCRYPTION_KEY}" background bria_cmd daemon --config ./tests/e2e/bria.${BRIA_CONFIG:-local}.yml run > .e2e-logs + SIGNER_ENCRYPTION_KEY="${SIGNER_ENCRYPTION_KEY}" background bria_cmd daemon --config ./bats/bria.${BRIA_CONFIG:-local}.yml run > .e2e-logs for i in {1..20} do if head .e2e-logs | grep -q 'Starting main server on port'; then diff --git a/tests/e2e/lnd_sync.bats b/bats/lnd_sync.bats similarity index 100% rename from tests/e2e/lnd_sync.bats rename to bats/lnd_sync.bats diff --git a/tests/e2e/multisig_payout.bats b/bats/multisig_payout.bats similarity index 100% rename from tests/e2e/multisig_payout.bats rename to bats/multisig_payout.bats diff --git a/tests/e2e/outbox.bats b/bats/outbox.bats similarity index 100% rename from tests/e2e/outbox.bats rename to bats/outbox.bats diff --git a/tests/e2e/payout.bats b/bats/payout.bats similarity index 100% rename from tests/e2e/payout.bats rename to bats/payout.bats diff --git a/ci/pipeline.yml b/ci/pipeline.yml index 74883bf1..d5bc0a26 100644 --- a/ci/pipeline.yml +++ b/ci/pipeline.yml @@ -4,9 +4,7 @@ #@ "build_edge_image", #@ "public_docker_registry", #@ "nodejs_task_image_config", -#@ "rust_check_code", -#@ "docker_host_pool", -#@ "test_on_docker_host", +#@ "check_code", #@ "repo_resource", #@ "edge_image_resource", #@ "version_resource", @@ -16,14 +14,16 @@ #@ "rust_task_image_config", #@ "charts_repo_resource", #@ "charts_repo_bot_branch", +#@ "integration_test", +#@ "bats_test", #@ ) groups: - name: bria jobs: - check-code - - integration-tests - - e2e-tests + - integration-test + - bats-test - release - release-docker - set-dev-version @@ -31,9 +31,9 @@ groups: - build-edge-image jobs: -- #@ rust_check_code() -- #@ test_on_docker_host("integration-tests") -- #@ test_on_docker_host("e2e-tests") +- #@ check_code() +- #@ integration_test() +- #@ bats_test() - #@ build_edge_image() @@ -43,8 +43,8 @@ jobs: - in_parallel: - get: repo passed: - - integration-tests - - e2e-tests + - integration-test + - bats-test - check-code - get: pipeline-tasks - get: version @@ -298,9 +298,8 @@ resources: type: registry-image source: tag: latest - username: #@ data.values.docker_registry_user - password: #@ data.values.docker_registry_password + username: #@ data.values.gar_registry_user + password: #@ data.values.gar_registry_password repository: #@ public_docker_registry() + "/" + data.values.gh_repository - #@ charts_repo_resource() - #@ charts_repo_bot_branch() -- #@ docker_host_pool() diff --git a/ci/values.yml b/ci/values.yml index 57bfc4d6..7ce62b25 100644 --- a/ci/values.yml +++ b/ci/values.yml @@ -11,14 +11,13 @@ git_charts_uri: git@github.com:blinkbitcoin/charts.git git_charts_branch: main git_charts_bot_branch: bot-bump-bria-image -docker_registry: us.gcr.io/galoy-org -docker_registry_user: ((docker-creds.username)) -docker_registry_password: ((docker-creds.password)) +docker_registry: us.gcr.io/galoyorg +gar_registry_user: ((gar-creds.username)) +gar_registry_password: ((gar-creds.password)) osxcross_docker_username: ((osxcross-image.username)) osxcross_docker_password: ((osxcross-image.password)) osxcross_repository: ((osxcross-image.repository)) -docker_host_ip: ((staging-ssh.docker_host_ip)) artifacts_bucket_name: ((staging-gcp-creds.bucket_name)) staging_inception_creds: ((staging-gcp-creds.creds_json)) staging_ssh_private_key: ((staging-ssh.ssh_private_key)) @@ -26,3 +25,6 @@ staging_ssh_pub_key: ((staging-ssh.ssh_public_key)) git_version_branch: version gh_org: blinkbitcoin gh_repository: bria + +cachix_auth_token: ((cachix-token.token)) +cachix_cache_name: bria-ci diff --git a/ci/vendir.lock.yml b/ci/vendir.lock.yml index b67d2a69..40d94e92 100644 --- a/ci/vendir.lock.yml +++ b/ci/vendir.lock.yml @@ -2,14 +2,14 @@ apiVersion: vendir.k14s.io/v1alpha1 directories: - contents: - git: - commitTitle: 'fix: check-code executable' - sha: cfd07211efb7ef9c986020d1d24069c820fd1717 + commitTitle: 'Merge pull request #6 from GaloyMoney/chore--update-cachix-flakes-img...' + sha: f9f82f114aa5b9c50b999309e09c5eb2fcf54281 path: . path: ../.github/workflows/vendor - contents: - git: - commitTitle: 'fix: check-code executable' - sha: cfd07211efb7ef9c986020d1d24069c820fd1717 + commitTitle: 'Merge pull request #6 from GaloyMoney/chore--update-cachix-flakes-img...' + sha: f9f82f114aa5b9c50b999309e09c5eb2fcf54281 path: . path: vendor kind: LockConfig diff --git a/ci/vendor/pipeline-fragments.lib.yml b/ci/vendor/pipeline-fragments.lib.yml index 9bf05f6a..6be5c646 100644 --- a/ci/vendor/pipeline-fragments.lib.yml +++ b/ci/vendor/pipeline-fragments.lib.yml @@ -1,11 +1,11 @@ #@ load("@ytt:data", "data") #@ def public_docker_registry(): -#@ return "us.gcr.io/galoy-org" +#@ return "us.gcr.io/galoyorg" #@ end #@ def private_docker_registry(): -#@ return "gcr.io/galoy-org" +#@ return "gcr.io/galoyorg" #@ end #@ def nodejs_concourse_image(): @@ -23,31 +23,32 @@ #@ def nodejs_task_image_config(): type: registry-image source: - username: ((docker-creds.username)) - password: ((docker-creds.password)) + username: #@ data.values.gar_registry_user + password: #@ data.values.gar_registry_password repository: #@ nodejs_concourse_image() #@ end #@ def rust_task_image_config(): type: registry-image source: - username: ((docker-creds.username)) - password: ((docker-creds.password)) + username: #@ data.values.gar_registry_user + password: #@ data.values.gar_registry_password repository: #@ rust_concourse_image() #@ end #@ def release_task_image_config(): type: registry-image source: - username: ((docker-creds.username)) - password: ((docker-creds.password)) + username: #@ data.values.gar_registry_user + password: #@ data.values.gar_registry_password repository: #@ release_concourse_image() #@ end #@ def nix_task_image_config(): type: registry-image source: - repository: nixpkgs/nix-flakes + repository: ghcr.io/nix-community/docker-nixpkgs/cachix-flakes + tag: latest-x86_64-linux #@ end #@ def check_code(): @@ -64,6 +65,10 @@ plan: inputs: - name: pipeline-tasks - name: repo + caches: + - path: cargo-home/registry/index + - path: cargo-home/registry/cache + - path: cargo-target-dir run: path: pipeline-tasks/ci/vendor/tasks/check-code.sh #@ end @@ -88,27 +93,6 @@ plan: path: pipeline-tasks/ci/vendor/tasks/nodejs-check-code.sh #@ end -#@ def rust_check_code(): -name: check-code -serial: true -plan: -- in_parallel: - - { get: repo, trigger: true } - - { get: pipeline-tasks } -- task: check-code - config: - platform: linux - image_resource: #@ rust_task_image_config() - inputs: - - name: pipeline-tasks - - name: repo - caches: - - path: cargo-home - - path: cargo-target-dir - run: - path: pipeline-tasks/ci/vendor/tasks/rust-check-code.sh -#@ end - #@ def install_yarn_deps(): name: install-deps plan: @@ -133,103 +117,57 @@ plan: file: bundled-deps/bundled-deps-*.tgz #@ end -#@ def test_on_docker_host(container, additional_params={}): -#@ params = dict(additional_params) -#@ params["REPO_PATH"] = data.values.gh_repository + "-" + container -#@ params["GOOGLE_CREDENTIALS"] = "((staging-gcp-creds.creds_json))" -#@ params["SSH_PRIVATE_KEY"] = "((staging-ssh.ssh_private_key))" -#@ params["SSH_PUB_KEY"] = "((staging-ssh.ssh_public_key))" -#@ params["TEST_CONTAINER"] = container -#@ params["JEST_TIMEOUT"] = 90000 -name: #@ container -serial: true +#@ def integration_test(): +name: integration-test plan: -- { put: docker-host, params: { acquire: true } } -- in_parallel: - - { get: repo, trigger: true } - - { get: pipeline-tasks } -- task: #@ container - attempts: 2 - timeout: 12m - tags: ["galoy-staging"] - config: - platform: linux - image_resource: #@ rust_task_image_config() - inputs: - - name: pipeline-tasks - - name: docker-host - - name: repo - path: #@ data.values.gh_repository + "-" + container - caches: - - path: cargo-home - - path: cargo-target-dir - params: #@ params - run: - path: pipeline-tasks/ci/vendor/tasks/test-on-docker-host.sh - ensure: - put: docker-host - params: - release: docker-host -#@ end - -#@ def nodejs_integration_test(): -name: test-integration -serial: true -plan: -- in_parallel: - - { get: repo, trigger: true } - - { get: pipeline-tasks } - - { get: bundled-deps, tags: ["galoy-staging"], trigger: true} -- task: test-integration - timeout: 12m - tags: ["galoy-staging"] - config: - platform: linux - image_resource: #@ nodejs_task_image_config() - inputs: - - name: bundled-deps - - name: pipeline-tasks - - name: repo - path: #@ data.values.gh_repository + "-integration" - params: - REPO_PATH: #@ data.values.gh_repository + "-integration" - DOCKER_HOST_IP: ((staging-ssh.docker_host_ip)) - GOOGLE_CREDENTIALS: ((staging-gcp-creds.creds_json)) - SSH_PRIVATE_KEY: ((staging-ssh.ssh_private_key)) - SSH_PUB_KEY: ((staging-ssh.ssh_public_key)) - JEST_TIMEOUT: 90000 - run: - path: pipeline-tasks/ci/vendor/tasks/chart-test-integration.sh + - in_parallel: + - get: repo + trigger: true + - { get: pipeline-tasks } + - task: integration-test + attempts: 2 + privileged: true + config: + platform: linux + image_resource: #@ nix_task_image_config() + inputs: + - name: pipeline-tasks + - name: repo + caches: + - path: cargo-home/registry/index + - path: cargo-home/registry/cache + - path: cargo-target-dir + run: + path: pipeline-tasks/ci/vendor/tasks/test-integration.sh + params: + CACHIX_AUTH_TOKEN: #@ data.values.cachix_auth_token + CACHIX_CACHE_NAME: #@ data.values.cachix_cache_name #@ end -#@ def rust_integration_test(): -name: test-integration -serial: true +#@ def bats_test(): +name: bats-test plan: - in_parallel: - - { get: repo, trigger: true } - - { get: pipeline-tasks } -- task: test-integration - timeout: 12m - tags: ["galoy-staging"] + - get: repo + trigger: true + - get: pipeline-tasks +- task: bats-test + privileged: true config: platform: linux - image_resource: #@ rust_task_image_config() + image_resource: #@ nix_task_image_config() inputs: - name: pipeline-tasks - name: repo - path: #@ data.values.gh_repository + "-integration" caches: - - path: cargo-home + - path: cargo-home/registry/index + - path: cargo-home/registry/cache - path: cargo-target-dir - params: - REPO_PATH: #@ data.values.gh_repository + "-integration" - DOCKER_HOST_IP: ((staging-ssh.docker_host_ip)) - GOOGLE_CREDENTIALS: ((staging-gcp-creds.creds_json)) - SSH_PRIVATE_KEY: ((staging-ssh.ssh_private_key)) - SSH_PUB_KEY: ((staging-ssh.ssh_public_key)) run: - path: pipeline-tasks/ci/vendor/tasks/chart-test-integration.sh + path: pipeline-tasks/ci/vendor/tasks/test-bats.sh + params: + CACHIX_AUTH_TOKEN: #@ data.values.cachix_auth_token + CACHIX_CACHE_NAME: #@ data.values.cachix_cache_name #@ end #@ def nodejs_audit(level = "high"): @@ -425,8 +363,8 @@ name: edge-image type: registry-image source: tag: edge - username: #@ data.values.docker_registry_user - password: #@ data.values.docker_registry_password + username: #@ data.values.gar_registry_user + password: #@ data.values.gar_registry_password repository: #@ public_docker_registry() + "/" + data.values.gh_repository if publicRepo else private_docker_registry() + "/" + data.values.gh_repository #@ end @@ -488,8 +426,8 @@ source: name: versioned-image type: registry-image source: - username: #@ data.values.docker_registry_user - password: #@ data.values.docker_registry_password + username: #@ data.values.gar_registry_user + password: #@ data.values.gar_registry_password repository: #@ public_docker_registry() + "/" + data.values.gh_repository if publicRepo else private_docker_registry() + "/" + data.values.gh_repository #@ end @@ -511,16 +449,6 @@ source: private_key: #@ data.values.github_private_key #@ end -#@ def docker_host_pool(): -name: docker-host -type: pool -source: - uri: git@github.com:blinkbitcoin/concourse-locks.git - branch: main - pool: docker-hosts - private_key: #@ data.values.github_private_key -#@ end - #@ def gcr_resource_type(): name: gcs-resource type: docker-image diff --git a/ci/vendor/tasks/chart-test-integration.sh b/ci/vendor/tasks/chart-test-integration.sh deleted file mode 100755 index fe56d778..00000000 --- a/ci/vendor/tasks/chart-test-integration.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash - -#! Auto synced from Shared CI Resources repository -#! Don't change this file, instead change it in github.com/blinkbitcoin/concourse-shared - -set -eu - -. pipeline-tasks/ci/vendor/tasks/helpers.sh - -CI_ROOT=$(pwd) - -unpack_deps - -cat < ${CI_ROOT}/gcloud-creds.json -${GOOGLE_CREDENTIALS} -EOF -cat < ${CI_ROOT}/login.ssh -${SSH_PRIVATE_KEY} -EOF -chmod 600 ${CI_ROOT}/login.ssh -cat < ${CI_ROOT}/login.ssh.pub -${SSH_PUB_KEY} -EOF -gcloud auth activate-service-account --key-file ${CI_ROOT}/gcloud-creds.json -gcloud compute os-login ssh-keys add --key-file=${CI_ROOT}/login.ssh.pub > /dev/null - -mkdir ~/.ssh -cp ${CI_ROOT}/login.ssh ~/.ssh/id_rsa -cp ${CI_ROOT}/login.ssh.pub ~/.ssh/id_rsa.pub - -export DOCKER_HOST_USER="sa_$(cat ${CI_ROOT}/gcloud-creds.json | jq -r '.client_id')" -export DOCKER_HOST=ssh://${DOCKER_HOST_USER}@${DOCKER_HOST_IP} -export ADDITIONAL_SSH_OPTS="-o StrictHostKeyChecking=no -i ${CI_ROOT}/login.ssh" - -pushd ${REPO_PATH} - -echo "Syncing repo to docker-host... " -rsync --delete --exclude target -avr -e "ssh -l ${DOCKER_HOST_USER} ${ADDITIONAL_SSH_OPTS}" \ - ./ ${DOCKER_HOST_IP}:${REPO_PATH} > /dev/null -echo "Done!" - -docker compose down --remove-orphans --timeout 1 - -ssh ${ADDITIONAL_SSH_OPTS} ${DOCKER_HOST_USER}@${DOCKER_HOST_IP} \ - "cd ${REPO_PATH}; docker compose -f docker-compose.yml up integration-tests" - -container_id=$(docker ps -q -f status=exited -f name="${PWD##*/}-integration-tests-") -test_status=$(docker inspect $container_id --format='{{.State.ExitCode}}') - -docker compose down --remove-orphans --timeout 1 - -exit $test_status diff --git a/ci/vendor/tasks/check-code.sh b/ci/vendor/tasks/check-code.sh index 98fe86be..620f2190 100755 --- a/ci/vendor/tasks/check-code.sh +++ b/ci/vendor/tasks/check-code.sh @@ -1,10 +1,15 @@ -#!/bin/bash +#!/usr/bin/env bash #! Auto synced from Shared CI Resources repository #! Don't change this file, instead change it in github.com/blinkbitcoin/concourse-shared -set -eu +set -euo pipefail +nix -L develop ./repo -c sh -exc ' +set -euo pipefail + +source pipeline-tasks/ci/vendor/tasks/helpers.sh pushd repo -nix develop -c make check-code +make check-code +' diff --git a/ci/vendor/tasks/rust-check-code.sh b/ci/vendor/tasks/rust-check-code.sh deleted file mode 100755 index 1bf2a1fd..00000000 --- a/ci/vendor/tasks/rust-check-code.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -#! Auto synced from Shared CI Resources repository -#! Don't change this file, instead change it in github.com/blinkbitcoin/concourse-shared - -set -eu - -pushd repo - -make check-code diff --git a/ci/vendor/tasks/test-bats.sh b/ci/vendor/tasks/test-bats.sh new file mode 100755 index 00000000..9318d2c8 --- /dev/null +++ b/ci/vendor/tasks/test-bats.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Change to repo directory +pushd repo + +echo "--- Setting up Cachix ---" +cachix use "${CACHIX_CACHE_NAME}" + +# cannot call the profile dev as it fails with a symlink error +# perhaps its a reserved keyword +echo "--- Setting up Nix development environment ---" +nix develop --profile dev-profile -c true +cachix push "${CACHIX_CACHE_NAME}" dev-profile + +echo "--- Running bats tests in Nix environment ---" + +nix -L develop --command sh -exc ' +set -euo pipefail + +cd .. +source pipeline-tasks/ci/vendor/tasks/helpers.sh +pushd repo + +echo "--- Checking for Podman (via nix) ---" +command -v podman +echo "--- Podman check done ---" +command -v podman-compose +echo "--- Podman-compose check done ---" + +echo "--- Testing Podman basic functionality ---" +podman info || echo "Warning: podman info failed." +echo "--- Podman info done ---" + +echo "--- Starting Podman service ---" +# Ensure DOCKER_HOST points to the standard rootful socket location +export DOCKER_HOST=unix:///run/podman/podman.sock +podman system service --time=0 & # Start service in background +sleep 5 # Wait a bit for the socket to become active +echo "--- Podman service started (attempted) ---" + +mkdir -p /etc/containers +echo "{\"default\": [{\"type\": \"insecureAcceptAnything\"}]}" > /etc/containers/policy.json +echo "unqualified-search-registries = [\"docker.io\"]" > /etc/containers/registries.conf + +echo "--- Starting Dependencies with Podman Compose ---" +podman compose up -d integration-deps +echo "--- Podman-compose up done ---" + +make setup-db + +# --- Build Test Artifacts --- +echo "--- Building test artifacts---" +# nix build . -L +make build + +# --- Run Bats Tests --- +echo "--- Running BATS tests ---" +export DOCKER_ENGINE=podman +bats -t bats + +echo "--- e2e Tests done ---" + +echo "--- Cleaning up dependencies ---" +podman compose down +echo "--- Cleanup done ---" + +echo "--- All steps completed ---" +' diff --git a/ci/vendor/tasks/test-integration.sh b/ci/vendor/tasks/test-integration.sh new file mode 100755 index 00000000..5d2671eb --- /dev/null +++ b/ci/vendor/tasks/test-integration.sh @@ -0,0 +1,64 @@ +#!/usr/bin/env bash + +#! Auto synced from Shared CI Resources repository +#! Don't change this file, instead change it in github.com/GaloyMoney/concourse-shared + +set -euo pipefail + +# Change to repo directory +pushd repo + +echo "--- Setting up Cachix ---" +cachix use "${CACHIX_CACHE_NAME}" + +# cannot call the profile dev as it fails with a symlink error +# perhaps its a reserved keyword +echo "--- Setting up Nix development environment ---" +nix develop --profile dev-profile -c true +cachix push "${CACHIX_CACHE_NAME}" dev-profile + +echo "--- Running integration tests in Nix environment ---" +nix -L develop --command sh -exc ' +set -euo pipefail + +cd .. +source pipeline-tasks/ci/vendor/tasks/helpers.sh +pushd repo + +echo "--- Checking for Podman (via nix) ---" +command -v podman +echo "--- Podman check done ---" +command -v podman-compose +echo "--- Podman-compose check done ---" + +echo "--- Testing Podman basic functionality ---" +podman info || echo "Warning: podman info failed." +echo "--- Podman info done ---" + +echo "--- Starting Podman service ---" +# Ensure DOCKER_HOST points to the standard rootful socket location +export DOCKER_HOST=unix:///run/podman/podman.sock +podman system service --time=0 & # Start service in background +sleep 5 # Wait a bit for the socket to become active +echo "--- Podman service started (attempted) ---" + +mkdir -p /etc/containers +echo "{\"default\": [{\"type\": \"insecureAcceptAnything\"}]}" > /etc/containers/policy.json +echo "unqualified-search-registries = [\"docker.io\"]" > /etc/containers/registries.conf + +echo "--- Starting Dependencies with Podman Compose ---" +podman compose up -d integration-deps +echo "--- Podman-compose up done ---" + +make setup-db + +echo "--- Running Integration Tests ---" +cargo nextest run --verbose --locked +echo "--- Tests done ---" + +echo "--- Cleaning up dependencies ---" +podman compose down +echo "--- Cleanup done ---" + +echo "--- All steps completed ---" +' diff --git a/ci/vendor/tasks/test-on-docker-host.sh b/ci/vendor/tasks/test-on-docker-host.sh deleted file mode 100755 index 31f127c5..00000000 --- a/ci/vendor/tasks/test-on-docker-host.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash - -set -eu - -export CI_ROOT=$(pwd) - -host_name=$(cat docker-host/metadata | jq -r '.docker_host_name') -echo "Running on host: ${host_name}" -host_zone=$(cat docker-host/metadata | jq -r '.docker_host_zone') -gcp_project=$(cat docker-host/metadata | jq -r '.docker_host_project') - -gcloud_ssh() { - gcloud compute ssh ${host_name} \ - --zone=${host_zone} \ - --project=${gcp_project} \ - --ssh-key-file=${CI_ROOT}/login.ssh \ - --tunnel-through-iap \ - --command "$@" 2> /dev/null -} - -cat < ${CI_ROOT}/gcloud-creds.json -${GOOGLE_CREDENTIALS} -EOF -cat < ${CI_ROOT}/login.ssh -${SSH_PRIVATE_KEY} -EOF -chmod 600 ${CI_ROOT}/login.ssh -cat < ${CI_ROOT}/login.ssh.pub -${SSH_PUB_KEY} -EOF -gcloud auth activate-service-account --key-file ${CI_ROOT}/gcloud-creds.json 2> /dev/null - -gcloud_ssh "docker ps -qa | xargs docker rm -fv || true; sudo rm -rf ${REPO_PATH} || true; mkdir -p ${REPO_PATH} && cd ${REPO_PATH}/../ && rmdir $(basename ${REPO_PATH})" - -pushd ${REPO_PATH} - -make create-tmp-env-ci || true - -gcloud compute scp --ssh-key-file=${CI_ROOT}/login.ssh \ - --recurse $(pwd) ${host_name}:${REPO_PATH} \ - --tunnel-through-iap \ - --zone=${host_zone} \ - --project=${gcp_project} > /dev/null - -gcloud_ssh "cd ${REPO_PATH}; export TMP_ENV_CI=tmp.env.ci; export COMPOSE_PROJECT_NAME=$(basename ${REPO_PATH}); source .envrc || true; docker compose pull; docker compose -f docker-compose.yml up ${TEST_CONTAINER} --attach ${TEST_CONTAINER} 2>&1" - -container_id=$(gcloud_ssh "docker ps -q -f status=exited -f name=${PWD##*/}-${TEST_CONTAINER}-") -test_status=$(gcloud_ssh "docker inspect $container_id --format='{{.State.ExitCode}}'") - -gcloud_ssh "cd ${REPO_PATH}; export COMPOSE_PROJECT_NAME=$(basename ${REPO_PATH}); docker compose down --remove-orphans --timeout 1" - -exit $test_status diff --git a/docker-compose.yml b/docker-compose.yml index 85dc7bf9..d2a37882 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -118,14 +118,33 @@ services: command: ["Fulcrum", "/fulcrum.conf"] mempool: image: mempool/backend - depends_on: [bitcoind] + depends_on: [bitcoind, mempool_db] environment: MEMPOOL_BACKEND: "none" CORE_RPC_HOST: bitcoind CORE_RPC_PORT: "18443" CORE_RPC_USERNAME: "rpcuser" CORE_RPC_PASSWORD: "rpcpassword" - DATABASE_ENABLED: "false" + DATABASE_ENABLED: "true" + DATABASE_HOST: "mempool_db" + DATABASE_USERNAME: "mempool" + DATABASE_PASSWORD: "mempool" + DATABASE_DATABASE: "mempool" + user: "1000:1000" + command: "./wait-for-it.sh mempool_db:3306 -- ./start.sh" + volumes: + - ${HOST_PROJECT_PATH:-.}/.mempool_data/backend:/backend/cache + mempool_db: + environment: + MYSQL_DATABASE: "mempool" + MYSQL_USER: "mempool" + MYSQL_PASSWORD: "mempool" + MYSQL_ROOT_PASSWORD: "admin" + image: mariadb:10.5.21 + user: "1000:1000" + restart: on-failure + volumes: + - ${HOST_PROJECT_PATH:-.}/.mempool_data/mysql:/var/lib/mysql volumes: cargo-cache: cargo-target: diff --git a/docs/demo.md b/docs/demo.md index 78a563cb..9eeb172f 100644 --- a/docs/demo.md +++ b/docs/demo.md @@ -27,9 +27,9 @@ ``` export PATH="${PATH}:$(pwd)/target/debug" ``` -* start the bria daemon with the [default configuration](../tests/e2e/bria.local.yml) and bootstrap +* start the bria daemon with the [default configuration](../bats/bria.local.yml) and bootstrap ``` - bria daemon --config ./tests/e2e/bria.local.yml postgres://user:password@127.0.0.1:5432/pg dev + bria daemon --config ./bats/bria.local.yml postgres://user:password@127.0.0.1:5432/pg dev ``` * open a new terminal and run direnv allow @@ -43,10 +43,10 @@ bitcoin_cli createwallet "default" bitcoin_cli generatetoaddress 200 "$(bitcoin_cli getnewaddress)" ``` -* create a bitcoind wallet using a [sample private descriptor](../tests/e2e/bitcoind_signer_descriptors.json) +* create a bitcoind wallet using a [sample private descriptor](../bats/bitcoind_signer_descriptors.json) ``` bitcoin_signer_cli createwallet "default" - bitcoin_signer_cli -rpcwallet=default importdescriptors "$(cat tests/e2e/bitcoind_signer_descriptors.json)" + bitcoin_signer_cli -rpcwallet=default importdescriptors "$(cat bats/bitcoind_signer_descriptors.json)" ``` * create a Bria account ``` diff --git a/flake.lock b/flake.lock index 07a70e5d..d9f789e0 100644 --- a/flake.lock +++ b/flake.lock @@ -20,11 +20,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1771147098, - "narHash": "sha256-jpfPdBjKO232s5NueoNEvvVzpndiUzPLNYcH4/Ov0gY=", + "lastModified": 1773110118, + "narHash": "sha256-mPAG8phMbCReKSiKAijjjd3v7uVcJOQ75gSjGJjt/Rk=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "e3cb16bccd9facebae3ba29c6a76a4cc1b73462a", + "rev": "e607cb5360ff1234862ac9f8839522becb853bb9", "type": "github" }, "original": { @@ -48,11 +48,11 @@ ] }, "locked": { - "lastModified": 1771211437, - "narHash": "sha256-lcNK438i4DGtyA+bPXXyVLHVmJjYpVKmpux9WASa3ro=", + "lastModified": 1773216618, + "narHash": "sha256-iZlowevS+xKLGOXtZwpIrz3SWe7PtoGUfEeVZNib+WE=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "c62195b3d6e1bb11e0c2fb2a494117d3b55d410f", + "rev": "07d7dc6fcc5eae76b4fb0e19d4afd939437bec97", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index ddc450f0..7135843b 100644 --- a/flake.nix +++ b/flake.nix @@ -8,7 +8,6 @@ url = "github:oxalica/rust-overlay"; inputs = { nixpkgs.follows = "nixpkgs"; - flake-utils.follows = "flake-utils"; }; }; }; @@ -57,6 +56,9 @@ docker-compose bats jq + podman + podman-compose + bc ]; shellHook = '' # Workaround for nixpkgs xcrun warnings on Darwin diff --git a/migrations/20260310100000_add_created_at_to_signing_sessions.down.sql b/migrations/20260310100000_add_created_at_to_signing_sessions.down.sql new file mode 100644 index 00000000..c6619173 --- /dev/null +++ b/migrations/20260310100000_add_created_at_to_signing_sessions.down.sql @@ -0,0 +1 @@ +ALTER TABLE bria_signing_sessions DROP COLUMN created_at; diff --git a/migrations/20260310100000_add_created_at_to_signing_sessions.up.sql b/migrations/20260310100000_add_created_at_to_signing_sessions.up.sql new file mode 100644 index 00000000..a4fa02da --- /dev/null +++ b/migrations/20260310100000_add_created_at_to_signing_sessions.up.sql @@ -0,0 +1,12 @@ +ALTER TABLE bria_signing_sessions ADD COLUMN created_at TIMESTAMPTZ; + +UPDATE bria_signing_sessions +SET created_at =( + SELECT MIN(recorded_at) + FROM bria_signing_session_events + WHERE bria_signing_session_events.id = bria_signing_sessions.id +); + +ALTER TABLE bria_signing_sessions +ALTER COLUMN created_at SET NOT NULL, +ALTER COLUMN created_at SET DEFAULT NOW(); diff --git a/migrations/20260310100100_add_account_id_to_initialized_event_in_payout.down.sql b/migrations/20260310100100_add_account_id_to_initialized_event_in_payout.down.sql new file mode 100644 index 00000000..fae7254f --- /dev/null +++ b/migrations/20260310100100_add_account_id_to_initialized_event_in_payout.down.sql @@ -0,0 +1,3 @@ +UPDATE bria_payout_events +SET event = event - 'account_id' +WHERE event ? 'account_id' AND event_type = 'initialized'; diff --git a/migrations/20260310100100_add_account_id_to_initialized_event_in_payout.up.sql b/migrations/20260310100100_add_account_id_to_initialized_event_in_payout.up.sql new file mode 100644 index 00000000..c1f1decc --- /dev/null +++ b/migrations/20260310100100_add_account_id_to_initialized_event_in_payout.up.sql @@ -0,0 +1,9 @@ +UPDATE bria_payout_events +SET event = jsonb_set( + event, + '{account_id}', + to_jsonb(p.account_id::text) +) +FROM bria_payouts p +WHERE bria_payout_events.id = p.id +AND event_type = 'initialized' AND event->>'account_id' IS NULL; diff --git a/migrations/20260310100200_add_context_to_events.down.sql b/migrations/20260310100200_add_context_to_events.down.sql new file mode 100644 index 00000000..2805b90a --- /dev/null +++ b/migrations/20260310100200_add_context_to_events.down.sql @@ -0,0 +1,7 @@ +ALTER TABLE bria_xpub_events DROP COLUMN context; +ALTER TABLE bria_wallet_events DROP COLUMN context; +ALTER TABLE bria_address_events DROP COLUMN context; +ALTER TABLE bria_payout_queue_events DROP COLUMN context; +ALTER TABLE bria_payout_events DROP COLUMN context; +ALTER TABLE bria_signing_session_events DROP COLUMN context; +ALTER TABLE bria_profile_events DROP COLUMN context; diff --git a/migrations/20260310100200_add_context_to_events.up.sql b/migrations/20260310100200_add_context_to_events.up.sql new file mode 100644 index 00000000..246747a1 --- /dev/null +++ b/migrations/20260310100200_add_context_to_events.up.sql @@ -0,0 +1,7 @@ +ALTER TABLE bria_xpub_events ADD COLUMN context JSONB DEFAULT NULL; +ALTER TABLE bria_wallet_events ADD COLUMN context JSONB DEFAULT NULL; +ALTER TABLE bria_address_events ADD COLUMN context JSONB DEFAULT NULL; +ALTER TABLE bria_payout_queue_events ADD COLUMN context JSONB DEFAULT NULL; +ALTER TABLE bria_payout_events ADD COLUMN context JSONB DEFAULT NULL; +ALTER TABLE bria_signing_session_events ADD COLUMN context JSONB DEFAULT NULL; +ALTER TABLE bria_profile_events ADD COLUMN context JSONB DEFAULT NULL; diff --git a/src/account/repo.rs b/src/account/repo.rs index b5d12076..aa3070f5 100644 --- a/src/account/repo.rs +++ b/src/account/repo.rs @@ -1,4 +1,4 @@ -use sqlx::{Pool, Postgres, Transaction}; +use sqlx::{Pool, Postgres}; use uuid::Uuid; use super::{entity::*, error::AccountError}; @@ -13,9 +13,9 @@ impl Accounts { Self { pool: pool.clone() } } - pub async fn create_in_tx( + pub async fn create_in_op( &self, - tx: &mut Transaction<'_, Postgres>, + op: &mut impl es_entity::AtomicOperation, account_name: String, ) -> Result { let id = Uuid::new_v4(); @@ -26,7 +26,7 @@ impl Accounts { id, account_name, ) - .fetch_one(&mut **tx) + .fetch_one(op.as_executor()) .await?; Ok(Account { name: account_name, diff --git a/src/address/entity.rs b/src/address/entity.rs index a3378c61..c37188ec 100644 --- a/src/address/entity.rs +++ b/src/address/entity.rs @@ -1,13 +1,12 @@ use derive_builder::Builder; +use es_entity::*; use serde::{Deserialize, Serialize}; -use crate::{ - entity::*, - primitives::{bitcoin::*, *}, -}; +use crate::primitives::{bitcoin::*, *}; -#[derive(Debug, Serialize, Deserialize)] +#[derive(EsEvent, Debug, Serialize, Deserialize)] #[serde(tag = "type", rename_all = "snake_case")] +#[es_event(id = "uuid::Uuid")] pub enum AddressEvent { Initialized { db_uuid: uuid::Uuid, @@ -27,22 +26,23 @@ pub enum AddressEvent { }, } -#[derive(Debug, Builder)] -#[builder(pattern = "owned", build_fn(error = "EntityError"))] +#[derive(EsEntity, Builder)] +#[es_entity(event = AddressEvent, new = NewAddress)] +#[builder(pattern = "owned", build_fn(error = "EsEntityError"))] pub struct WalletAddress { pub account_id: AccountId, pub address: Address, pub wallet_id: WalletId, pub external_id: String, kind: KeychainKind, - pub(super) db_uuid: uuid::Uuid, + pub(super) id: uuid::Uuid, pub(super) events: EntityEvents, } impl WalletAddress { pub fn metadata(&self) -> Option<&serde_json::Value> { let mut ret = None; - for event in self.events.iter() { + for event in self.events.iter_all() { if let AddressEvent::MetadataUpdated { metadata } = event { ret = Some(metadata) } @@ -65,13 +65,13 @@ impl WalletAddress { } pub fn is_external(&self) -> bool { - self.kind == KeychainKind::External + matches!(self.kind, KeychainKind::External) } } #[derive(Builder, Clone, Debug)] pub struct NewAddress { - pub(super) db_uuid: uuid::Uuid, + pub(super) id: uuid::Uuid, #[builder(setter(custom))] pub(super) address: Address, #[builder(setter(into))] @@ -90,14 +90,16 @@ pub struct NewAddress { impl NewAddress { pub fn builder() -> NewAddressBuilder { let mut builder = NewAddressBuilder::default(); - builder.db_uuid(uuid::Uuid::new_v4()); + builder.id(uuid::Uuid::new_v4()); builder } +} - pub fn initial_events(self) -> EntityEvents { - let mut events = EntityEvents::init([ +impl IntoEvents for NewAddress { + fn into_events(self) -> EntityEvents { + let mut events = vec![ AddressEvent::Initialized { - db_uuid: self.db_uuid, + db_uuid: self.id, account_id: self.account_id, wallet_id: self.wallet_id, keychain_id: self.keychain_id, @@ -109,11 +111,11 @@ impl NewAddress { AddressEvent::ExternalIdUpdated { external_id: self.external_id, }, - ]); + ]; if let Some(metadata) = self.metadata { events.push(AddressEvent::MetadataUpdated { metadata }) } - events + EntityEvents::init(self.id, events) } } @@ -127,12 +129,10 @@ impl NewAddressBuilder { } } -impl TryFrom> for WalletAddress { - type Error = EntityError; - - fn try_from(events: EntityEvents) -> Result { +impl TryFromEvents for WalletAddress { + fn try_from_events(events: EntityEvents) -> Result { let mut builder = WalletAddressBuilder::default(); - for event in events.iter() { + for event in events.iter_all() { match event { AddressEvent::Initialized { db_uuid, @@ -143,7 +143,7 @@ impl TryFrom> for WalletAddress { .. } => { builder = builder - .db_uuid(*db_uuid) + .id(*db_uuid) .account_id(*account_id) .address(address.clone()) .wallet_id(*wallet_id) diff --git a/src/address/error.rs b/src/address/error.rs index 7caf0b2c..144f8fb3 100644 --- a/src/address/error.rs +++ b/src/address/error.rs @@ -4,16 +4,16 @@ use thiserror::Error; pub enum AddressError { #[error("AddressError - external_id already exists")] ExternalIdAlreadyExists, - #[error("AddressError - external_id does not exist")] - ExternalIdNotFound, - #[error("AddressError - Could not find address: {0}")] - AddressNotFound(String), #[error("AddressError - Sqlx: {0}")] Sqlx(sqlx::Error), - #[error("AddressError - EntityError: {0}")] - EntityError(#[from] crate::entity::EntityError), + #[error("ProfileError - EsEntityError: {0}")] + EsEntityError(es_entity::EsEntityError), + #[error("ProfileError - CursorDestructureError: {0}")] + CursorDestructureError(#[from] es_entity::CursorDestructureError), } +es_entity::from_es_entity_error!(AddressError); + impl From for AddressError { fn from(error: sqlx::Error) -> Self { if let Some(err) = error.as_database_error() { diff --git a/src/address/repo.rs b/src/address/repo.rs index fb23fabd..6aa1be22 100644 --- a/src/address/repo.rs +++ b/src/address/repo.rs @@ -1,14 +1,33 @@ -use sqlx::{Pool, Postgres, Transaction}; - -use std::collections::HashMap; +use es_entity::*; +use sqlx::{Pool, Postgres}; +use uuid::Uuid; use super::{entity::*, error::AddressError}; -use crate::{ - entity::*, - primitives::{bitcoin::*, *}, -}; -#[derive(Clone)] +use crate::primitives::{bitcoin::*, *}; + +#[derive(EsRepo, Clone)] +#[es_repo( + entity = "WalletAddress", + event = "AddressEvent", + err = "AddressError", + tbl = "bria_addresses", + id = Uuid, + events_tbl = "bria_address_events", + columns( + wallet_id(ty = "WalletId", update(persist = false)), + account_id(ty = "AccountId", update(persist = false)), + keychain_id(ty = "KeychainId", update(persist = false)), + profile_id(ty = "Option", update(persist = false)), + address(ty = "String", create(accessor = "address.to_string()"), update(persist = false)), + kind( + ty = "pg::PgKeychainKind", + create(accessor = "kind.into()"), + update(persist = false) + ), + external_id(ty = "String") + ), +)] pub struct Addresses { pool: Pool, } @@ -18,39 +37,16 @@ impl Addresses { Self { pool: pool.clone() } } - pub async fn persist_new_address(&self, address: NewAddress) -> Result<(), AddressError> { - let mut tx = self.pool.begin().await?; - sqlx::query!( - r#"INSERT INTO bria_addresses - (id, account_id, wallet_id, keychain_id, profile_id, address, kind, external_id) - VALUES ($1, $2, $3, $4, $5, $6, $7, $8)"#, - address.db_uuid, - address.account_id as AccountId, - address.wallet_id as WalletId, - address.keychain_id as KeychainId, - address.profile_id as Option, - address.address.to_string(), - pg::PgKeychainKind::from(address.kind) as pg::PgKeychainKind, - address.external_id, - ) - .execute(&mut *tx) - .await?; - - Self::persist_events(&mut tx, address).await?; - tx.commit().await?; - Ok(()) - } - pub async fn persist_if_not_present( &self, - tx: &mut Transaction<'_, Postgres>, + op: &mut impl es_entity::AtomicOperation, address: NewAddress, ) -> Result<(), AddressError> { let res = sqlx::query!( r#"INSERT INTO bria_addresses (id, account_id, wallet_id, keychain_id, profile_id, address, kind, external_id) VALUES ($1, $2, $3, $4, $5, $6, $7, $8) ON CONFLICT DO NOTHING"#, - address.db_uuid, + address.id, address.account_id as AccountId, address.wallet_id as WalletId, address.keychain_id as KeychainId, @@ -59,52 +55,13 @@ impl Addresses { pg::PgKeychainKind::from(address.kind) as pg::PgKeychainKind, address.external_id, ) - .execute(&mut **tx) + .execute(op.as_executor()) .await?; if res.rows_affected() == 0 { return Ok(()); } - Self::persist_events(tx, address).await - } - - pub async fn update(&self, address: WalletAddress) -> Result<(), AddressError> { - if !address.events.is_dirty() { - return Ok(()); - } - - let mut tx = self.pool.begin().await?; - sqlx::query!( - r#"UPDATE bria_addresses - SET external_id = $1 - WHERE account_id = $2 AND address = $3"#, - address.external_id, - address.account_id as AccountId, - address.address.to_string() - ) - .execute(&mut *tx) - .await?; - EntityEvents::::persist( - "bria_address_events", - &mut tx, - address.events.new_serialized_events(address.db_uuid), - ) - .await?; - tx.commit().await?; - Ok(()) - } - - async fn persist_events( - tx: &mut Transaction<'_, Postgres>, - address: NewAddress, - ) -> Result<(), AddressError> { - let id = address.db_uuid; - EntityEvents::::persist( - "bria_address_events", - tx, - address.initial_events().new_serialized_events(id), - ) - .await?; + self.persist_events(op, &mut address.into_events()).await?; Ok(()) } @@ -113,90 +70,83 @@ impl Addresses { account_id: AccountId, wallet_id: WalletId, ) -> Result, AddressError> { - let rows = sqlx::query!( - r#" - SELECT b.id, e.sequence, e.event - FROM bria_addresses b - JOIN bria_address_events e ON b.id = e.id - WHERE account_id = $1 AND wallet_id = $2 AND kind = 'external' - ORDER BY b.created_at, b.id, sequence"#, - account_id as AccountId, - wallet_id as WalletId - ) - .fetch_all(&self.pool) - .await?; - let mut entity_events = HashMap::new(); - let mut ids = Vec::new(); - for row in rows { - let id = row.id; - ids.push(id); - let events = entity_events - .entry(id) - .or_insert_with(EntityEvents::::new); - events.load_event(row.sequence as usize, row.event)?; - } - let mut ret = Vec::new(); - for id in ids { - if let Some(events) = entity_events.remove(&id) { - ret.push(WalletAddress::try_from(events)?); + let mut wallet_addresses = Vec::new(); + let mut query = es_entity::PaginatedQueryArgs::< + wallet_address_cursor::WalletAddressesByCreatedAtCursor, + > { + first: Default::default(), + after: None, + }; + loop { + let (id, created_at) = if let Some(after) = query.after { + (Some(after.id), Some(after.created_at)) + } else { + (None, None) + }; + + let (entities, has_next_page) = es_entity::es_query!( + entity = WalletAddress, + r#" + SELECT * + FROM bria_addresses + WHERE account_id = $1 AND wallet_id = $2 AND kind = 'external' + AND (COALESCE((created_at, id) > ($4, $3), $3 IS NULL)) + ORDER BY created_at, id"#, + account_id as AccountId, + wallet_id as WalletId, + id, + created_at + ) + .fetch_n(self.pool(), query.first) + .await?; + + wallet_addresses.extend(entities); + + if !has_next_page { + break; } + query.after = wallet_addresses + .last() + .map(wallet_address_cursor::WalletAddressesByCreatedAtCursor::from); } - Ok(ret) + Ok(wallet_addresses) } - pub async fn find_by_address( + pub async fn find_by_account_id_and_address( &self, account_id: AccountId, address: String, ) -> Result { - let rows = sqlx::query!( + let wallet_address = es_entity::es_query!( + entity = WalletAddress, r#" - SELECT b.id, e.sequence, e.event - FROM bria_addresses b - JOIN bria_address_events e ON b.id = e.id - WHERE account_id = $1 AND address = $2 - ORDER BY b.created_at, b.id, sequence"#, + SELECT * + FROM bria_addresses + WHERE account_id = $1 AND address = $2"#, account_id as AccountId, - address + address.to_string() ) - .fetch_all(&self.pool) + .fetch_one(self.pool()) .await?; - - if rows.is_empty() { - return Err(AddressError::AddressNotFound(address)); - } - - let mut events = EntityEvents::new(); - for row in rows { - events.load_event(row.sequence as usize, row.event)?; - } - Ok(WalletAddress::try_from(events)?) + Ok(wallet_address) } - pub async fn find_by_external_id( + pub async fn find_by_account_id_and_external_id( &self, account_id: AccountId, external_id: String, ) -> Result { - let rows = sqlx::query!( + let wallet_address = es_entity::es_query!( + entity = WalletAddress, r#" - SELECT b.id, e.sequence, e.event - FROM bria_addresses b - JOIN bria_address_events e ON b.id = e.id - WHERE account_id = $1 AND external_id = $2 - ORDER BY b.created_at, b.id, sequence"#, + SELECT * + FROM bria_addresses + WHERE account_id = $1 AND external_id = $2"#, account_id as AccountId, external_id ) - .fetch_all(&self.pool) + .fetch_one(self.pool()) .await?; - if rows.is_empty() { - return Err(AddressError::ExternalIdNotFound); - } - let mut events = EntityEvents::new(); - for row in rows { - events.load_event(row.sequence as usize, row.event)?; - } - Ok(WalletAddress::try_from(events)?) + Ok(wallet_address) } } diff --git a/src/admin/app.rs b/src/admin/app.rs index 0d9b7fb3..ec3d7f42 100644 --- a/src/admin/app.rs +++ b/src/admin/app.rs @@ -10,7 +10,6 @@ pub struct AdminApp { accounts: Accounts, profiles: Profiles, ledger: Ledger, - pool: sqlx::PgPool, network: bitcoin::Network, } @@ -21,7 +20,6 @@ impl AdminApp { accounts: Accounts::new(&pool), profiles: Profiles::new(&pool), ledger: Ledger::new(&pool), - pool, network, } } @@ -34,26 +32,26 @@ impl AdminApp { return Err(AdminApiError::BadNetworkForDev); } let admin_key = self.bootstrap().await?; + let mut op = self.profiles.begin_op().await?; - let mut tx = self.pool.begin().await?; let account = self .accounts - .create_in_tx(&mut tx, dev_constants::DEV_ACCOUNT_NAME.to_owned()) + .create_in_op(&mut op, dev_constants::DEV_ACCOUNT_NAME.to_owned()) .await?; self.ledger - .create_journal_for_account(&mut tx, account.id, account.name.clone()) + .create_journal_for_account(op.tx_mut(), account.id, account.name.clone()) .await?; let new_profile = NewProfile::builder() .account_id(account.id) .name(account.name) .build() .expect("Couldn't build NewProfile"); - let profile = self.profiles.create_in_tx(&mut tx, new_profile).await?; + let profile = self.profiles.create_in_op(&mut op, new_profile).await?; let profile_key = self .profiles - .create_key_for_profile_in_tx(&mut tx, profile, true) + .create_key_for_profile_in_op(&mut op, profile, true) .await?; - tx.commit().await?; + op.commit().await?; Ok((admin_key, profile_key)) } @@ -73,25 +71,25 @@ impl AdminApp { &self, account_name: String, ) -> Result { - let mut tx = self.pool.begin().await?; + let mut op = self.profiles.begin_op().await?; let account = self .accounts - .create_in_tx(&mut tx, account_name.clone()) + .create_in_op(&mut op, account_name.clone()) .await?; self.ledger - .create_journal_for_account(&mut tx, account.id, account.name.clone()) + .create_journal_for_account(op.tx_mut(), account.id, account.name.clone()) .await?; let new_profile = NewProfile::builder() .account_id(account.id) .name(account.name) .build() .expect("Couldn't build NewProfile"); - let profile = self.profiles.create_in_tx(&mut tx, new_profile).await?; + let profile = self.profiles.create_in_op(&mut op, new_profile).await?; let key = self .profiles - .create_key_for_profile_in_tx(&mut tx, profile, false) + .create_key_for_profile_in_op(&mut op, profile, false) .await?; - tx.commit().await?; + op.commit().await?; Ok(key) } diff --git a/src/api/server/convert.rs b/src/api/server/convert.rs index 22e24347..7bc1a32e 100644 --- a/src/api/server/convert.rs +++ b/src/api/server/convert.rs @@ -132,7 +132,7 @@ impl From for proto::Xpub { fn from(xpub: AccountXPub) -> Self { Self { name: xpub.key_name.to_string(), - id: xpub.id().to_string(), + id: xpub.fingerprint().to_string(), xpub: xpub.original.clone(), derivation_path: xpub .derivation_path() @@ -275,7 +275,7 @@ impl From for proto::SigningSession { proto::SigningSession { id: session.id.to_string(), batch_id: session.batch_id.to_string(), - xpub_id: session.xpub_id.to_string(), + xpub_id: session.xpub_fingerprint.to_string(), failure_reason: session.failure_reason().map(|r| r.to_string()), state: format!("{:?}", session.state()), } @@ -652,43 +652,28 @@ impl From for proto::WalletAddress { impl From for tonic::Status { fn from(err: ApplicationError) -> Self { - use crate::{ - address::error::*, payout::error::*, payout_queue::error::*, profile::error::*, - wallet::error::*, - }; + use crate::{address::error::*, payout::error::*, profile::error::*, wallet::error::*}; match err { ApplicationError::ProfileError(ProfileError::ProfileKeyNotFound) => { tonic::Status::unauthenticated(err.to_string()) } - ApplicationError::WalletError(WalletError::WalletNameNotFound(_)) => { - tonic::Status::not_found(err.to_string()) - } - ApplicationError::WalletError(WalletError::WalletIdNotFound(_)) => { + ApplicationError::WalletError(err) if err.was_not_found() => { tonic::Status::not_found(err.to_string()) } - ApplicationError::AddressError(AddressError::ExternalIdNotFound) => { - tonic::Status::not_found(err.to_string()) - } - ApplicationError::AddressError(AddressError::AddressNotFound(_)) => { + ApplicationError::AddressError(err) if err.was_not_found() => { tonic::Status::not_found(err.to_string()) } ApplicationError::AddressError(AddressError::ExternalIdAlreadyExists) => { tonic::Status::already_exists(err.to_string()) } - ApplicationError::PayoutQueueError(PayoutQueueError::PayoutQueueNameNotFound(_)) => { + ApplicationError::PayoutQueueError(err) if err.was_not_found() => { tonic::Status::not_found(err.to_string()) } - ApplicationError::PayoutQueueError(PayoutQueueError::PayoutQueueIdNotFound(_)) => { + ApplicationError::ProfileError(err) if err.was_not_found() => { tonic::Status::not_found(err.to_string()) } - ApplicationError::ProfileError(ProfileError::ProfileNameNotFound(_)) => { - tonic::Status::not_found(err.to_string()) - } - ApplicationError::ProfileError(ProfileError::ProfileIdNotFound(_)) => { - tonic::Status::not_found(err.to_string()) - } - ApplicationError::PayoutError(PayoutError::PayoutIdNotFound(_)) => { + ApplicationError::PayoutError(err) if err.was_not_found() => { tonic::Status::not_found(err.to_string()) } ApplicationError::PayoutError(PayoutError::ExternalIdAlreadyExists) => { @@ -700,9 +685,6 @@ impl From for tonic::Status { ApplicationError::CouldNotParseIncomingUuid(_) => { tonic::Status::invalid_argument(err.to_string()) } - ApplicationError::PayoutError(PayoutError::ExternalIdNotFound) => { - tonic::Status::not_found(err.to_string()) - } ApplicationError::DestinationBlocked(_) => { tonic::Status::permission_denied(err.to_string()) } @@ -715,7 +697,7 @@ impl From for tonic::Status { ApplicationError::SigningSessionNotFoundForBatchId(_) => { tonic::Status::not_found(err.to_string()) } - ApplicationError::SigningSessionNotFoundForXPubId(_) => { + ApplicationError::SigningSessionNotFoundForXPubFingerprint(_) => { tonic::Status::not_found(err.to_string()) } ApplicationError::WalletError(WalletError::PsbtDoesNotHaveValidSignatures) => { diff --git a/src/api/server/mod.rs b/src/api/server/mod.rs index 72d27a82..949dc913 100644 --- a/src/api/server/mod.rs +++ b/src/api/server/mod.rs @@ -247,7 +247,7 @@ impl BriaService for Bria { name, keychain_config, } = request.into_inner(); - let (id, xpub_ids) = match keychain_config { + let (id, xpub_fingerprints) = match keychain_config { Some(KeychainConfig { config: Some(keychain_config::Config::Wpkh(keychain_config::Wpkh { @@ -286,7 +286,7 @@ impl BriaService for Bria { }; Ok(Response::new(CreateWalletResponse { id: id.to_string(), - xpub_ids: xpub_ids.into_iter().map(|id| id.to_string()).collect(), + xpub_ids: xpub_fingerprints.into_iter().map(|id| id.to_string()).collect(), })) }) .await diff --git a/src/app/error.rs b/src/app/error.rs index bad3851b..9ba387d7 100644 --- a/src/app/error.rs +++ b/src/app/error.rs @@ -71,8 +71,8 @@ pub enum ApplicationError { PayoutExceedsMaximum(Satoshis), #[error("Signing Session not found for batch id: {0}")] SigningSessionNotFoundForBatchId(crate::primitives::BatchId), - #[error("Signing Session not found for xpub id: {0}")] - SigningSessionNotFoundForXPubId(crate::primitives::XPubId), + #[error("Signing Session not found for xpub fingerprint: {0}")] + SigningSessionNotFoundForXPubFingerprint(crate::primitives::XPubFingerprint), #[error("Could not parse incoming psbt: {0}")] CouldNotParseIncomingPsbt(bitcoin::psbt::PsbtParseError), #[error("Hex decode error: {0}")] diff --git a/src/app/mod.rs b/src/app/mod.rs index 163fc3d0..5bf36809 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -116,7 +116,6 @@ impl App { config, _runners: runners, }; - crate::profile::migration::profile_event_migration(&app.pool).await?; if let Some(deprecrated_encryption_key) = app.config.deprecated_encryption_key.as_ref() { app.rotate_encryption_key(deprecrated_encryption_key) .await?; @@ -141,15 +140,13 @@ impl App { name: String, spending_policy: Option, ) -> Result { - let mut tx = self.pool.begin().await?; let new_profile = NewProfile::builder() .account_id(profile.account_id) .name(name) .spending_policy(spending_policy) .build() .expect("Couldn't build NewProfile"); - let new_profile = self.profiles.create_in_tx(&mut tx, new_profile).await?; - tx.commit().await?; + let new_profile = self.profiles.create(new_profile).await?; Ok(new_profile) } @@ -162,12 +159,10 @@ impl App { ) -> Result<(), ApplicationError> { let mut target_profile = self .profiles - .find_by_id(profile.account_id, profile_id) + .find_by_account_id_and_id(profile.account_id, profile_id) .await?; target_profile.update_spending_policy(spending_policy); - let mut tx = self.pool.begin().await?; - self.profiles.update(&mut tx, target_profile).await?; - tx.commit().await?; + self.profiles.update(&mut target_profile).await?; Ok(()) } @@ -185,12 +180,12 @@ impl App { ) -> Result { let found_profile = self .profiles - .find_by_name(profile.account_id, profile_name) + .find_by_account_id_and_name(profile.account_id, profile_name) .await?; let mut tx = self.pool.begin().await?; let key = self .profiles - .create_key_for_profile_in_tx(&mut tx, found_profile, false) + .create_key_for_profile_in_op(&mut tx, found_profile, false) .await?; tx.commit().await?; Ok(key) @@ -203,7 +198,7 @@ impl App { key_name: String, xpub: String, derivation: Option, - ) -> Result { + ) -> Result { let value = XPub::try_from((&xpub, derivation))?; let xpub = NewAccountXPub::builder() .account_id(profile.account_id) @@ -212,8 +207,8 @@ impl App { .value(value) .build() .expect("Couldn't build xpub"); - let id = self.xpubs.persist(xpub).await?; - Ok(id) + let fingerprint = self.xpubs.create(xpub).await?.fingerprint(); + Ok(fingerprint) } #[instrument(name = "app.set_signer_config", skip(self), err)] @@ -223,6 +218,7 @@ impl App { xpub_ref: String, config: SignerConfig, ) -> Result<(), ApplicationError> { + let mut op = self.xpubs.begin_op().await?; let mut xpub = self .xpubs .find_from_ref( @@ -232,16 +228,18 @@ impl App { .expect("ref should always parse"), ) .await?; - let xpub_id = xpub.id(); + let xpub_fingerprint = xpub.fingerprint(); xpub.set_signer_config(config, &self.config.signer_encryption.key)?; - let mut tx = self.pool.begin().await?; - self.xpubs.persist_updated(&mut tx, xpub).await?; + self.xpubs.update_signer_config(&mut op, xpub).await?; let batch_ids = self .signing_sessions - .list_batch_ids_for(&mut tx, profile.account_id, xpub_id) - .await?; - job::spawn_all_batch_signings(tx, batch_ids.into_iter().map(|b| (profile.account_id, b))) + .list_batch_ids_for(&mut op, profile.account_id, xpub_fingerprint) .await?; + job::spawn_all_batch_signings( + op.into(), + batch_ids.into_iter().map(|b| (profile.account_id, b)), + ) + .await?; Ok(()) } @@ -262,14 +260,14 @@ impl App { cipher.decrypt(nonce, deprecated_encrypted_key_bytes.as_slice())?; let deprecated_key = chacha20poly1305::Key::clone_from_slice(deprecated_key_bytes.as_ref()); let xpubs = self.xpubs.list_all_xpubs().await?; - let mut tx = self.pool.begin().await?; + let mut op = self.xpubs.begin_op().await?; for mut xpub in xpubs { if let Some(signing_cfg) = xpub.signing_cfg(deprecated_key) { xpub.set_signer_config(signing_cfg, &self.config.signer_encryption.key)?; - self.xpubs.persist_updated(&mut tx, xpub).await?; + self.xpubs.update_signer_config(&mut op, xpub).await?; } } - tx.commit().await?; + op.commit().await?; Ok(()) } @@ -290,7 +288,7 @@ impl App { .expect("ref should always parse"), ) .await?; - let xpub_id = xpub.id(); + let xpub_fingerprint = xpub.fingerprint(); let xpub = xpub.value; let unsigned_psbt = self .batches @@ -304,16 +302,17 @@ impl App { .await? .ok_or(ApplicationError::SigningSessionNotFoundForBatchId(batch_id))? .xpub_sessions; - let session = sessions - .get_mut(&xpub_id) - .ok_or_else(|| ApplicationError::SigningSessionNotFoundForXPubId(xpub_id))?; + let session = sessions.get_mut(&xpub_fingerprint).ok_or_else(|| { + ApplicationError::SigningSessionNotFoundForXPubFingerprint(xpub_fingerprint) + })?; - let mut tx = self.pool.begin().await?; + let mut op = self.signing_sessions.begin_op().await?; session.submit_externally_signed_psbt(signed_psbt); self.signing_sessions - .update_sessions(&mut tx, &sessions) + .update_sessions(&mut op, &sessions) + .await?; + job::spawn_all_batch_signings(op.into(), std::iter::once((profile.account_id, batch_id))) .await?; - job::spawn_all_batch_signings(tx, std::iter::once((profile.account_id, batch_id))).await?; Ok(()) } @@ -324,7 +323,7 @@ impl App { wallet_name: String, xpub: String, derivation: Option, - ) -> Result<(WalletId, Vec), ApplicationError> { + ) -> Result<(WalletId, Vec), ApplicationError> { let keychain = if let Ok(xpub) = XPub::try_from((&xpub, derivation)) { KeychainConfig::wpkh(xpub) } else { @@ -349,7 +348,7 @@ impl App { wallet_name: String, external: String, internal: String, - ) -> Result<(WalletId, Vec), ApplicationError> { + ) -> Result<(WalletId, Vec), ApplicationError> { let keychain = KeychainConfig::try_from((external.as_ref(), internal.as_ref()))?; self.create_wallet(profile, wallet_name, keychain).await } @@ -361,7 +360,7 @@ impl App { wallet_name: String, xpubs: Vec, threshold: u32, - ) -> Result<(WalletId, Vec), ApplicationError> { + ) -> Result<(WalletId, Vec), ApplicationError> { let xpub_values: Vec = futures::future::try_join_all( xpubs .iter() @@ -385,36 +384,37 @@ impl App { profile: &Profile, wallet_name: String, keychain: KeychainConfig, - ) -> Result<(WalletId, Vec), ApplicationError> { - let mut tx = self.pool.begin().await?; + ) -> Result<(WalletId, Vec), ApplicationError> { + let mut op = self.wallets.begin_op().await?; let xpubs = keychain.xpubs(); - let mut xpub_ids = Vec::new(); + let mut xpub_fingerprints = Vec::new(); for xpub in xpubs { match self .xpubs - .find_from_ref(profile.account_id, xpub.id()) + .find_from_ref(profile.account_id, xpub.fingerprint()) .await { Ok(xpub) => { - xpub_ids.push(xpub.id()); + xpub_fingerprints.push(xpub.fingerprint()); } Err(_) => { let original = xpub.inner().to_string(); let xpub = NewAccountXPub::builder() .account_id(profile.account_id) - .key_name(format!("{wallet_name}-{}", xpub.id())) + .key_name(format!("{wallet_name}-{}", xpub.fingerprint())) .original(original) .value(xpub) .build() .expect("Couldn't build xpub"); - xpub_ids.push(self.xpubs.persist_in_tx(&mut tx, xpub).await?); + xpub_fingerprints + .push(self.xpubs.create_in_op(&mut op, xpub).await?.fingerprint()); } } } let wallet_id = WalletId::new(); let wallet_ledger_accounts = self .ledger - .create_ledger_accounts_for_wallet(&mut tx, wallet_id) + .create_ledger_accounts_for_wallet(op.tx_mut(), wallet_id) .await?; let new_wallet = NewWallet::builder() .id(wallet_id) @@ -426,7 +426,7 @@ impl App { .ledger_account_ids(wallet_ledger_accounts) .build() .expect("Couldn't build NewWallet"); - let wallet_id = self.wallets.create_in_tx(&mut tx, new_wallet).await?; + let wallet = self.wallets.create_in_op(&mut op, new_wallet).await?; let descriptors = vec![ NewDescriptor::builder() .account_id(profile.account_id) @@ -444,10 +444,10 @@ impl App { .expect("Could not build descriptor"), ]; self.descriptors - .persist_all_in_tx(&mut tx, descriptors) + .persist_all_in_op(&mut op, descriptors) .await?; - tx.commit().await?; - Ok((wallet_id, xpub_ids)) + op.commit().await?; + Ok((wallet.id, xpub_fingerprints)) } #[instrument(name = "app.get_wallet_balance_summary", skip(self), err)] @@ -458,7 +458,7 @@ impl App { ) -> Result { let wallet = self .wallets - .find_by_name(profile.account_id, wallet_name) + .find_by_account_id_and_name(profile.account_id, wallet_name) .await?; let wallet_ledger_account_balances = self .ledger @@ -492,7 +492,7 @@ impl App { ) -> Result<(WalletId, Address), ApplicationError> { let wallet = self .wallets - .find_by_name(profile.account_id, wallet_name) + .find_by_account_id_and_name(profile.account_id, wallet_name) .await?; let keychain_wallet = wallet.current_keychain_wallet(&self.pool); let addr = keychain_wallet.new_external_address().await?; @@ -511,7 +511,7 @@ impl App { builder.external_id(external_id); } let new_address = builder.build().expect("Couldn't build NewAddress"); - self.addresses.persist_new_address(new_address).await?; + self.addresses.create(new_address).await?; Ok((wallet.id, address)) } @@ -526,7 +526,7 @@ impl App { ) -> Result<(), ApplicationError> { let mut address = self .addresses - .find_by_address(profile.account_id, address) + .find_by_account_id_and_address(profile.account_id, address) .await?; if let Some(id) = new_external_id { address.update_external_id(id); @@ -534,7 +534,7 @@ impl App { if let Some(metadata) = new_metadata { address.update_metadata(metadata); } - self.addresses.update(address).await?; + self.addresses.update(&mut address).await?; Ok(()) } @@ -546,7 +546,7 @@ impl App { ) -> Result<(WalletId, Vec), ApplicationError> { let wallet = self .wallets - .find_by_name(profile.account_id, wallet_name) + .find_by_account_id_and_name(profile.account_id, wallet_name) .await?; let addresses = self .addresses @@ -564,7 +564,7 @@ impl App { ) -> Result { let address = self .addresses - .find_by_external_id(profile.account_id, external_id) + .find_by_account_id_and_external_id(profile.account_id, external_id) .await?; Ok(address) } @@ -577,7 +577,7 @@ impl App { ) -> Result { let address = self .addresses - .find_by_address(profile.account_id, address) + .find_by_account_id_and_address(profile.account_id, address) .await?; Ok(address) } @@ -599,7 +599,7 @@ impl App { ) -> Result<(WalletId, Vec), ApplicationError> { let wallet = self .wallets - .find_by_name(profile.account_id, wallet_name) + .find_by_account_id_and_name(profile.account_id, wallet_name) .await?; let mut utxos = self .utxos @@ -629,8 +629,8 @@ impl App { builder.config(config); } let payout_queue = builder.build().expect("Couldn't build NewPayoutQueue"); - let payout_queue_id = self.payout_queues.create(payout_queue).await?; - Ok(payout_queue_id) + let payout_queue = self.payout_queues.create(payout_queue).await?; + Ok(payout_queue.id) } #[instrument(name = "app.trigger_payout_queue", skip(self), err)] @@ -641,7 +641,7 @@ impl App { ) -> Result<(), ApplicationError> { let payout_queue = self .payout_queues - .find_by_name(profile.account_id, name) + .find_by_account_id_and_name(profile.account_id, name) .await?; job::spawn_process_payout_queue(&self.pool, (payout_queue.account_id, payout_queue.id)) .await?; @@ -659,7 +659,7 @@ impl App { ) -> Result<(Satoshis, FeeRate), ApplicationError> { let destination_wallet = self .wallets - .find_by_name(profile.account_id, destination_wallet_name) + .find_by_account_id_and_name(profile.account_id, destination_wallet_name) .await?; let destination = destination_wallet .current_keychain_wallet(&self.pool) @@ -686,11 +686,11 @@ impl App { ) -> Result<(Satoshis, FeeRate), ApplicationError> { let wallet = self .wallets - .find_by_name(profile.account_id, wallet_name) + .find_by_account_id_and_name(profile.account_id, wallet_name) .await?; let payout_queue = self .payout_queues - .find_by_name(profile.account_id, queue_name) + .find_by_account_id_and_name(profile.account_id, queue_name) .await?; let mut tx = self.pool.begin().await?; let mut unbatched_payouts = self @@ -758,11 +758,11 @@ impl App { ) -> Result<(PayoutId, Option>), ApplicationError> { let wallet = self .wallets - .find_by_name(profile.account_id, wallet_name) + .find_by_account_id_and_name(profile.account_id, wallet_name) .await?; let payout_queue = self .payout_queues - .find_by_name(profile.account_id, queue_name) + .find_by_account_id_and_name(profile.account_id, queue_name) .await?; let addr = Address::try_from((address, self.config.blockchain.network))?; self.submit_payout( @@ -792,11 +792,11 @@ impl App { ) -> Result<(PayoutId, Option>), ApplicationError> { let wallet = self .wallets - .find_by_name(profile.account_id, wallet_name) + .find_by_account_id_and_name(profile.account_id, wallet_name) .await?; let payout_queue = self .payout_queues - .find_by_name(profile.account_id, queue_name) + .find_by_account_id_and_name(profile.account_id, queue_name) .await?; let payout_id = PayoutId::new(); let (wallet_id, address) = self @@ -858,11 +858,11 @@ impl App { builder.external_id(external_id); } let new_payout = builder.build().expect("Couldn't build NewPayout"); - let mut tx = self.pool.begin().await?; - let id = self.payouts.create_in_tx(&mut tx, new_payout).await?; + let mut op = self.payouts.begin_op().await?; + let id = self.payouts.create_in_op(&mut op, new_payout).await?.id; self.ledger .payout_submitted( - tx, + op.into(), id, PayoutSubmittedParams { journal_id: wallet.journal_id, @@ -894,22 +894,22 @@ impl App { id: PayoutId, skip_committed_check: bool, ) -> Result<(), ApplicationError> { - let mut tx = self.pool.begin().await?; + let mut op = self.payouts.begin_op().await?; let mut payout = self .payouts - .find_by_id_for_cancellation(&mut tx, profile.account_id, id) + .find_by_id_for_cancellation(&mut op, profile.account_id, id) .await?; payout.cancel_payout(profile.id, skip_committed_check)?; - self.payouts.update(&mut tx, payout).await?; + self.payouts.update_in_op(&mut op, &mut payout).await?; self.ledger - .payout_cancelled(tx, LedgerTransactionId::new(), id) + .payout_cancelled(op.into(), LedgerTransactionId::new(), id) .await?; Ok(()) } #[instrument(name = "app.list_wallets", skip_all, err)] pub async fn list_wallets(&self, profile: &Profile) -> Result, ApplicationError> { - Ok(self.wallets.list_by_account_id(profile.account_id).await?) + Ok(self.wallets.list_for_account(profile.account_id).await?) } #[instrument(name = "app.find_payout_by_external_id", skip_all, err)] @@ -920,7 +920,7 @@ impl App { ) -> Result { let payout = self .payouts - .find_by_external_id(profile.account_id, external_id) + .find_by_account_id_and_external_id(profile.account_id, external_id) .await?; Ok(self .batch_inclusion @@ -934,7 +934,10 @@ impl App { profile: &Profile, id: PayoutId, ) -> Result { - let payout = self.payouts.find_by_id(profile.account_id, id).await?; + let payout = self + .payouts + .find_by_account_id_and_id(profile.account_id, id) + .await?; Ok(self .batch_inclusion .include_estimate(profile.account_id, payout) @@ -951,7 +954,7 @@ impl App { ) -> Result, ApplicationError> { let wallet = self .wallets - .find_by_name(profile.account_id, wallet_name) + .find_by_account_id_and_name(profile.account_id, wallet_name) .await?; let payouts = self .payouts @@ -969,11 +972,10 @@ impl App { &self, profile: &Profile, ) -> Result, ApplicationError> { - let payout_queues = self + Ok(self .payout_queues - .list_by_account_id(profile.account_id) - .await?; - Ok(payout_queues) + .list_for_account_id(profile.account_id) + .await?) } #[instrument(name = "app.update_payout_queue", skip(self), err)] @@ -986,15 +988,16 @@ impl App { ) -> Result<(), ApplicationError> { let mut payout_queue = self .payout_queues - .find_by_id(profile.account_id, id) + .find_by_account_id_and_id(profile.account_id, id) .await?; + if let Some(desc) = new_description { payout_queue.update_description(desc) } if let Some(config) = new_config { payout_queue.update_config(config) } - self.payout_queues.update(payout_queue).await?; + self.payout_queues.update(&mut payout_queue).await?; Ok(()) } diff --git a/src/batch/repo.rs b/src/batch/repo.rs index 2b3a3a9b..16d735d7 100644 --- a/src/batch/repo.rs +++ b/src/batch/repo.rs @@ -23,10 +23,10 @@ impl Batches { Self { pool: pool.clone() } } - #[instrument(name = "batches.create_in_tx", skip_all)] - pub async fn create_in_tx<'a>( + #[instrument(name = "batches.create_in_op", skip_all)] + pub async fn create_in_op( &self, - tx: &mut Transaction<'a, Postgres>, + op: &mut impl es_entity::AtomicOperation, batch: NewBatch, ) -> Result { let serializied_psbt = batch.unsigned_psbt.serialize(); @@ -39,7 +39,7 @@ impl Batches { i64::from(batch.total_fee_sats), batch.tx_id.as_ref() as &[u8], serializied_psbt.as_slice() as &[u8], - ).execute(&mut **tx).await?; + ).execute(op.as_executor()).await?; let mut query_builder: QueryBuilder = QueryBuilder::new( r#"INSERT INTO bria_batch_wallet_summaries ( @@ -75,7 +75,7 @@ impl Batches { }, ); let query = query_builder.build(); - query.execute(&mut **tx).await?; + query.execute(op.as_executor()).await?; Ok(batch.id) } diff --git a/src/batch_inclusion/mod.rs b/src/batch_inclusion/mod.rs index 00885ef9..6c717c73 100644 --- a/src/batch_inclusion/mod.rs +++ b/src/batch_inclusion/mod.rs @@ -69,7 +69,7 @@ impl BatchInclusion { } let queue = self .payout_queues - .find_by_id(account_id, payout.payout_queue_id) + .find_by_account_id_and_id(account_id, payout.payout_queue_id) .await?; let estimate = self.estimate_next_queue_trigger(queue).await?; Ok(PayoutWithInclusionEstimate { @@ -83,7 +83,7 @@ impl BatchInclusion { account_id: AccountId, payouts: Vec, ) -> Result, BatchInclusionError> { - let queues = self.payout_queues.list_by_account_id(account_id).await?; + let queues = self.payout_queues.list_for_account_id(account_id).await?; let next_queue_trigger_times = self.next_queue_trigger_times(queues).await?; Ok(payouts .into_iter() diff --git a/src/descriptor/repo.rs b/src/descriptor/repo.rs index bf20cd6d..e1f42f49 100644 --- a/src/descriptor/repo.rs +++ b/src/descriptor/repo.rs @@ -1,4 +1,4 @@ -use sqlx::{Pool, Postgres, Transaction}; +use sqlx::{Pool, Postgres}; use super::{entity::*, error::DescriptorError}; use crate::primitives::*; @@ -15,20 +15,20 @@ impl Descriptors { } } - pub async fn persist_all_in_tx( + pub async fn persist_all_in_op( &self, - tx: &mut Transaction<'_, Postgres>, + op: &mut impl es_entity::AtomicOperation, descriptors: Vec, ) -> Result<(), DescriptorError> { for descriptor in descriptors { - self.persist_in_tx(tx, descriptor).await?; + self.persist_in_op(op, descriptor).await?; } Ok(()) } - async fn persist_in_tx( + async fn persist_in_op( &self, - tx: &mut Transaction<'_, Postgres>, + op: &mut impl es_entity::AtomicOperation, descriptor: NewDescriptor, ) -> Result<(), DescriptorError> { let (descriptor_str, checksum) = descriptor.descriptor_and_checksum(); @@ -53,7 +53,7 @@ impl Descriptors { bitcoin::pg::PgKeychainKind::from(descriptor.keychain_kind) as bitcoin::pg::PgKeychainKind, ) - .fetch_one(&mut **tx) + .fetch_one(op.as_executor()) .await?; if res.wallet_id != Some(descriptor.wallet_id) { diff --git a/src/entity/event.rs b/src/entity/event.rs deleted file mode 100644 index f9e9f78c..00000000 --- a/src/entity/event.rs +++ /dev/null @@ -1,117 +0,0 @@ -use serde::{de::DeserializeOwned, Serialize}; - -use super::error::EntityError; - -#[derive(Debug)] -pub struct EntityEvents { - last_persisted_sequence: usize, - events: Vec, -} - -impl EntityEvents { - #[allow(clippy::new_without_default)] - pub fn new() -> Self { - Self { - last_persisted_sequence: 0, - events: Vec::new(), - } - } - - pub fn init(initial_events: impl IntoIterator) -> Self { - Self { - last_persisted_sequence: 0, - events: initial_events.into_iter().collect(), - } - } - - pub fn push(&mut self, event: T) { - self.events.push(event); - } - - pub fn iter(&self) -> impl DoubleEndedIterator { - self.events.iter() - } - - pub fn into_iter(self) -> impl DoubleEndedIterator { - self.events.into_iter() - } - - pub fn load_event( - &mut self, - sequence: usize, - json: serde_json::Value, - ) -> Result<(), EntityError> { - let event = serde_json::from_value(json)?; - self.last_persisted_sequence = sequence; - self.events.push(event); - Ok(()) - } - - pub fn new_serialized_events( - &self, - id: impl Into, - ) -> impl Iterator + '_ { - let id = id.into(); - self.events - .iter() - .enumerate() - .skip(self.last_persisted_sequence) - .map(move |(i, e)| { - let event_json = serde_json::to_value(e).expect("Could not serialize event"); - let event_type = event_json - .get("type") - .and_then(serde_json::Value::as_str) - .expect("Could not get type") - .to_owned(); - (id, (i + 1) as i32, event_type, event_json) - }) - } - - pub fn into_new_serialized_events( - self, - id: impl Into, - ) -> impl Iterator { - let id = id.into(); - self.events - .into_iter() - .enumerate() - .skip(self.last_persisted_sequence) - .map(move |(i, e)| { - let event_json = serde_json::to_value(e).expect("Could not serialize event"); - let event_type = event_json - .get("type") - .and_then(serde_json::Value::as_str) - .expect("Could not get type") - .to_owned(); - (id, (i + 1) as i32, event_type, event_json) - }) - } - - pub fn is_dirty(&self) -> bool { - self.last_persisted_sequence != self.events.len() - } - - pub async fn persist( - table_name: &str, - tx: &mut sqlx::Transaction<'_, sqlx::Postgres>, - events: impl Iterator + '_, - ) -> Result<(), sqlx::Error> { - let mut query_builder = sqlx::QueryBuilder::new(format!( - "INSERT INTO {table_name} (id, sequence, event_type, event)" - )); - query_builder.push_values(events, |mut builder, (id, sequence, event_type, event)| { - builder.push_bind(id); - builder.push_bind(sequence); - builder.push_bind(event_type); - builder.push_bind(event); - }); - let query = query_builder.build(); - query.execute(&mut **tx).await?; - Ok(()) - } - - #[cfg(test)] - pub fn last(&self, n: usize) -> &[T] { - &self.events[self.events.len() - n..] - } -} diff --git a/src/entity/mod.rs b/src/entity/mod.rs index 3641b5ad..2d1ca886 100644 --- a/src/entity/mod.rs +++ b/src/entity/mod.rs @@ -1,8 +1,6 @@ mod error; -mod event; pub use error::*; -pub use event::*; #[macro_export] macro_rules! entity_id { diff --git a/src/job/batch_signing.rs b/src/job/batch_signing.rs index 71043159..fb9ecc76 100644 --- a/src/job/batch_signing.rs +++ b/src/job/batch_signing.rs @@ -63,16 +63,18 @@ pub async fn execute( let keychain_xpubs = wallet.xpubs_for_keychains(&summary.signing_keychains); for (_, keychain_xpubs) in keychain_xpubs.into_iter() { for xpub in keychain_xpubs.into_iter() { - let account_xpub = xpubs.find_from_ref(data.account_id, xpub.id()).await?; + let account_xpub = xpubs + .find_from_ref(data.account_id, xpub.fingerprint()) + .await?; let new_session = NewSigningSession::builder() .account_id(data.account_id) .batch_id(data.batch_id) - .xpub_id(xpub.id()) + .xpub_fingerprint(xpub.fingerprint()) .unsigned_psbt(unsigned_psbt.clone()) .build() .expect("Could not build signing session"); - new_sessions.insert(account_xpub.id(), new_session); - account_xpubs.insert(account_xpub.id(), account_xpub); + new_sessions.insert(account_xpub.fingerprint(), new_session); + account_xpubs.insert(account_xpub.fingerprint(), account_xpub); } } } @@ -87,12 +89,14 @@ pub async fn execute( }; let mut any_updated = false; - for (xpub_id, session) in sessions.iter_mut().filter(|(_, s)| !s.is_completed()) { + for (xpub_fingerprint, session) in sessions.iter_mut().filter(|(_, s)| !s.is_completed()) { any_updated = true; - let account_xpub = if let Some(xpub) = account_xpub_cache.remove(xpub_id) { + let account_xpub = if let Some(xpub) = account_xpub_cache.remove(xpub_fingerprint) { xpub } else { - xpubs.find_from_ref(data.account_id, xpub_id).await? + xpubs + .find_from_ref(data.account_id, xpub_fingerprint) + .await? }; let mut client = match account_xpub .remote_signing_client(signer_encryption_config.key) diff --git a/src/job/mod.rs b/src/job/mod.rs index df386856..91d6bcbc 100644 --- a/src/job/mod.rs +++ b/src/job/mod.rs @@ -270,7 +270,7 @@ async fn process_all_payout_queues( .build() .expect("couldn't build JobExecutor") .execute(|_| async move { - for group in payout_queues.all().await? { + for group in payout_queues.list_all().await? { if let Some(delay) = group.spawn_in() { let _ = spawn_schedule_process_payout_queue( &pool, diff --git a/src/job/process_payout_queue.rs b/src/job/process_payout_queue.rs index 894cf7da..593d80a5 100644 --- a/src/job/process_payout_queue.rs +++ b/src/job/process_payout_queue.rs @@ -52,7 +52,7 @@ pub(super) async fn execute<'a>( JobError, > { let payout_queue = payout_queues - .find_by_id(data.account_id, data.payout_queue_id) + .find_by_account_id_and_id(data.account_id, data.payout_queue_id) .await?; let mut tx = pool.begin().await?; let mut unbatched_payouts = payouts @@ -134,7 +134,7 @@ pub(super) async fn execute<'a>( })); let batch_id = batch.id; - batches.create_in_tx(&mut tx, batch).await?; + batches.create_in_op(&mut tx, batch).await?; utxos .reserve_utxos_in_batch( &mut tx, @@ -191,9 +191,9 @@ pub async fn construct_psbt( span.record("payout_queue_id", tracing::field::display(queue_id)); span.record("n_unbatched_payouts", unbatched_payouts.n_payouts()); - let wallets = wallets.find_by_ids(unbatched_payouts.wallet_ids()).await?; + let wallets = wallets.find_all(&unbatched_payouts.wallet_ids()).await?; let reserved_utxos = { - let keychain_ids = wallets.values().flat_map(|w| w.keychain_ids()); + let keychain_ids = wallets.values().flat_map(|w: &Wallet| w.keychain_ids()); utxos .outpoints_bdk_should_not_select(tx, keychain_ids) .await? diff --git a/src/outbox/augmentation.rs b/src/outbox/augmentation.rs index c8906f5c..a8867959 100644 --- a/src/outbox/augmentation.rs +++ b/src/outbox/augmentation.rs @@ -46,7 +46,7 @@ impl Augmenter { } => { let address_info = self .addresses - .find_by_address(account_id, address.to_string()) + .find_by_account_id_and_address(account_id, address.to_string()) .await?; Ok(Augmentation { address: Some(AddressAugmentation { @@ -63,7 +63,10 @@ impl Augmenter { | OutboxEventPayload::PayoutCommitted { id, .. } | OutboxEventPayload::PayoutBroadcast { id, .. } | OutboxEventPayload::PayoutSettled { id, .. } => { - let payout = self.payouts.find_by_id(account_id, id).await?; + let payout = self + .payouts + .find_by_account_id_and_id(account_id, id) + .await?; let payout = self .batch_inclusion .include_estimate(account_id, payout) diff --git a/src/payout/entity.rs b/src/payout/entity.rs index 387862f3..6e4c1e48 100644 --- a/src/payout/entity.rs +++ b/src/payout/entity.rs @@ -1,15 +1,18 @@ use derive_builder::Builder; +use es_entity::*; use serde::{Deserialize, Serialize}; -use crate::{entity::*, primitives::*}; +use crate::primitives::*; use super::error::PayoutError; -#[derive(Serialize, Deserialize)] +#[derive(EsEvent, Serialize, Deserialize)] #[serde(tag = "type", rename_all = "snake_case")] +#[es_event(id = "PayoutId")] pub enum PayoutEvent { Initialized { id: PayoutId, + account_id: AccountId, wallet_id: WalletId, payout_queue_id: PayoutQueueId, profile_id: ProfileId, @@ -31,10 +34,11 @@ pub enum PayoutEvent { }, } -#[derive(Builder)] -#[builder(pattern = "owned", build_fn(error = "EntityError"))] +#[derive(EsEntity, Builder)] +#[builder(pattern = "owned", build_fn(error = "EsEntityError"))] pub struct Payout { pub id: PayoutId, + pub account_id: AccountId, pub wallet_id: WalletId, pub profile_id: ProfileId, pub payout_queue_id: PayoutQueueId, @@ -70,7 +74,7 @@ impl Payout { } pub fn is_cancelled(&self) -> bool { - for event in self.events.iter() { + for event in self.events.iter_all() { if let PayoutEvent::Cancelled { .. } = event { return true; } @@ -83,6 +87,47 @@ impl Payout { } } +impl TryFromEvents for Payout { + fn try_from_events(events: EntityEvents) -> Result { + let mut builder = PayoutBuilder::default(); + for event in events.iter_all() { + match event { + PayoutEvent::Initialized { + id, + account_id, + wallet_id, + profile_id, + payout_queue_id, + destination, + satoshis, + .. + } => { + builder = builder + .id(*id) + .account_id(*account_id) + .wallet_id(*wallet_id) + .profile_id(*profile_id) + .payout_queue_id(*payout_queue_id) + .destination(destination.clone()) + .satoshis(*satoshis); + } + + PayoutEvent::ExternalIdUpdated { external_id } => { + builder = builder.external_id(external_id.clone()); + } + PayoutEvent::MetadataUpdated { metadata } => { + builder = builder.metadata(metadata.clone()); + } + PayoutEvent::CommittedToBatch { batch_id, outpoint } => { + builder = builder.batch_id(*batch_id).outpoint(*outpoint); + } + _ => (), + } + } + builder.events(events).build() + } +} + #[derive(Debug, Builder, Clone)] pub struct NewPayout { #[builder(setter(into))] @@ -108,11 +153,14 @@ impl NewPayout { builder.external_id(id.to_string()).id(id); builder } +} - pub(super) fn initial_events(self) -> EntityEvents { - let mut events = EntityEvents::init([ +impl IntoEvents for NewPayout { + fn into_events(self) -> EntityEvents { + let mut events = vec![ PayoutEvent::Initialized { id: self.id, + account_id: self.account_id, wallet_id: self.wallet_id, payout_queue_id: self.payout_queue_id, profile_id: self.profile_id, @@ -122,52 +170,11 @@ impl NewPayout { PayoutEvent::ExternalIdUpdated { external_id: self.external_id, }, - ]); + ]; if let Some(metadata) = self.metadata { events.push(PayoutEvent::MetadataUpdated { metadata }); } - events - } -} - -impl TryFrom> for Payout { - type Error = EntityError; - - fn try_from(events: EntityEvents) -> Result { - let mut builder = PayoutBuilder::default(); - for event in events.iter() { - match event { - PayoutEvent::Initialized { - id, - wallet_id, - profile_id, - payout_queue_id, - destination, - satoshis, - .. - } => { - builder = builder - .id(*id) - .wallet_id(*wallet_id) - .profile_id(*profile_id) - .payout_queue_id(*payout_queue_id) - .destination(destination.clone()) - .satoshis(*satoshis); - } - - PayoutEvent::ExternalIdUpdated { external_id } => { - builder = builder.external_id(external_id.clone()); - } - PayoutEvent::MetadataUpdated { metadata } => { - builder = builder.metadata(metadata.clone()); - } - PayoutEvent::CommittedToBatch { batch_id, outpoint } => { - builder = builder.batch_id(*batch_id).outpoint(*outpoint); - } - _ => (), - } - } - builder.events(events).build() + EntityEvents::init(self.id, events) } } @@ -178,31 +185,36 @@ mod tests { use super::*; fn init_events() -> EntityEvents { - EntityEvents::init([ - PayoutEvent::Initialized { - id: PayoutId::new(), - wallet_id: WalletId::new(), - profile_id: ProfileId::new(), - payout_queue_id: PayoutQueueId::new(), - destination: PayoutDestination::OnchainAddress { - value: "bc1qwqdg6squsna38e46795at95yu9atm8azzmyvckulcc7kytlcckxswvvzej" - .parse::
() - .unwrap(), + let id = PayoutId::new(); + EntityEvents::init( + id, + [ + PayoutEvent::Initialized { + id: id, + account_id: AccountId::new(), + wallet_id: WalletId::new(), + profile_id: ProfileId::new(), + payout_queue_id: PayoutQueueId::new(), + destination: PayoutDestination::OnchainAddress { + value: "bc1qwqdg6squsna38e46795at95yu9atm8azzmyvckulcc7kytlcckxswvvzej" + .parse::
() + .unwrap(), + }, + satoshis: Satoshis::from(Decimal::from(21)), }, - satoshis: Satoshis::from(Decimal::from(21)), - }, - PayoutEvent::ExternalIdUpdated { - external_id: "external_id".to_string(), - }, - ]) + PayoutEvent::ExternalIdUpdated { + external_id: "external_id".to_string(), + }, + ], + ) } #[test] fn cancel_payout() { - let mut payout = Payout::try_from(init_events()).unwrap(); + let mut payout = Payout::try_from_events(init_events()).unwrap(); assert!(payout.cancel_payout(payout.profile_id, false).is_ok()); assert!(matches!( - payout.events.last(1)[0], + payout.events.iter_all().last().unwrap(), PayoutEvent::Cancelled { .. } )); } @@ -213,7 +225,7 @@ mod tests { events.push(PayoutEvent::Cancelled { executed_by: ProfileId::new(), }); - let mut payout = Payout::try_from(events).unwrap(); + let mut payout = Payout::try_from_events(events).unwrap(); let result = payout.cancel_payout(payout.profile_id, false); assert!(matches!(result, Err(PayoutError::PayoutAlreadyCancelled))); } @@ -231,7 +243,7 @@ mod tests { }, }); - let mut payout = Payout::try_from(events).unwrap(); + let mut payout = Payout::try_from_events(events).unwrap(); let result = payout.cancel_payout(payout.profile_id, false); assert!(matches!(result, Err(PayoutError::PayoutAlreadyCommitted))); @@ -250,10 +262,10 @@ mod tests { }, }); - let mut payout = Payout::try_from(events).unwrap(); + let mut payout = Payout::try_from_events(events).unwrap(); assert!(payout.cancel_payout(payout.profile_id, true).is_ok()); assert!(matches!( - payout.events.last(1)[0], + payout.events.iter_all().last().unwrap(), PayoutEvent::Cancelled { .. } )); } diff --git a/src/payout/error.rs b/src/payout/error.rs index 875d9aa3..f62e0564 100644 --- a/src/payout/error.rs +++ b/src/payout/error.rs @@ -4,20 +4,20 @@ use thiserror::Error; pub enum PayoutError { #[error("PayoutError - Sqlx: {0}")] Sqlx(sqlx::Error), - #[error("PayoutError - EntityError: {0}")] - EntityError(#[from] crate::entity::EntityError), - #[error("PayoutError - Could not find payout with id: {0}")] - PayoutIdNotFound(String), - #[error("PayoutError - External Id does not exists")] - ExternalIdNotFound, #[error("PayoutError - Payout is already committed to batch")] PayoutAlreadyCommitted, #[error("PayoutError - Payout is already cancelled")] PayoutAlreadyCancelled, #[error("PayoutError - external_id already exists")] ExternalIdAlreadyExists, + #[error("PayoutError - EsEntityError: {0}")] + EsEntityError(es_entity::EsEntityError), + #[error("PayoutError - CursorDestructureError: {0}")] + CursorDestructureError(#[from] es_entity::CursorDestructureError), } +es_entity::from_es_entity_error!(PayoutError); + impl From for PayoutError { fn from(error: sqlx::Error) -> Self { if let Some(err) = error.as_database_error() { diff --git a/src/payout/repo.rs b/src/payout/repo.rs index e6b5aaac..7937db1b 100644 --- a/src/payout/repo.rs +++ b/src/payout/repo.rs @@ -1,12 +1,26 @@ -use sqlx::{Pool, Postgres, Transaction}; +use es_entity::*; +use sqlx::{Pool, Postgres}; use tracing::instrument; use std::collections::HashMap; use super::{entity::*, error::*, unbatched::*}; -use crate::{entity::*, primitives::*}; +use crate::primitives::*; -#[derive(Debug, Clone)] +#[derive(EsRepo, Clone, Debug)] +#[es_repo( + entity = "Payout", + err = "PayoutError", + columns( + account_id(ty = "AccountId", update(persist = false)), + wallet_id(ty = "WalletId", update(persist = false)), + payout_queue_id(ty = "PayoutQueueId", update(persist = false)), + profile_id(ty = "ProfileId", update(persist = false)), + external_id(ty = "String", update(persist = false)), + batch_id(ty = "Option", create(persist = false),) + ), + tbl_prefix = "bria" +)] pub struct Payouts { pool: Pool, } @@ -16,144 +30,99 @@ impl Payouts { Self { pool: pool.clone() } } - #[instrument(name = "payouts.create", skip(self, tx))] - pub async fn create_in_tx( - &self, - tx: &mut Transaction<'_, Postgres>, - new_payout: NewPayout, - ) -> Result { - sqlx::query!( - r#"INSERT INTO bria_payouts (id, account_id, wallet_id, payout_queue_id, profile_id, external_id) - VALUES ($1, $2, $3, $4, $5, $6)"#, - new_payout.id as PayoutId, - new_payout.account_id as AccountId, - new_payout.wallet_id as WalletId, - new_payout.payout_queue_id as PayoutQueueId, - new_payout.profile_id as ProfileId, - new_payout.external_id, - ).execute(&mut **tx).await?; - let id = new_payout.id; - EntityEvents::::persist( - "bria_payout_events", - tx, - new_payout.initial_events().new_serialized_events(id), - ) - .await?; - Ok(id) - } - - #[instrument(name = "payouts.find_by_id", skip(self))] - pub async fn find_by_id( + pub async fn find_by_account_id_and_id( &self, account_id: AccountId, payout_id: PayoutId, ) -> Result { - let rows = sqlx::query!( - r#" - SELECT b.*, e.sequence, e.event - FROM bria_payouts b - JOIN bria_payout_events e ON b.id = e.id - WHERE account_id = $1 AND b.id = $2 - ORDER BY b.created_at, b.id, e.sequence"#, - account_id as AccountId, - payout_id as PayoutId, - ) - .fetch_all(&self.pool) - .await?; - - if rows.is_empty() { - return Err(PayoutError::PayoutIdNotFound(payout_id.to_string())); + let payout = self.find_by_id(payout_id).await?; + if payout.account_id != account_id { + return Err(PayoutError::EsEntityError(EsEntityError::NotFound)); } - - let mut entity_events = EntityEvents::new(); - for row in rows { - entity_events.load_event(row.sequence as usize, row.event)?; - } - Ok(Payout::try_from(entity_events)?) + Ok(payout) } #[instrument(name = "payouts.find_by_external_id", skip(self))] - pub async fn find_by_external_id( + pub async fn find_by_account_id_and_external_id( &self, account_id: AccountId, external_id: String, ) -> Result { - let rows = sqlx::query!( + let payout = es_entity::es_query!( + tbl_prefix = "bria", r#" - SELECT b.*, e.sequence, e.event - FROM bria_payouts b - JOIN bria_payout_events e ON b.id = e.id - WHERE account_id = $1 AND b.external_id = $2 - ORDER BY b.created_at, b.id, e.sequence"#, + SELECT * + FROM bria_payouts + WHERE account_id = $1 AND external_id = $2"#, account_id as AccountId, external_id ) - .fetch_all(&self.pool) + .fetch_one(self.pool()) .await?; - - if rows.is_empty() { - return Err(PayoutError::ExternalIdNotFound); - } - - let mut entity_events = EntityEvents::new(); - for row in rows { - entity_events.load_event(row.sequence as usize, row.event)?; - } - Ok(Payout::try_from(entity_events)?) + Ok(payout) } - #[instrument(name = "payouts.list_unbatched", skip(self))] + #[instrument(name = "payouts.list_unbatched", skip(self, op))] pub async fn list_unbatched( &self, - tx: &mut Transaction<'_, Postgres>, + op: &mut impl es_entity::AtomicOperation, account_id: AccountId, payout_queue_id: PayoutQueueId, ) -> Result { - let rows = sqlx::query!( - r#" - SELECT b.*, e.sequence, e.event - FROM bria_payouts b - JOIN bria_payout_events e ON b.id = e.id - WHERE b.batch_id IS NULL AND b.account_id = $1 AND b.payout_queue_id = $2 - ORDER BY b.created_at, b.id, e.sequence FOR UPDATE"#, - account_id as AccountId, - payout_queue_id as PayoutQueueId, - ) - .fetch_all(&mut **tx) - .await?; - let mut wallet_payouts = Vec::new(); - let mut entity_events = HashMap::new(); - for row in rows { - let wallet_id = WalletId::from(row.wallet_id); - let id = WalletId::from(row.id); - wallet_payouts.push((id, wallet_id)); - let events = entity_events.entry(id).or_insert_with(EntityEvents::new); - events.load_event(row.sequence as usize, row.event)?; - } - let mut payouts: HashMap> = HashMap::new(); - for (id, wallet_id) in wallet_payouts { - if let Some(events) = entity_events.remove(&id) { - payouts - .entry(wallet_id) - .or_default() - .push(UnbatchedPayout::try_from(events)?); + let mut unbatched_payouts = Vec::new(); + let mut query = es_entity::PaginatedQueryArgs:: { + first: Default::default(), + after: None, + }; + + loop { + let (id, created_at) = query + .after + .map(|c| (Some(c.id), Some(c.created_at))) + .unwrap_or((None, None)); + + let (entities, has_next_page) = es_entity::es_query!( + tbl_prefix = "bria", + r#" + SELECT * + FROM bria_payouts + WHERE batch_id is NULL AND account_id = $1 AND payout_queue_id = $2 + AND (COALESCE((created_at, id) > ($4, $3), $3 IS NULL)) + ORDER BY created_at, id + FOR UPDATE"#, + account_id as AccountId, + payout_queue_id as PayoutQueueId, + id as Option, + created_at + ) + .fetch_n(&mut *op, query.first) + .await?; + + unbatched_payouts.extend(entities); + + if !has_next_page { + break; } + let end_cursor = unbatched_payouts + .last() + .map(payout_cursor::PayoutsByCreatedAtCursor::from); + + query.after = end_cursor; } - let filtered_payouts: HashMap> = payouts + + let filtered_payouts: HashMap> = unbatched_payouts .into_iter() - .map(|(wallet_id, unbatched_payouts)| { - let filtered_unbatched_payouts = unbatched_payouts - .into_iter() - .filter(|payout| { - !payout - .events - .iter() - .any(|event| matches!(event, PayoutEvent::Cancelled { .. })) - }) - .collect(); - (wallet_id, filtered_unbatched_payouts) + .filter(|payout| { + !payout + .events + .iter_all() + .any(|event| matches!(event, PayoutEvent::Cancelled { .. })) }) - .collect(); + .filter_map(|unbatched_payout| UnbatchedPayout::try_from(unbatched_payout).ok()) + .fold(HashMap::new(), |mut map, payout| { + map.entry(payout.wallet_id).or_default().push(payout); + map + }); Ok(UnbatchedPayouts::new(filtered_payouts)) } @@ -166,43 +135,21 @@ impl Payouts { page_size: u64, ) -> Result, PayoutError> { let offset = (page - 1) * page_size; - - let rows = sqlx::query!( + let payouts = es_entity::es_query!( + tbl_prefix = "bria", r#" - WITH payouts AS ( SELECT * FROM bria_payouts WHERE account_id = $1 AND wallet_id = $2 - ORDER BY created_at DESC, id - LIMIT $3 OFFSET $4 - ) - SELECT p.*, e.sequence, e.event - FROM payouts p - JOIN bria_payout_events e ON p.id = e.id - ORDER BY p.created_at DESC, p.id, e.sequence - "#, + ORDER BY created_at DESC + OFFSET $3"#, account_id as AccountId, wallet_id as WalletId, - page_size as i64, offset as i64, ) - .fetch_all(&self.pool) + .fetch_n(self.pool(), page_size as usize) .await?; - let mut wallet_payouts = Vec::new(); - let mut entity_events = HashMap::new(); - for row in rows { - let id = WalletId::from(row.id); - wallet_payouts.push(id); - let events = entity_events.entry(id).or_insert_with(EntityEvents::new); - events.load_event(row.sequence as usize, row.event)?; - } - let mut payouts = Vec::new(); - for id in wallet_payouts { - if let Some(events) = entity_events.remove(&id) { - payouts.push(Payout::try_from(events)?); - } - } - Ok(payouts) + Ok(payouts.0) } #[instrument(name = "payouts.list_for_batch", skip(self))] @@ -211,60 +158,85 @@ impl Payouts { account_id: AccountId, batch_id: BatchId, ) -> Result>, PayoutError> { - let rows = sqlx::query!( - r#" - SELECT b.*, e.sequence, e.event - FROM bria_payouts b - JOIN bria_payout_events e ON b.id = e.id - WHERE b.account_id = $1 AND b.batch_id = $2 - ORDER BY b.created_at, b.id, e.sequence"#, - account_id as AccountId, - batch_id as BatchId, - ) - .fetch_all(&self.pool) - .await?; - let mut payout_ids = Vec::new(); - let mut entity_events = HashMap::new(); - for row in rows { - let id = PayoutId::from(row.id); - payout_ids.push(id); - let events = entity_events.entry(id).or_insert_with(EntityEvents::new); - events.load_event(row.sequence as usize, row.event)?; - } - let mut payouts: HashMap> = HashMap::new(); - for id in payout_ids { - if let Some(events) = entity_events.remove(&id) { - let payout = Payout::try_from(events)?; - payouts.entry(payout.wallet_id).or_default().push(payout); + let mut batched_payouts = Vec::new(); + let mut query = es_entity::PaginatedQueryArgs:: { + first: Default::default(), + after: None, + }; + + loop { + let (id, created_at) = query + .after + .map(|c| (Some(c.id), Some(c.created_at))) + .unwrap_or((None, None)); + + let (entities, has_next_page) = es_entity::es_query!( + tbl_prefix = "bria", + r#" + SELECT * + FROM bria_payouts + WHERE account_id = $1 AND batch_id = $2 + AND (COALESCE((created_at, id) > ($4, $3), $3 IS NULL)) + ORDER BY created_at, id"#, + account_id as AccountId, + batch_id as BatchId, + id as Option, + created_at + ) + .fetch_n(self.pool(), query.first) + .await?; + + batched_payouts.extend(entities); + + if !has_next_page { + break; } + + let end_cursor = batched_payouts + .last() + .map(payout_cursor::PayoutsByCreatedAtCursor::from); + + query.after = end_cursor; } + + let payouts: HashMap> = + batched_payouts + .into_iter() + .fold(HashMap::new(), |mut map, batched_payout| { + map.entry(batched_payout.wallet_id) + .or_default() + .push(batched_payout); + map + }); Ok(payouts) } pub async fn update_unbatched( &self, - tx: &mut Transaction<'_, Postgres>, + op: &mut impl es_entity::AtomicOperation, payouts: UnbatchedPayouts, ) -> Result<(), PayoutError> { if payouts.batch_id.is_none() || payouts.batched.is_empty() { return Ok(()); } let mut ids = Vec::new(); - EntityEvents::::persist( - "bria_payout_events", - tx, - payouts.batched.into_iter().flat_map(|p| { + let mut all_events: Vec> = payouts + .batched + .into_iter() + .map(|p| { ids.push(uuid::Uuid::from(p.id)); - p.events.into_new_serialized_events(p.id) - }), - ) - .await?; + p.events + }) + .collect(); + + self.persist_events_batch(op, &mut all_events).await?; + sqlx::query!( r#"UPDATE bria_payouts SET batch_id = $1 WHERE id = ANY($2)"#, payouts.batch_id.unwrap() as BatchId, &ids[..], ) - .execute(&mut **tx) + .execute(op.as_executor()) .await?; Ok(()) } @@ -303,52 +275,25 @@ impl Payouts { )) } - #[instrument(name = "payouts.find_by_id_for_cancellation", skip(self))] + #[instrument(name = "payouts.find_by_id_for_cancellation", skip(self, op))] pub async fn find_by_id_for_cancellation( &self, - tx: &mut Transaction<'_, Postgres>, + op: &mut impl es_entity::AtomicOperation, account_id: AccountId, payout_id: PayoutId, ) -> Result { - let rows = sqlx::query!( + let payout = es_entity::es_query!( + tbl_prefix = "bria", r#" - SELECT b.*, e.sequence, e.event - FROM bria_payouts b - JOIN bria_payout_events e ON b.id = e.id - WHERE account_id = $1 AND b.id = $2 - ORDER BY b.created_at, b.id, e.sequence - FOR UPDATE"#, + SELECT * + FROM bria_payouts + WHERE account_id = $1 AND id = $2 + FOR UPDATE"#, account_id as AccountId, payout_id as PayoutId, ) - .fetch_all(&mut **tx) + .fetch_one(op) .await?; - - if rows.is_empty() { - return Err(PayoutError::PayoutIdNotFound(payout_id.to_string())); - } - - let mut entity_events = EntityEvents::new(); - for row in rows { - entity_events.load_event(row.sequence as usize, row.event)?; - } - Ok(Payout::try_from(entity_events)?) - } - - pub async fn update( - &self, - tx: &mut Transaction<'_, Postgres>, - payout: Payout, - ) -> Result<(), PayoutError> { - if !payout.events.is_dirty() { - return Ok(()); - } - EntityEvents::::persist( - "bria_payout_events", - tx, - payout.events.new_serialized_events(payout.id), - ) - .await?; - Ok(()) + Ok(payout) } } diff --git a/src/payout/unbatched.rs b/src/payout/unbatched.rs index e3aa9e2f..db4284a0 100644 --- a/src/payout/unbatched.rs +++ b/src/payout/unbatched.rs @@ -1,9 +1,10 @@ use derive_builder::Builder; -use std::collections::{HashMap, HashSet}; +use es_entity::*; +use std::collections::HashMap; -use super::entity::PayoutEvent; -use crate::{entity::*, primitives::*}; +use super::entity::{Payout, PayoutEvent}; +use crate::primitives::*; pub struct UnbatchedPayouts { inner: HashMap>, @@ -24,7 +25,7 @@ impl UnbatchedPayouts { } } - pub fn wallet_ids(&self) -> HashSet { + pub fn wallet_ids(&self) -> Vec { std::iter::once(self.simulated_payout.as_ref()) .filter_map(|p| p.map(|(id, _)| id)) .chain(self.inner.keys()) @@ -90,7 +91,7 @@ impl UnbatchedPayouts { } #[derive(Builder)] -#[builder(pattern = "owned", build_fn(error = "EntityError"))] +#[builder(pattern = "owned", build_fn(error = "EsEntityError"))] pub struct UnbatchedPayout { pub id: PayoutId, pub wallet_id: WalletId, @@ -107,12 +108,11 @@ impl UnbatchedPayout { } } -impl TryFrom> for UnbatchedPayout { - type Error = EntityError; - - fn try_from(events: EntityEvents) -> Result { +impl TryFrom for UnbatchedPayout { + type Error = EsEntityError; + fn try_from(payout: Payout) -> Result { let mut builder = UnbatchedPayoutBuilder::default(); - for event in events.iter() { + for event in payout.events.iter_all() { if let PayoutEvent::Initialized { id, wallet_id, @@ -128,7 +128,7 @@ impl TryFrom> for UnbatchedPayout { .satoshis(*satoshis); } } - builder.events(events).build() + builder.events(payout.events).build() } } diff --git a/src/payout_queue/entity.rs b/src/payout_queue/entity.rs index 5dc2d551..e29d1107 100644 --- a/src/payout_queue/entity.rs +++ b/src/payout_queue/entity.rs @@ -1,12 +1,16 @@ use derive_builder::Builder; +use es_entity::*; use serde::{Deserialize, Serialize}; + use std::time::Duration; +use crate::primitives::*; + use super::config::*; -use crate::{entity::*, primitives::*}; -#[derive(Serialize, Deserialize)] +#[derive(EsEvent, Serialize, Deserialize)] #[serde(tag = "type", rename_all = "snake_case")] +#[es_event(id = "PayoutQueueId")] pub enum PayoutQueueEvent { Initialized { id: PayoutQueueId, @@ -23,14 +27,13 @@ pub enum PayoutQueueEvent { }, } -#[derive(Builder)] -#[builder(pattern = "owned", build_fn(error = "EntityError"))] +#[derive(EsEntity, Builder)] +#[builder(pattern = "owned", build_fn(error = "EsEntityError"))] pub struct PayoutQueue { pub id: PayoutQueueId, pub account_id: AccountId, pub name: String, pub config: PayoutQueueConfig, - pub(super) events: EntityEvents, } @@ -45,7 +48,7 @@ impl PayoutQueue { pub fn description(&self) -> Option { let mut ret = None; - for event in self.events.iter() { + for event in self.events.iter_all() { if let PayoutQueueEvent::DescriptionUpdated { description } = event { ret = Some(description.as_str()); } @@ -67,7 +70,28 @@ impl PayoutQueue { } } -#[derive(Debug, Builder, Clone)] +impl TryFromEvents for PayoutQueue { + fn try_from_events(events: EntityEvents) -> Result { + let mut builder = PayoutQueueBuilder::default(); + for event in events.iter_all() { + match event { + PayoutQueueEvent::Initialized { id, account_id } => { + builder = builder.id(*id).account_id(*account_id); + } + PayoutQueueEvent::NameUpdated { name } => { + builder = builder.name(name.clone()); + } + PayoutQueueEvent::ConfigUpdated { config } => { + builder = builder.config(config.clone()); + } + _ => (), + } + } + builder.events(events).build() + } +} + +#[derive(Debug, Builder)] pub struct NewPayoutQueue { #[builder(setter(into))] pub(super) id: PayoutQueueId, @@ -79,16 +103,17 @@ pub struct NewPayoutQueue { #[builder(default)] pub(super) config: PayoutQueueConfig, } - impl NewPayoutQueue { pub fn builder() -> NewPayoutQueueBuilder { let mut builder = NewPayoutQueueBuilder::default(); builder.id(PayoutQueueId::new()); builder } +} - pub(super) fn initial_events(self) -> EntityEvents { - let mut events = EntityEvents::init([ +impl IntoEvents for NewPayoutQueue { + fn into_events(self) -> EntityEvents { + let mut events = vec![ PayoutQueueEvent::Initialized { id: self.id, account_id: self.account_id, @@ -97,34 +122,10 @@ impl NewPayoutQueue { PayoutQueueEvent::ConfigUpdated { config: self.config, }, - ]); + ]; if let Some(description) = self.description { events.push(PayoutQueueEvent::DescriptionUpdated { description }); } - events - } -} - -impl TryFrom> for PayoutQueue { - type Error = EntityError; - - fn try_from(events: EntityEvents) -> Result { - let mut builder = PayoutQueueBuilder::default(); - use PayoutQueueEvent::*; - for event in events.iter() { - match event { - Initialized { id, account_id } => { - builder = builder.id(*id).account_id(*account_id); - } - NameUpdated { name } => { - builder = builder.name(name.clone()); - } - ConfigUpdated { config } => { - builder = builder.config(config.clone()); - } - _ => (), - } - } - builder.events(events).build() + EntityEvents::init(self.id, events) } } diff --git a/src/payout_queue/error.rs b/src/payout_queue/error.rs index 85adf9ca..6d5d283a 100644 --- a/src/payout_queue/error.rs +++ b/src/payout_queue/error.rs @@ -2,12 +2,12 @@ use thiserror::Error; #[derive(Error, Debug)] pub enum PayoutQueueError { - #[error("PayoutQueueError - Could not find payout queue with name: {0}")] - PayoutQueueNameNotFound(String), - #[error("PayoutQueueError - Could not find payout queue with id: {0}")] - PayoutQueueIdNotFound(String), #[error("PayoutQueueError - Sqlx: {0}")] Sqlx(#[from] sqlx::Error), - #[error("PayoutQueueError - EntityError: {0}")] - EntityError(#[from] crate::entity::EntityError), + #[error("PayoutQueueError - EsEntityError: {0}")] + EsEntityError(es_entity::EsEntityError), + #[error("PayoutQueueError - CursorDestructureError: {0}")] + CursorDestructureError(#[from] es_entity::CursorDestructureError), } + +es_entity::from_es_entity_error!(PayoutQueueError); diff --git a/src/payout_queue/repo.rs b/src/payout_queue/repo.rs index b5f7f29b..11595b29 100644 --- a/src/payout_queue/repo.rs +++ b/src/payout_queue/repo.rs @@ -1,12 +1,17 @@ +use es_entity::*; use sqlx::{Pool, Postgres}; -use tracing::instrument; - -use std::collections::HashMap; use super::{entity::*, error::PayoutQueueError}; -use crate::{entity::*, primitives::*}; -#[derive(Debug, Clone)] +use crate::primitives::*; + +#[derive(EsRepo, Clone, Debug)] +#[es_repo( + entity = "PayoutQueue", + err = "PayoutQueueError", + columns(name(ty = "String"), account_id(ty = "AccountId", list_for)), + tbl_prefix = "bria" +)] pub struct PayoutQueues { pool: Pool, } @@ -16,146 +21,67 @@ impl PayoutQueues { Self { pool: pool.clone() } } - #[instrument(name = "payout_queues.create", skip(self))] - pub async fn create(&self, queue: NewPayoutQueue) -> Result { - let mut tx = self.pool.begin().await?; - sqlx::query!( - r#" - INSERT INTO bria_payout_queues (id, account_id, name) - VALUES ($1, $2, $3) - "#, - queue.id as PayoutQueueId, - queue.account_id as AccountId, - queue.name, - ) - .execute(&mut *tx) - .await?; - let id = queue.id; - EntityEvents::::persist( - "bria_payout_queue_events", - &mut tx, - queue.initial_events().new_serialized_events(id), - ) - .await?; - tx.commit().await?; - Ok(id) - } - - pub async fn find_by_name( + pub async fn find_by_account_id_and_id( &self, account_id: AccountId, - name: String, + id: PayoutQueueId, ) -> Result { - let rows = sqlx::query!( - r#" - SELECT b.*, e.sequence, e.event - FROM bria_payout_queues b - JOIN bria_payout_queue_events e ON b.id = e.id - WHERE account_id = $1 AND name = $2 - ORDER BY e.sequence"#, - account_id as AccountId, - name - ) - .fetch_all(&self.pool) - .await?; - if rows.is_empty() { - return Err(PayoutQueueError::PayoutQueueNameNotFound(name)); - } - let mut events = EntityEvents::new(); - for row in rows { - events.load_event(row.sequence as usize, row.event)?; + let payout_queue = self.find_by_id(id).await?; + if payout_queue.account_id != account_id { + return Err(PayoutQueueError::EsEntityError(EsEntityError::NotFound)); } - Ok(PayoutQueue::try_from(events)?) + Ok(payout_queue) } - pub async fn find_by_id( + pub async fn find_by_account_id_and_name( &self, account_id: AccountId, - id: PayoutQueueId, + name: String, ) -> Result { - let rows = sqlx::query!( + let payout_queue = es_entity::es_query!( + tbl_prefix = "bria", r#" - SELECT b.*, e.sequence, e.event - FROM bria_payout_queues b - JOIN bria_payout_queue_events e ON b.id = e.id - WHERE account_id = $1 AND b.id = $2 - ORDER BY e.sequence"#, + SELECT * + FROM bria_payout_queues + WHERE account_id = $1 and name = $2"#, account_id as AccountId, - id as PayoutQueueId, + name ) - .fetch_all(&self.pool) + .fetch_one(self.pool()) .await?; - if rows.is_empty() { - return Err(PayoutQueueError::PayoutQueueIdNotFound(id.to_string())); - } - let mut events = EntityEvents::new(); - for row in rows { - events.load_event(row.sequence as usize, row.event)?; - } - Ok(PayoutQueue::try_from(events)?) + Ok(payout_queue) } - pub async fn list_by_account_id( + + pub async fn list_for_account_id( &self, account_id: AccountId, ) -> Result, PayoutQueueError> { - let rows = sqlx::query!( - r#" - SELECT b.*, e.sequence, e.event - FROM bria_payout_queues b - JOIN bria_payout_queue_events e ON b.id = e.id - WHERE account_id = $1 - ORDER BY b.id, e.sequence"#, - account_id as AccountId, - ) - .fetch_all(&self.pool) - .await?; - let mut entity_events = HashMap::new(); - for row in rows { - let id = PayoutQueueId::from(row.id); - let events = entity_events.entry(id).or_insert_with(EntityEvents::new); - events.load_event(row.sequence as usize, row.event)?; - } - Ok(entity_events - .into_values() - .map(PayoutQueue::try_from) - .collect::, _>>()?) - } + let mut queues = Vec::new(); + let mut next = Some(PaginatedQueryArgs::default()); - pub async fn all(&self) -> Result, PayoutQueueError> { - let rows = sqlx::query!( - r#" - SELECT b.*, e.sequence, e.event - FROM bria_payout_queues b - JOIN bria_payout_queue_events e ON b.id = e.id - ORDER BY b.id, e.sequence"#, - ) - .fetch_all(&self.pool) - .await?; - let mut entity_events = HashMap::new(); - for row in rows { - let id = PayoutQueueId::from(row.id); - let events = entity_events.entry(id).or_insert_with(EntityEvents::new); - events.load_event(row.sequence as usize, row.event)?; + while let Some(query) = next.take() { + let mut ret = self + .list_for_account_id_by_created_at(account_id, query, Default::default()) + .await?; + + queues.append(&mut ret.entities); + next = ret.into_next_query(); } - Ok(entity_events - .into_values() - .map(PayoutQueue::try_from) - .collect::, _>>()?) + + Ok(queues) } - pub async fn update(&self, payout_queue: PayoutQueue) -> Result<(), PayoutQueueError> { - if !payout_queue.events.is_dirty() { - return Ok(()); + pub async fn list_all(&self) -> Result, PayoutQueueError> { + let mut queues = Vec::new(); + let mut next = Some(PaginatedQueryArgs::default()); + + while let Some(query) = next.take() { + let mut ret = self.list_by_id(query, Default::default()).await?; + + queues.append(&mut ret.entities); + next = ret.into_next_query(); } - let mut tx = self.pool.begin().await?; - EntityEvents::::persist( - "bria_payout_queue_events", - &mut tx, - payout_queue.events.new_serialized_events(payout_queue.id), - ) - .await?; - tx.commit().await?; - Ok(()) + Ok(queues) } } diff --git a/src/primitives/mod.rs b/src/primitives/mod.rs index eec92ad9..eb85c657 100644 --- a/src/primitives/mod.rs +++ b/src/primitives/mod.rs @@ -21,14 +21,11 @@ impl From for LedgerJournalId { Self::from(uuid::Uuid::from(id)) } } -crate::entity_id! { ProfileId } + +es_entity::entity_id! { ProfileId, PayoutQueueId, WalletId, SigningSessionId, PayoutId } crate::entity_id! { ProfileApiKeyId } -crate::entity_id! { SigningSessionId } crate::entity_id! { KeychainId } crate::entity_id! { SignerId } -crate::entity_id! { WalletId } -crate::entity_id! { PayoutQueueId } -crate::entity_id! { PayoutId } impl From for LedgerTransactionId { fn from(id: PayoutId) -> Self { @@ -46,15 +43,15 @@ crate::entity_id! { OutboxEventId } #[derive(Debug, Clone, Hash, PartialEq, Eq, Copy, Serialize, Deserialize)] #[serde(transparent)] -pub struct XPubId(bitcoin::Fingerprint); +pub struct XPubFingerprint(bitcoin::Fingerprint); -impl From for XPubId { +impl From for XPubFingerprint { fn from(fp: bitcoin::Fingerprint) -> Self { Self(fp) } } -impl std::str::FromStr for XPubId { +impl std::str::FromStr for XPubFingerprint { type Err = ::Err; fn from_str(s: &str) -> Result { @@ -63,13 +60,13 @@ impl std::str::FromStr for XPubId { } } -impl fmt::Display for XPubId { +impl fmt::Display for XPubFingerprint { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.0.fmt(f) } } -impl std::ops::Deref for XPubId { +impl std::ops::Deref for XPubFingerprint { type Target = bitcoin::Fingerprint; fn deref(&self) -> &Self::Target { diff --git a/src/profile/entity.rs b/src/profile/entity.rs index 35fcbd0d..fc8ffdb5 100644 --- a/src/profile/entity.rs +++ b/src/profile/entity.rs @@ -1,10 +1,12 @@ use derive_builder::Builder; +use es_entity::*; use serde::{Deserialize, Serialize}; -use crate::{entity::*, primitives::*}; +use crate::primitives::*; -#[derive(Debug, Serialize, Deserialize)] +#[derive(EsEvent, Debug, Serialize, Deserialize)] #[serde(tag = "type", rename_all = "snake_case")] +#[es_event(id = "ProfileId")] pub enum ProfileEvent { Initialized { id: ProfileId, @@ -19,18 +21,28 @@ pub enum ProfileEvent { SpendingPolicyRemoved {}, } -#[derive(Debug, Builder)] -#[builder(pattern = "owned", build_fn(error = "EntityError"))] +#[derive(EsEntity, Builder)] +#[builder(pattern = "owned", build_fn(error = "EsEntityError"))] pub struct Profile { pub id: ProfileId, pub account_id: AccountId, pub name: String, #[builder(default)] pub spending_policy: Option, - pub(super) events: EntityEvents, } +impl std::fmt::Debug for Profile { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("Profile") + .field("id", &self.id) + .field("account_id", &self.account_id) + .field("name", &self.name) + .field("spending_policy", &self.spending_policy) + .finish() + } +} + impl Profile { pub fn update_spending_policy(&mut self, policy: Option) { if self.spending_policy != policy { @@ -60,6 +72,26 @@ impl Profile { } } +impl TryFromEvents for Profile { + fn try_from_events(events: EntityEvents) -> Result { + let mut builder = ProfileBuilder::default(); + for event in events.iter_all() { + match event { + ProfileEvent::Initialized { id, account_id } => { + builder = builder.id(*id).account_id(*account_id); + } + ProfileEvent::NameUpdated { name } => { + builder = builder.name(name.clone()); + } + ProfileEvent::SpendingPolicyUpdated { spending_policy } => { + builder = builder.spending_policy(Some(spending_policy.clone())); + } + ProfileEvent::SpendingPolicyRemoved {} => builder = builder.spending_policy(None), + } + } + builder.events(events).build() + } +} #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct SpendingPolicy { pub allowed_payout_addresses: Vec
, @@ -104,42 +136,21 @@ impl NewProfile { builder.id(ProfileId::new()); builder } +} - pub(super) fn initial_events(self) -> EntityEvents { - let mut events = EntityEvents::init([ +impl IntoEvents for NewProfile { + fn into_events(self) -> EntityEvents { + let mut events = vec![ ProfileEvent::Initialized { id: self.id, account_id: self.account_id, }, ProfileEvent::NameUpdated { name: self.name }, - ]); + ]; if let Some(spending_policy) = self.spending_policy { events.push(ProfileEvent::SpendingPolicyUpdated { spending_policy }); } - events - } -} - -impl TryFrom> for Profile { - type Error = EntityError; - - fn try_from(events: EntityEvents) -> Result { - let mut builder = ProfileBuilder::default(); - for event in events.iter() { - match event { - ProfileEvent::Initialized { id, account_id } => { - builder = builder.id(*id).account_id(*account_id) - } - ProfileEvent::NameUpdated { name } => { - builder = builder.name(name.clone()); - } - ProfileEvent::SpendingPolicyUpdated { spending_policy } => { - builder = builder.spending_policy(Some(spending_policy.clone())); - } - ProfileEvent::SpendingPolicyRemoved {} => builder = builder.spending_policy(None), - } - } - builder.events(events).build() + EntityEvents::init(self.id, events) } } diff --git a/src/profile/error.rs b/src/profile/error.rs index 2642b546..1f5c78d4 100644 --- a/src/profile/error.rs +++ b/src/profile/error.rs @@ -1,17 +1,15 @@ use thiserror::Error; -use crate::primitives::ProfileId; - #[derive(Error, Debug)] pub enum ProfileError { #[error("ProfileError - Api key does not exist")] ProfileKeyNotFound, - #[error("ProfileError - Could not find profile with name: {0}")] - ProfileNameNotFound(String), - #[error("ProfileError - Could not find profile with id: {0}")] - ProfileIdNotFound(ProfileId), #[error("ProfileError - Sqlx: {0}")] Sqlx(#[from] sqlx::Error), - #[error("ProfileError - EntityError: {0}")] - EntityError(#[from] crate::entity::EntityError), + #[error("ProfileError - EsEntityError: {0}")] + EsEntityError(es_entity::EsEntityError), + #[error("ProfileError - CursorDestructureError: {0}")] + CursorDestructureError(#[from] es_entity::CursorDestructureError), } + +es_entity::from_es_entity_error!(ProfileError); diff --git a/src/profile/migration.rs b/src/profile/migration.rs deleted file mode 100644 index cf59d1b5..00000000 --- a/src/profile/migration.rs +++ /dev/null @@ -1,34 +0,0 @@ -use sqlx::{Pool, Postgres}; - -use super::{entity::*, error::ProfileError}; - -pub async fn profile_event_migration(pool: &Pool) -> Result<(), ProfileError> { - let res = sqlx::query!("SELECT count(*) FROM bria_profile_events") - .fetch_one(pool) - .await?; - - if res.count.unwrap_or(0) == 0 { - let records = sqlx::query!(r#"SELECT id, account_id, name FROM bria_profiles"#,) - .fetch_all(pool) - .await?; - - let mut tx = pool.begin().await?; - for record in records.into_iter() { - let new_profile = NewProfile::builder() - .id(record.id) - .account_id(record.account_id) - .name(record.name) - .build() - .expect("Failed to build profile"); - let id = new_profile.id; - crate::entity::EntityEvents::::persist( - "bria_profile_events", - &mut tx, - new_profile.initial_events().new_serialized_events(id), - ) - .await?; - } - tx.commit().await?; - } - Ok(()) -} diff --git a/src/profile/mod.rs b/src/profile/mod.rs index edd5a0ce..a22a438b 100644 --- a/src/profile/mod.rs +++ b/src/profile/mod.rs @@ -1,6 +1,5 @@ mod entity; pub mod error; -pub mod migration; mod repo; pub use entity::*; diff --git a/src/profile/repo.rs b/src/profile/repo.rs index 8191e788..7abf89de 100644 --- a/src/profile/repo.rs +++ b/src/profile/repo.rs @@ -1,11 +1,21 @@ +use es_entity::*; use rand::distributions::{Alphanumeric, DistString}; -use sqlx::{Pool, Postgres, Transaction}; -use std::collections::HashMap; +use sqlx::{Pool, Postgres}; use uuid::Uuid; use super::{entity::*, error::ProfileError}; -use crate::{dev_constants, entity::*, primitives::*}; +use crate::{dev_constants, primitives::*}; +#[derive(EsRepo)] +#[es_repo( + entity = "Profile", + err = "ProfileError", + columns( + name(ty = "String"), + account_id(ty = "AccountId", list_for, update(persist = false)) + ), + tbl_prefix = "bria" +)] pub struct Profiles { pool: Pool, } @@ -15,120 +25,58 @@ impl Profiles { Self { pool: pool.clone() } } - pub async fn create_in_tx( - &self, - tx: &mut Transaction<'_, Postgres>, - profile: NewProfile, - ) -> Result { - let id = profile.id; - sqlx::query!( - r#"INSERT INTO bria_profiles (id, account_id, name) - VALUES ($1, $2, $3)"#, - profile.id as ProfileId, - profile.account_id as AccountId, - profile.name, - ) - .execute(&mut **tx) - .await?; - let events = profile.initial_events(); - EntityEvents::::persist( - "bria_profile_events", - &mut *tx, - events.new_serialized_events(id), - ) - .await?; - let res = Profile::try_from(events)?; - Ok(res) - } - pub async fn list_for_account( &self, account_id: AccountId, ) -> Result, ProfileError> { - let rows = sqlx::query!( - r#"SELECT p.id, e.sequence, e.event_type, e.event - FROM bria_profiles p - JOIN bria_profile_events e ON p.id = e.id - WHERE p.account_id = $1 - ORDER BY p.id, sequence"#, - account_id as AccountId - ) - .fetch_all(&self.pool) - .await?; - let mut entity_events = HashMap::new(); - for row in rows { - let id = SigningSessionId::from(row.id); - let events = entity_events.entry(id).or_insert_with(EntityEvents::new); - events.load_event(row.sequence as usize, row.event)?; - } let mut profiles = Vec::new(); - for (_, events) in entity_events { - let profile = Profile::try_from(events)?; - profiles.push(profile); + let mut next = Some(PaginatedQueryArgs::default()); + while let Some(query) = next.take() { + let mut res = self + .list_for_account_id_by_id(account_id, query, Default::default()) + .await?; + + profiles.append(&mut res.entities); + next = res.into_next_query(); } Ok(profiles) } - pub async fn find_by_id( + pub async fn find_by_account_id_and_id( &self, account_id: AccountId, id: ProfileId, ) -> Result { - let rows = sqlx::query!( - r#"SELECT p.id, e.sequence, e.event_type, e.event - FROM bria_profiles p - JOIN bria_profile_events e ON p.id = e.id - WHERE p.account_id = $1 AND p.id = $2 - ORDER BY p.id, sequence"#, - account_id as AccountId, - id as ProfileId - ) - .fetch_all(&self.pool) - .await?; - - if !rows.is_empty() { - let mut events = EntityEvents::new(); - for row in rows { - events.load_event(row.sequence as usize, row.event)?; - } - Ok(Profile::try_from(events)?) - } else { - Err(ProfileError::ProfileIdNotFound(id)) + let profile = self.find_by_id(id).await?; + if profile.account_id != account_id { + return Err(ProfileError::EsEntityError(EsEntityError::NotFound)); } + Ok(profile) } - pub async fn find_by_name( + pub async fn find_by_account_id_and_name( &self, account_id: AccountId, name: String, ) -> Result { - let rows = sqlx::query!( - r#"SELECT p.id, e.sequence, e.event_type, e.event - FROM bria_profiles p - JOIN bria_profile_events e ON p.id = e.id - WHERE p.account_id = $1 AND p.name = $2 - ORDER BY p.id, sequence"#, + let profile = es_entity::es_query!( + tbl_prefix = "bria", + r#" + SELECT * + FROM bria_profiles + WHERE account_id = $1 and name = $2"#, account_id as AccountId, name ) - .fetch_all(&self.pool) + .fetch_one(self.pool()) .await?; - - if !rows.is_empty() { - let mut events = EntityEvents::new(); - for row in rows { - events.load_event(row.sequence as usize, row.event)?; - } - Ok(Profile::try_from(events)?) - } else { - Err(ProfileError::ProfileNameNotFound(name)) - } + Ok(profile) } - pub async fn create_key_for_profile_in_tx( + pub async fn create_key_for_profile_in_op( &self, - tx: &mut sqlx::Transaction<'_, Postgres>, + op: &mut impl es_entity::AtomicOperation, profile: Profile, dev: bool, ) -> Result { @@ -144,7 +92,7 @@ impl Profiles { key, Uuid::from(profile.id), ) - .fetch_one(&mut **tx) + .fetch_one(op.as_executor()) .await?; Ok(ProfileApiKey { key, @@ -168,38 +116,10 @@ impl Profiles { .await?; if let Some(record) = record { - let rows = sqlx::query!( - r#"SELECT sequence, event_type, event FROM bria_profile_events - WHERE id = $1 - ORDER BY sequence"#, - record.id - ) - .fetch_all(&mut *tx) - .await?; - let mut events = EntityEvents::new(); - for row in rows { - events.load_event(row.sequence as usize, row.event)?; - } - Ok(Profile::try_from(events)?) + let profile = self.find_by_id(ProfileId::from(record.id)).await; + profile } else { Err(ProfileError::ProfileKeyNotFound) } } - - pub async fn update( - &self, - tx: &mut Transaction<'_, Postgres>, - profile: Profile, - ) -> Result<(), ProfileError> { - if !profile.events.is_dirty() { - return Ok(()); - } - EntityEvents::::persist( - "bria_profile_events", - tx, - profile.events.new_serialized_events(profile.id), - ) - .await?; - Ok(()) - } } diff --git a/src/signing_session/entity.rs b/src/signing_session/entity.rs index 1add14a8..94eca968 100644 --- a/src/signing_session/entity.rs +++ b/src/signing_session/entity.rs @@ -1,21 +1,22 @@ use derive_builder::Builder; +use es_entity::*; use serde::{Deserialize, Serialize}; use thiserror::Error; use std::collections::HashMap; use crate::{ - entity::*, primitives::{bitcoin::psbt, *}, xpub::SigningClientError, }; -#[derive(Debug, Serialize, Deserialize)] +#[derive(EsEvent, Debug, Serialize, Deserialize, Clone)] #[serde(tag = "type", rename_all = "snake_case")] +#[es_event(id = "SigningSessionId")] pub enum SigningSessionEvent { Initialized { id: SigningSessionId, - xpub_id: XPubId, + xpub_id: XPubFingerprint, account_id: AccountId, batch_id: BatchId, unsigned_psbt: psbt::PartiallySignedTransaction, @@ -38,13 +39,13 @@ pub enum SigningSessionState { Complete, } -#[derive(Builder)] -#[builder(pattern = "owned", build_fn(error = "EntityError"))] +#[derive(EsEntity, Builder)] +#[builder(pattern = "owned", build_fn(error = "EsEntityError"))] pub struct SigningSession { pub id: SigningSessionId, pub account_id: AccountId, pub batch_id: BatchId, - pub xpub_id: XPubId, + pub xpub_fingerprint: XPubFingerprint, pub unsigned_psbt: psbt::PartiallySignedTransaction, pub(super) events: EntityEvents, } @@ -72,7 +73,7 @@ impl SigningSession { pub fn signed_psbt(&self) -> Option<&psbt::PartiallySignedTransaction> { let mut ret = None; - for event in self.events.iter() { + for event in self.events.iter_all() { match event { SigningSessionEvent::RemoteSigningCompleted { signed_psbt } | SigningSessionEvent::ExternallySignedPsbtSubmitted { signed_psbt } => { @@ -86,15 +87,10 @@ impl SigningSession { pub fn failure_reason(&self) -> Option<&SigningFailureReason> { let mut ret = None; - for event in self.events.iter() { - if let SigningSessionEvent::SigningAttemptFailed { reason } = event { - ret = Some(reason); - } + for event in self.events.iter_all() { ret = match event { SigningSessionEvent::SigningAttemptFailed { reason } => Some(reason), - SigningSessionEvent::RemoteSigningCompleted { .. } => None, - SigningSessionEvent::ExternallySignedPsbtSubmitted { .. } => None, - _ => ret, + _ => None, }; } ret @@ -102,7 +98,7 @@ impl SigningSession { pub fn state(&self) -> SigningSessionState { let mut ret = SigningSessionState::Initialized; - for event in self.events.iter() { + for event in self.events.iter_all() { ret = match event { SigningSessionEvent::SigningAttemptFailed { .. } => SigningSessionState::Failed, SigningSessionEvent::RemoteSigningCompleted { .. } => SigningSessionState::Complete, @@ -116,7 +112,7 @@ impl SigningSession { } } -#[derive(Error, Debug, Serialize, Deserialize)] +#[derive(Error, Debug, Serialize, Deserialize, Clone)] #[serde(rename_all = "snake_case")] pub enum SigningFailureReason { #[error("SignerConfigMissing")] @@ -134,7 +130,7 @@ impl From<&SigningClientError> for SigningFailureReason { } pub struct BatchSigningSession { - pub xpub_sessions: HashMap, + pub xpub_sessions: HashMap, } #[derive(Builder, Clone, Debug)] @@ -143,7 +139,7 @@ pub struct NewSigningSession { pub(super) id: SigningSessionId, pub(super) account_id: AccountId, pub(super) batch_id: BatchId, - pub(super) xpub_id: XPubId, + pub(super) xpub_fingerprint: XPubFingerprint, unsigned_psbt: psbt::PartiallySignedTransaction, } @@ -153,24 +149,25 @@ impl NewSigningSession { builder.id(SigningSessionId::new()); builder } +} - pub(super) fn initial_events(self) -> EntityEvents { - EntityEvents::init([SigningSessionEvent::Initialized { +impl IntoEvents for NewSigningSession { + fn into_events(self) -> EntityEvents { + let events = vec![SigningSessionEvent::Initialized { id: self.id, account_id: self.account_id, batch_id: self.batch_id, - xpub_id: self.xpub_id, + xpub_id: self.xpub_fingerprint, unsigned_psbt: self.unsigned_psbt, - }]) + }]; + EntityEvents::init(self.id, events) } } -impl TryFrom> for SigningSession { - type Error = EntityError; - - fn try_from(events: EntityEvents) -> Result { +impl TryFromEvents for SigningSession { + fn try_from_events(events: EntityEvents) -> Result { let mut builder = SigningSessionBuilder::default(); - for event in events.iter() { + for event in events.iter_all() { if let SigningSessionEvent::Initialized { id, account_id, @@ -183,7 +180,7 @@ impl TryFrom> for SigningSession { .id(*id) .account_id(*account_id) .batch_id(*batch_id) - .xpub_id(*xpub_id) + .xpub_fingerprint(*xpub_id) .unsigned_psbt(unsigned_psbt.clone()); } } diff --git a/src/signing_session/error.rs b/src/signing_session/error.rs index 8ba9ca44..f130bb96 100644 --- a/src/signing_session/error.rs +++ b/src/signing_session/error.rs @@ -4,6 +4,9 @@ use thiserror::Error; pub enum SigningSessionError { #[error("SigningSessionError - Sqlx: {0}")] Sqlx(#[from] sqlx::Error), - #[error("SigningSessionError - EntityError: {0}")] - EntityError(#[from] crate::entity::EntityError), + #[error("SigningSessionError - EsEntityError: {0})")] + EsEntityError(es_entity::EsEntityError), + #[error("SigningSessionError - CursorDestructureError: {0}")] + CursorDestructureError(#[from] es_entity::CursorDestructureError), } +es_entity::from_es_entity_error!(SigningSessionError); diff --git a/src/signing_session/repo.rs b/src/signing_session/repo.rs index a3728532..6e2c752f 100644 --- a/src/signing_session/repo.rs +++ b/src/signing_session/repo.rs @@ -1,12 +1,22 @@ -use sqlx::{Pool, Postgres, QueryBuilder, Transaction}; +use es_entity::*; +use sqlx::{Pool, Postgres}; use uuid::Uuid; -use std::collections::HashMap; - use super::{entity::*, error::SigningSessionError}; -use crate::{entity::EntityEvents, primitives::*}; +use crate::primitives::*; +use std::collections::HashMap; -#[derive(Clone)] +#[derive(EsRepo, Clone)] +#[es_repo( + entity = "SigningSession", + err = "SigningSessionError", + columns( + batch_id(ty = "BatchId", update(persist = false)), + account_id(ty = "AccountId", update(persist = false)), + xpub_fingerprint(ty = "XPubFingerprint", update(persist = false)) + ), + tbl_prefix = "bria" +)] pub struct SigningSessions { pool: Pool, } @@ -18,60 +28,28 @@ impl SigningSessions { pub async fn persist_sessions( &self, - sessions: HashMap, + sessions: HashMap, ) -> Result { - let mut tx = self.pool.begin().await?; - let mut query_builder: QueryBuilder = QueryBuilder::new( - r#"INSERT INTO bria_signing_sessions - (id, account_id, batch_id, xpub_fingerprint)"#, - ); - let mut account_id = None; - let mut batch_id = None; - query_builder.push_values(sessions.iter(), |mut builder, (xpub_id, session)| { - if account_id.is_none() && batch_id.is_none() { - account_id = Some(session.account_id); - batch_id = Some(session.batch_id); - } - builder.push_bind(Uuid::from(session.id)); - builder.push_bind(Uuid::from(session.account_id)); - builder.push_bind(Uuid::from(session.batch_id)); - builder.push_bind(xpub_id.as_bytes().to_owned()); - }); - let query = query_builder.build(); - query.execute(&mut *tx).await?; - EntityEvents::::persist( - "bria_signing_session_events", - &mut tx, - sessions.into_values().flat_map(|session| { - let id = session.id; - session.initial_events().into_new_serialized_events(id) - }), - ) - .await?; - tx.commit().await?; - if let (Some(account_id), Some(batch_id)) = (account_id, batch_id) { - Ok(self - .list_for_batch(account_id, batch_id) - .await? - .expect("New session not found")) - } else { - unreachable!() + let signing_sessions = self.create_all(sessions.into_values().collect()).await?; + + let mut xpub_sessions = HashMap::new(); + for session in signing_sessions { + xpub_sessions.insert(session.xpub_fingerprint, session); } + + Ok(BatchSigningSession { xpub_sessions }) } pub async fn update_sessions( &self, - tx: &mut Transaction<'_, Postgres>, - sessions: &HashMap, + op: &mut impl es_entity::AtomicOperation, + sessions: &HashMap, ) -> Result<(), SigningSessionError> { - EntityEvents::::persist( - "bria_signing_session_events", - tx, - sessions - .values() - .flat_map(|session| session.events.new_serialized_events(session.id)), - ) - .await?; + let mut events: Vec> = sessions + .values() + .map(|session| session.events.clone()) + .collect(); + self.persist_events_batch(op, &mut events).await?; Ok(()) } @@ -80,31 +58,52 @@ impl SigningSessions { account_id: AccountId, batch_id: BatchId, ) -> Result, SigningSessionError> { - let entity_events = { - let rows = sqlx::query!( + let mut signing_sessions = Vec::new(); + let mut query = es_entity::PaginatedQueryArgs::< + signing_session_cursor::SigningSessionsByCreatedAtCursor, + > { + first: Default::default(), + after: None, + }; + + loop { + let es_entity::PaginatedQueryArgs { first, after } = query; + let (id, created_at) = if let Some(after) = after { + (Some(after.id), Some(after.created_at)) + } else { + (None, None) + }; + + let (entities, has_next_page) = es_entity::es_query!( + tbl_prefix = "bria", r#" - SELECT b.*, e.sequence, e.event_type, e.event - FROM bria_signing_sessions b - JOIN bria_signing_session_events e ON b.id = e.id - WHERE account_id = $1 AND batch_id = $2 - ORDER BY b.id, sequence"#, - Uuid::from(account_id), - Uuid::from(batch_id) + SELECT * + FROM bria_signing_sessions + WHERE account_id = $1 AND batch_id = $2 + AND (COALESCE((created_at, id) > ($4, $3), $3 IS NULL)) + ORDER BY created_at, id"#, + account_id as AccountId, + batch_id as BatchId, + id as Option, + created_at as Option>, ) - .fetch_all(&self.pool) + .fetch_n(self.pool(), first) .await?; - let mut entity_events = HashMap::new(); - for row in rows { - let id = SigningSessionId::from(row.id); - let events = entity_events.entry(id).or_insert_with(EntityEvents::new); - events.load_event(row.sequence as usize, row.event)?; + + signing_sessions.extend(entities); + + if !has_next_page { + break; } - entity_events - }; + let end_cursor = signing_sessions + .last() + .map(signing_session_cursor::SigningSessionsByCreatedAtCursor::from); + + query.after = end_cursor; + } let mut xpub_sessions = HashMap::new(); - for (_, events) in entity_events { - let session = SigningSession::try_from(events)?; - xpub_sessions.insert(session.xpub_id, session); + for session in signing_sessions { + xpub_sessions.insert(session.xpub_fingerprint, session); } if xpub_sessions.is_empty() { Ok(None) @@ -115,9 +114,9 @@ impl SigningSessions { pub async fn list_batch_ids_for( &self, - tx: &mut Transaction<'_, Postgres>, + op: &mut impl es_entity::AtomicOperation, account_id: AccountId, - xpub_id: XPubId, + xpub_fingerprint: XPubFingerprint, ) -> Result, SigningSessionError> { let rows = sqlx::query!( r#" @@ -125,9 +124,9 @@ impl SigningSessions { FROM bria_signing_sessions WHERE account_id = $1 AND xpub_fingerprint = $2 FOR UPDATE"#, Uuid::from(account_id), - xpub_id.as_bytes() + xpub_fingerprint.as_bytes() ) - .fetch_all(&mut **tx) + .fetch_all(op.as_executor()) .await?; Ok(rows diff --git a/src/utxo/repo.rs b/src/utxo/repo.rs index 3246a6e3..4a10baa1 100644 --- a/src/utxo/repo.rs +++ b/src/utxo/repo.rs @@ -126,7 +126,7 @@ impl UtxoRepo { ); query_builder.push_bind(tx_id); query_builder - .push("WHERE spend_detected_ledger_tx_id IS NULL AND (keychain_id, tx_id, vout) IN"); + .push(" WHERE spend_detected_ledger_tx_id IS NULL AND (keychain_id, tx_id, vout) IN"); let mut n_inputs = 0; query_builder.push_tuples(utxos, |mut builder, out| { n_inputs += 1; @@ -311,7 +311,7 @@ impl UtxoRepo { query_builder.push_bind(payout_queue_id); query_builder.push(", spending_sats_per_vbyte = "); query_builder.push_bind(fee_rate.as_sat_per_vb()); - query_builder.push("WHERE account_id = "); + query_builder.push(" WHERE account_id = "); query_builder.push_bind(account_id); query_builder.push(" AND (keychain_id, tx_id, vout) IN"); query_builder.push_tuples( diff --git a/src/wallet/entity.rs b/src/wallet/entity.rs index 690869c1..4be2ce09 100644 --- a/src/wallet/entity.rs +++ b/src/wallet/entity.rs @@ -1,14 +1,16 @@ use derive_builder::Builder; +use es_entity::*; use serde::{Deserialize, Serialize}; use sqlx_ledger::{AccountId as LedgerAccountId, JournalId}; use std::collections::HashMap; use super::{config::*, keychain::*}; -use crate::{entity::*, ledger::WalletLedgerAccountIds, primitives::*, xpub::XPub}; +use crate::{ledger::WalletLedgerAccountIds, primitives::*, xpub::XPub}; -#[derive(Serialize, Deserialize)] +#[derive(EsEvent, Serialize, Deserialize)] #[serde(tag = "type", rename_all = "snake_case")] +#[es_event(id = "WalletId")] #[allow(clippy::large_enum_variant)] pub enum WalletEvent { Initialized { @@ -41,10 +43,11 @@ pub enum WalletEvent { }, } -#[derive(Builder)] -#[builder(pattern = "owned", build_fn(error = "EntityError"))] +#[derive(EsEntity, Builder)] +#[builder(pattern = "owned", build_fn(error = "EsEntityError"))] pub struct Wallet { pub id: WalletId, + pub account_id: AccountId, pub ledger_account_ids: WalletLedgerAccountIds, pub journal_id: JournalId, pub config: WalletConfig, @@ -56,14 +59,14 @@ pub struct Wallet { impl Wallet { fn iter_keychains(&self) -> impl Iterator + '_ { - self.events.iter().rev().filter_map(|e| { + self.events.iter_all().rev().filter_map(|e| { if let WalletEvent::KeychainAdded { keychain_id, - keychain_config: config, + keychain_config, .. } = e { - Some((keychain_id, config)) + Some((keychain_id, keychain_config)) } else { None } @@ -126,55 +129,16 @@ pub struct NewWallet { config: WalletConfig, } -impl NewWallet { - pub fn builder() -> NewWalletBuilder { - let mut builder = NewWalletBuilder::default(); - builder.id(WalletId::new()); - builder - } - - pub(super) fn initial_events(self) -> EntityEvents { - let keychain_id = KeychainId::new(); - EntityEvents::init([ - WalletEvent::Initialized { - id: self.id, - network: self.network, - account_id: self.account_id, - journal_id: self.journal_id, - onchain_incoming_ledger_account_id: self.ledger_account_ids.onchain_incoming_id, - onchain_at_rest_ledger_account_id: self.ledger_account_ids.onchain_at_rest_id, - onchain_outgoing_ledger_account_id: self.ledger_account_ids.onchain_outgoing_id, - onchain_fee_ledger_account_id: self.ledger_account_ids.fee_id, - effective_incoming_ledger_account_id: self.ledger_account_ids.effective_incoming_id, - effective_at_rest_ledger_account_id: self.ledger_account_ids.effective_at_rest_id, - effective_outgoing_ledger_account_id: self.ledger_account_ids.effective_outgoing_id, - dust_ledger_account_id: self.ledger_account_ids.dust_id, - }, - WalletEvent::NameUpdated { name: self.name }, - WalletEvent::ConfigUpdated { - wallet_config: self.config, - }, - WalletEvent::KeychainAdded { - keychain_id, - idx: 0, - keychain_config: self.keychain, - }, - WalletEvent::KeychainActivated { keychain_id }, - ]) - } -} - -impl TryFrom> for Wallet { - type Error = EntityError; - - fn try_from(events: EntityEvents) -> Result { +impl TryFromEvents for Wallet { + fn try_from_events(events: EntityEvents) -> Result { let mut builder = WalletBuilder::default(); use WalletEvent::*; - for event in events.iter() { + for event in events.iter_all() { match event { Initialized { id, network, + account_id, journal_id, onchain_incoming_ledger_account_id, onchain_at_rest_ledger_account_id, @@ -188,6 +152,7 @@ impl TryFrom> for Wallet { } => { builder = builder .id(*id) + .account_id(*account_id) .network(*network) .journal_id(*journal_id) .ledger_account_ids(WalletLedgerAccountIds { @@ -215,3 +180,52 @@ impl TryFrom> for Wallet { builder.events(events).build() } } + +impl NewWallet { + pub fn builder() -> NewWalletBuilder { + let mut builder = NewWalletBuilder::default(); + builder.id(WalletId::new()); + builder + } +} + +impl IntoEvents for NewWallet { + fn into_events(self) -> EntityEvents { + let keychain_id = KeychainId::new(); + EntityEvents::init( + self.id, + vec![ + WalletEvent::Initialized { + id: self.id, + network: self.network, + account_id: self.account_id, + journal_id: self.journal_id, + onchain_incoming_ledger_account_id: self.ledger_account_ids.onchain_incoming_id, + onchain_at_rest_ledger_account_id: self.ledger_account_ids.onchain_at_rest_id, + onchain_outgoing_ledger_account_id: self.ledger_account_ids.onchain_outgoing_id, + onchain_fee_ledger_account_id: self.ledger_account_ids.fee_id, + effective_incoming_ledger_account_id: self + .ledger_account_ids + .effective_incoming_id, + effective_at_rest_ledger_account_id: self + .ledger_account_ids + .effective_at_rest_id, + effective_outgoing_ledger_account_id: self + .ledger_account_ids + .effective_outgoing_id, + dust_ledger_account_id: self.ledger_account_ids.dust_id, + }, + WalletEvent::NameUpdated { name: self.name }, + WalletEvent::ConfigUpdated { + wallet_config: self.config, + }, + WalletEvent::KeychainAdded { + keychain_id, + idx: 0, + keychain_config: self.keychain, + }, + WalletEvent::KeychainActivated { keychain_id }, + ], + ) + } +} diff --git a/src/wallet/error.rs b/src/wallet/error.rs index 4b86108a..2c66c2b7 100644 --- a/src/wallet/error.rs +++ b/src/wallet/error.rs @@ -2,14 +2,12 @@ use thiserror::Error; #[derive(Error, Debug)] pub enum WalletError { - #[error("WalletError - Could not find wallet with name: {0}")] - WalletNameNotFound(String), - #[error("WalletError - Could not find wallet with id: {0}")] - WalletIdNotFound(String), #[error("WalletError - Sqlx: {0}")] Sqlx(#[from] sqlx::Error), - #[error("WalletError - EntityError: {0}")] - EntityError(#[from] crate::entity::EntityError), + #[error("WalletError - EsEntityError: {0}")] + EsEntityError(es_entity::EsEntityError), + #[error("WalletError - CursorDestructureError: {0}")] + CursorDestructureError(#[from] es_entity::CursorDestructureError), #[error("WalletError - UnsupportedPubKeyType")] UnsupportedPubKeyType, #[error("WalletError - BdkMiniscriptError: {0}")] @@ -19,3 +17,5 @@ pub enum WalletError { #[error("WalletError - Unsigned txn in signed and unsigned psbt don't match")] UnsignedTxnMismatch, } + +es_entity::from_es_entity_error!(WalletError); diff --git a/src/wallet/keychain/config.rs b/src/wallet/keychain/config.rs index 35793023..39512729 100644 --- a/src/wallet/keychain/config.rs +++ b/src/wallet/keychain/config.rs @@ -37,12 +37,12 @@ impl KeychainConfig { let mut ret = HashMap::new(); internal.for_each_key(|key| { let xpub = XPub::try_from(key).expect("Couldn't convert xpub"); - ret.insert(xpub.id(), xpub); + ret.insert(xpub.fingerprint(), xpub); true }); external.for_each_key(|key| { let xpub = XPub::try_from(key).expect("Couldn't convert xpub"); - ret.insert(xpub.id(), xpub); + ret.insert(xpub.fingerprint(), xpub); true }); ret.into_values().collect() diff --git a/src/wallet/repo.rs b/src/wallet/repo.rs index ef406f64..fc4ec207 100644 --- a/src/wallet/repo.rs +++ b/src/wallet/repo.rs @@ -1,11 +1,21 @@ -use sqlx::{Pool, Postgres, Transaction}; +use es_entity::*; +use sqlx::{Pool, Postgres}; use std::collections::{HashMap, HashSet}; use uuid::Uuid; -use super::{entity::*, error::*}; -use crate::{entity::*, primitives::*}; +use super::{entity::*, error::WalletError}; +use crate::primitives::*; -#[derive(Debug, Clone)] +#[derive(EsRepo, Clone, Debug)] +#[es_repo( + entity = "Wallet", + err = "WalletError", + columns( + name(ty = "String"), + account_id(ty = "AccountId", list_for, update(persist = false)) + ), + tbl_prefix = "bria" +)] pub struct Wallets { pool: Pool, } @@ -15,53 +25,52 @@ impl Wallets { Self { pool: pool.clone() } } - pub async fn create_in_tx( + pub async fn list_for_account( &self, - tx: &mut Transaction<'_, Postgres>, - new_wallet: NewWallet, - ) -> Result { - let record = sqlx::query!( - r#"INSERT INTO bria_wallets (id, account_id, name) VALUES ($1, $2, $3) RETURNING (id)"#, - Uuid::from(new_wallet.id), - Uuid::from(new_wallet.account_id), - new_wallet.name - ) - .fetch_one(&mut **tx) - .await?; - EntityEvents::::persist( - "bria_wallet_events", - tx, - new_wallet.initial_events().new_serialized_events(record.id), - ) - .await?; - Ok(WalletId::from(record.id)) + account_id: AccountId, + ) -> Result, WalletError> { + let mut wallets = Vec::new(); + let mut next = Some(PaginatedQueryArgs::default()); + + while let Some(query) = next.take() { + let mut res = self + .list_for_account_id_by_id(account_id, query, Default::default()) + .await?; + wallets.append(&mut res.entities); + next = res.into_next_query(); + } + Ok(wallets) } - pub async fn find_by_name( + pub async fn find_by_account_id_and_id( + &self, + account_id: AccountId, + id: WalletId, + ) -> Result { + let wallet = self.find_by_id(id).await?; + if wallet.account_id != account_id { + return Err(WalletError::EsEntityError(EsEntityError::NotFound)); + } + Ok(wallet) + } + + pub async fn find_by_account_id_and_name( &self, account_id: AccountId, name: String, ) -> Result { - let rows = sqlx::query!( + let wallet = es_entity::es_query!( + tbl_prefix = "bria", r#" - SELECT b.*, e.sequence, e.event - FROM bria_wallets b - JOIN bria_wallet_events e ON b.id = e.id - WHERE account_id = $1 AND name = $2 - ORDER BY e.sequence"#, + SELECT * + FROM bria_wallets + WHERE account_id = $1 and name = $2"#, account_id as AccountId, name ) - .fetch_all(&self.pool) + .fetch_one(self.pool()) .await?; - if rows.is_empty() { - return Err(WalletError::WalletNameNotFound(name)); - } - let mut events = EntityEvents::new(); - for row in rows { - events.load_event(row.sequence as usize, row.event)?; - } - Ok(Wallet::try_from(events)?) + Ok(wallet) } pub async fn all_ids( @@ -81,71 +90,4 @@ impl Wallets { ) })) } - - pub async fn find_by_id(&self, id: WalletId) -> Result { - let ids: HashSet = std::iter::once(id).collect(); - if let Some(wallet) = self.find_by_ids(ids).await?.remove(&id) { - Ok(wallet) - } else { - Err(WalletError::WalletIdNotFound(id.to_string())) - } - } - - pub async fn list_by_account_id( - &self, - account_id: AccountId, - ) -> Result, WalletError> { - let rows = sqlx::query!( - r#" - SELECT b.*, e.sequence, e.event - FROM bria_wallets b - JOIN bria_wallet_events e ON b.id = e.id - WHERE account_id = $1 - ORDER BY e.sequence"#, - account_id as AccountId, - ) - .fetch_all(&self.pool) - .await?; - let mut events = HashMap::new(); - for row in rows { - let id = WalletId::from(row.id); - let sequence = row.sequence; - let events = events.entry(id).or_insert_with(EntityEvents::new); - events.load_event(sequence as usize, row.event)?; - } - Ok(events - .into_values() - .map(Wallet::try_from) - .collect::, _>>()?) - } - - pub async fn find_by_ids( - &self, - ids: HashSet, - ) -> Result, WalletError> { - let uuids = ids.into_iter().map(Uuid::from).collect::>(); - let rows = sqlx::query!( - r#" - SELECT b.*, e.sequence, e.event - FROM bria_wallets b - JOIN bria_wallet_events e ON b.id = e.id - WHERE b.id = ANY($1) - ORDER BY b.id, e.sequence"#, - &uuids[..] - ) - .fetch_all(&self.pool) - .await?; - let mut events = HashMap::new(); - for row in rows { - let id = WalletId::from(row.id); - let sequence = row.sequence; - let events = events.entry(id).or_insert_with(EntityEvents::new); - events.load_event(sequence as usize, row.event)?; - } - let mut wallets = HashMap::new(); - for (id, events) in events { - wallets.insert(id, Wallet::try_from(events)?); - } - Ok(wallets) - } } diff --git a/src/xpub/entity.rs b/src/xpub/entity.rs index 5ad57e7f..a834ecd8 100644 --- a/src/xpub/entity.rs +++ b/src/xpub/entity.rs @@ -1,11 +1,13 @@ use derive_builder::Builder; +use es_entity::*; use serde::{Deserialize, Serialize}; use super::{error::XPubError, signer_config::*, signing_client::*, value::XPub as XPubValue}; -use crate::{entity::*, primitives::*}; +use crate::primitives::*; -#[derive(Debug, Serialize, Deserialize)] +#[derive(EsEvent, Debug, Serialize, Deserialize)] #[serde(tag = "type", rename_all = "snake_case")] +#[es_event(id = "uuid::Uuid")] pub enum XPubEvent { Initialized { db_uuid: uuid::Uuid, @@ -21,21 +23,23 @@ pub enum XPubEvent { }, } -#[derive(Builder)] -#[builder(pattern = "owned", build_fn(error = "EntityError"))] +#[derive(EsEntity, Builder)] +#[es_entity(event = XPubEvent)] +#[builder(pattern = "owned", build_fn(error = "EsEntityError"))] pub struct AccountXPub { pub account_id: AccountId, pub key_name: String, pub value: XPubValue, pub original: String, + #[builder(default)] pub(super) encrypted_signer_config: Option<(ConfigCyper, Nonce)>, - pub(super) db_uuid: uuid::Uuid, + pub(super) id: uuid::Uuid, pub(super) events: EntityEvents, } impl AccountXPub { - pub fn id(&self) -> XPubId { - self.value.id() + pub fn fingerprint(&self) -> XPubFingerprint { + self.value.fingerprint() } pub fn set_signer_config( @@ -82,7 +86,7 @@ impl AccountXPub { #[derive(Builder, Clone, Debug)] pub struct NewAccountXPub { - pub(super) db_uuid: uuid::Uuid, + pub(super) id: uuid::Uuid, pub(super) account_id: AccountId, #[builder(setter(into))] pub(super) key_name: String, @@ -93,19 +97,24 @@ pub struct NewAccountXPub { impl NewAccountXPub { pub fn builder() -> NewAccountXPubBuilder { let mut builder = NewAccountXPubBuilder::default(); - builder.db_uuid(uuid::Uuid::new_v4()); + builder.id(uuid::Uuid::new_v4()); builder } - pub fn id(&self) -> XPubId { - self.value.id() + pub fn fingerprint(&self) -> XPubFingerprint { + self.value.fingerprint() } - pub(super) fn initial_events(self) -> EntityEvents { + pub fn key_name(&self) -> String { + self.key_name.clone() + } +} +impl IntoEvents for NewAccountXPub { + fn into_events(self) -> EntityEvents { let xpub = self.value.inner; - EntityEvents::init([ + let events = vec![ XPubEvent::Initialized { - db_uuid: self.db_uuid, + db_uuid: self.id, account_id: self.account_id, fingerprint: xpub.fingerprint(), parent_fingerprint: xpub.parent_fingerprint, @@ -116,18 +125,15 @@ impl NewAccountXPub { XPubEvent::NameUpdated { name: self.key_name, }, - ]) + ]; + EntityEvents::init(self.id, events) } } -impl TryFrom<(EntityEvents, Option<(ConfigCyper, Nonce)>)> for AccountXPub { - type Error = EntityError; - - fn try_from( - (events, config): (EntityEvents, Option<(ConfigCyper, Nonce)>), - ) -> Result { +impl TryFromEvents for AccountXPub { + fn try_from_events(events: EntityEvents) -> Result { let mut builder = AccountXPubBuilder::default(); - for event in events.iter() { + for event in events.iter_all() { match event { XPubEvent::Initialized { db_uuid, @@ -138,7 +144,7 @@ impl TryFrom<(EntityEvents, Option<(ConfigCyper, Nonce)>)> for Accoun .. } => { builder = builder - .db_uuid(*db_uuid) + .id(*db_uuid) .account_id(*account_id) .value(XPubValue { inner: *xpub, @@ -151,11 +157,6 @@ impl TryFrom<(EntityEvents, Option<(ConfigCyper, Nonce)>)> for Accoun } } } - if let Some((encrypted_config, nonce)) = config { - builder = builder.encrypted_signer_config(Some((encrypted_config, nonce))); - } else { - builder = builder.encrypted_signer_config(None); - } builder.events(events).build() } } diff --git a/src/xpub/error.rs b/src/xpub/error.rs index b87f7586..e76cac8f 100644 --- a/src/xpub/error.rs +++ b/src/xpub/error.rs @@ -20,4 +20,10 @@ pub enum XPubError { UnsupportedPubKeyType, #[error("Could not decrypt signer config: {0}")] CouldNotDecryptSignerConfig(chacha20poly1305::Error), + #[error("XPubError - EsEntityError: {0}")] + EsEntityError(es_entity::EsEntityError), + #[error("XPubError - CursorDestructureError: {0}")] + CursorDestructureError(#[from] es_entity::CursorDestructureError), } + +es_entity::from_es_entity_error!(XPubError); diff --git a/src/xpub/reference.rs b/src/xpub/reference.rs index ffea6180..75b1a675 100644 --- a/src/xpub/reference.rs +++ b/src/xpub/reference.rs @@ -1,7 +1,7 @@ use crate::primitives::*; pub enum XPubRef { - Id(XPubId), + Fingerprint(XPubFingerprint), Name(String), } @@ -9,22 +9,22 @@ impl std::str::FromStr for XPubRef { type Err = super::error::XPubError; fn from_str(s: &str) -> Result { - if let Ok(id) = XPubId::from_str(s) { - Ok(XPubRef::Id(id)) + if let Ok(fingerprint) = XPubFingerprint::from_str(s) { + Ok(XPubRef::Fingerprint(fingerprint)) } else { Ok(XPubRef::Name(s.to_string())) } } } -impl From for XPubRef { - fn from(id: XPubId) -> Self { - Self::Id(id) +impl From for XPubRef { + fn from(fingerprint: XPubFingerprint) -> Self { + Self::Fingerprint(fingerprint) } } -impl From<&XPubId> for XPubRef { - fn from(id: &XPubId) -> Self { - Self::Id(*id) +impl From<&XPubFingerprint> for XPubRef { + fn from(fingerprint: &XPubFingerprint) -> Self { + Self::Fingerprint(*fingerprint) } } diff --git a/src/xpub/repo.rs b/src/xpub/repo.rs index 70c36947..0e67894d 100644 --- a/src/xpub/repo.rs +++ b/src/xpub/repo.rs @@ -1,87 +1,80 @@ -use sqlx::{Pool, Postgres, Transaction}; -use tracing::instrument; -use uuid::Uuid; +use es_entity::*; +use sqlx::{ + postgres::{PgHasArrayType, PgTypeInfo}, + Database, Encode, Pool, Postgres, +}; -use super::{entity::*, error::XPubError, reference::*, signer_config::*}; -use crate::{entity::*, primitives::*}; use std::collections::HashMap; +use uuid::Uuid; -#[derive(Clone)] +use super::{entity::*, error::XPubError, reference::*, signer_config::*}; +use crate::primitives::*; + +#[derive(EsRepo, Clone)] +#[es_repo( + entity = "AccountXPub", + event = "XPubEvent", + err = "XPubError", + id = Uuid, + tbl = "bria_xpubs", + events_tbl = "bria_xpub_events", + columns( + account_id(ty = "AccountId", list_for, update(persist = false)), + name(ty = "String", update(persist=false), create(accessor=key_name())), + fingerprint(ty = "XPubFingerprint", create(accessor=fingerprint()), update(persist = false)) + ), +)] pub struct XPubs { pool: Pool, } -impl XPubs { - pub fn new(pool: &Pool) -> Self { - Self { pool: pool.clone() } +impl Encode<'_, Postgres> for XPubFingerprint { + fn encode_by_ref( + &self, + buf: &mut ::ArgumentBuffer<'_>, + ) -> Result> { + let bytes = self.to_bytes(); + bytes.encode_by_ref(buf) } +} - #[instrument(name = "xpubs.persist", skip(self))] - pub async fn persist(&self, xpub: NewAccountXPub) -> Result { - let mut tx = self.pool.begin().await?; - let ret = self.persist_in_tx(&mut tx, xpub).await?; - tx.commit().await?; - Ok(ret) +impl sqlx::Type for XPubFingerprint { + fn type_info() -> ::TypeInfo { + sqlx::postgres::PgTypeInfo::with_name("BYTEA") } +} - #[instrument(name = "xpubs.persist_in_tx", skip(self))] - pub async fn persist_in_tx( - &self, - tx: &mut Transaction<'_, Postgres>, - xpub: NewAccountXPub, - ) -> Result { - let xpub_id = xpub.id(); - sqlx::query!( - r#"INSERT INTO bria_xpubs - (id, account_id, name, fingerprint) - VALUES ($1, $2, $3, $4)"#, - xpub.db_uuid, - Uuid::from(xpub.account_id), - xpub.key_name, - xpub_id.as_bytes() - ) - .execute(&mut **tx) - .await?; - let id = xpub.db_uuid; - EntityEvents::::persist( - "bria_xpub_events", - &mut *tx, - xpub.initial_events().new_serialized_events(id), - ) - .await?; - Ok(xpub_id) +impl PgHasArrayType for XPubFingerprint { + fn array_type_info() -> PgTypeInfo { + PgTypeInfo::with_name("_bytea") + } +} + +impl XPubs { + pub fn new(pool: &Pool) -> Self { + Self { pool: pool.clone() } } - pub async fn persist_updated( + pub async fn update_signer_config( &self, - tx: &mut Transaction<'_, Postgres>, + op: &mut impl es_entity::AtomicOperation, xpub: AccountXPub, ) -> Result<(), XPubError> { - if xpub.events.is_dirty() { - EntityEvents::::persist( - "bria_xpub_events", - tx, - xpub.events.new_serialized_events(xpub.db_uuid), - ) - .await?; - } - if let Some((cypher, nonce)) = xpub.encrypted_signer_config { let cypher_bytes = &cypher.0; let nonce_bytes = &nonce.0; - sqlx::query!( r#" INSERT INTO bria_xpub_signer_configs (id, cypher, nonce, created_at, modified_at) VALUES ($1, $2, $3, NOW(), NOW()) - ON CONFLICT (id) DO UPDATE + ON CONFLICT (id) DO UPDATE SET cypher = $2, nonce = $3, modified_at = NOW() "#, - xpub.db_uuid, + xpub.id as Uuid, cypher_bytes, nonce_bytes, ) - .execute(&mut **tx) + .execute(op.as_executor()) .await?; } @@ -94,75 +87,71 @@ impl XPubs { xpub_ref: impl Into, ) -> Result { let xpub_ref = xpub_ref.into(); - let mut tx = self.pool.begin().await?; - let db_uuid = match xpub_ref { - XPubRef::Id(fp) => { - let record = sqlx::query!( - r#"SELECT id FROM bria_xpubs WHERE account_id = $1 AND fingerprint = $2"#, + let mut xpub = match xpub_ref { + XPubRef::Fingerprint(fp) => { + let xpub = es_entity::es_query!( + entity = AccountXPub, + r#" + SELECT * + FROM bria_xpubs + WHERE account_id = $1 AND fingerprint = $2"#, Uuid::from(account_id), fp.as_bytes() ) - .fetch_one(&mut *tx) + .fetch_one(self.pool()) .await?; - record.id + xpub } XPubRef::Name(name) => { - let record = sqlx::query!( - r#"SELECT id FROM bria_xpubs WHERE account_id = $1 AND name = $2"#, + let xpub = es_entity::es_query!( + entity = AccountXPub, + r#" + SELECT * + FROM bria_xpubs + WHERE account_id = $1 AND name = $2"#, Uuid::from(account_id), name ) - .fetch_one(&mut *tx) + .fetch_one(self.pool()) .await?; - record.id + xpub } }; - let rows = sqlx::query!( - r#"SELECT sequence, event_type, event FROM bria_xpub_events - WHERE id = $1 - ORDER BY sequence"#, - db_uuid - ) - .fetch_all(&mut *tx) - .await?; - let mut events = EntityEvents::new(); - for row in rows { - events.load_event(row.sequence as usize, row.event)?; - } - let config_row = sqlx::query!( r#" SELECT cypher, nonce FROM bria_xpub_signer_configs WHERE id = $1 "#, - db_uuid + xpub.id as Uuid, ) .fetch_optional(&self.pool) .await?; - let config = match config_row { - Some(row) => Some((ConfigCyper(row.cypher), Nonce(row.nonce))), - None => None, + match config_row { + Some(row) => { + xpub.encrypted_signer_config = Some((ConfigCyper(row.cypher), Nonce(row.nonce))) + } + None => xpub.encrypted_signer_config = None, }; - Ok(AccountXPub::try_from((events, config))?) + Ok(xpub) } pub async fn list_xpubs(&self, account_id: AccountId) -> Result, XPubError> { - let rows = sqlx::query!( - r#"SELECT b.*, e.sequence, e.event - FROM bria_xpubs b - JOIN bria_xpub_events e ON b.id = e.id - WHERE account_id = $1 - ORDER BY b.id, e.sequence"#, - account_id as AccountId, - ) - .fetch_all(&self.pool) - .await?; + let mut xpubs = vec![]; + let mut next = Some(PaginatedQueryArgs::default()); + while let Some(query) = next.take() { + let mut paginated_xpub = self + .list_for_account_id_by_id(account_id, query, es_entity::ListDirection::Ascending) + .await?; + + xpubs.append(&mut paginated_xpub.entities); + next = paginated_xpub.into_next_query(); + } - let ids: Vec = rows.iter().map(|row| row.id).collect(); + let ids: Vec = xpubs.iter().map(|xpub| xpub.id).collect(); let config_rows = sqlx::query!( r#" @@ -180,32 +169,27 @@ impl XPubs { .map(|row| (row.id, (ConfigCyper(row.cypher), Nonce(row.nonce)))) .collect(); - let mut entity_events = HashMap::new(); - for row in rows { - let id = row.id; - let events = entity_events.entry(id).or_insert_with(EntityEvents::new); - events.load_event(row.sequence as usize, row.event)?; - } - - let mut xpubs = Vec::new(); - for (id, events) in entity_events { - let config = config_map.remove(&id); - let xpub = AccountXPub::try_from((events, config))?; - xpubs.push(xpub); + for xpub in &mut xpubs { + if let Some(config) = config_map.remove(&xpub.id) { + xpub.encrypted_signer_config = Some(config); + } else { + xpub.encrypted_signer_config = None; + } } Ok(xpubs) } pub async fn list_all_xpubs(&self) -> Result, XPubError> { - let rows = sqlx::query!( - r#"SELECT b.*, e.sequence, e.event - FROM bria_xpubs b - JOIN bria_xpub_events e ON b.id = e.id - ORDER BY b.id, e.sequence"#, - ) - .fetch_all(&self.pool) - .await?; + let mut xpubs = vec![]; + let mut next = Some(PaginatedQueryArgs::default()); + while let Some(query) = next.take() { + let mut paginated_xpub = self + .list_by_id(query, es_entity::ListDirection::default()) + .await?; + xpubs.append(&mut paginated_xpub.entities); + next = paginated_xpub.into_next_query(); + } let config_rows = sqlx::query!( r#" SELECT id, cypher, nonce @@ -219,19 +203,12 @@ impl XPubs { .into_iter() .map(|row| (row.id, (ConfigCyper(row.cypher), Nonce(row.nonce)))) .collect(); - - let mut entity_events = HashMap::new(); - for row in rows { - let id = row.id; - let events = entity_events.entry(id).or_insert_with(EntityEvents::new); - events.load_event(row.sequence as usize, row.event)?; - } - - let mut xpubs = Vec::new(); - for (id, events) in entity_events { - let config = config_map.remove(&id); - let xpub = AccountXPub::try_from((events, config))?; - xpubs.push(xpub); + for xpub in &mut xpubs { + if let Some(config) = config_map.remove(&xpub.id) { + xpub.encrypted_signer_config = Some(config); + } else { + xpub.encrypted_signer_config = None; + } } Ok(xpubs) diff --git a/src/xpub/signer.rs b/src/xpub/signer.rs deleted file mode 100644 index e69de29b..00000000 diff --git a/src/xpub/value.rs b/src/xpub/value.rs index ea690169..a1b01c02 100644 --- a/src/xpub/value.rs +++ b/src/xpub/value.rs @@ -5,7 +5,7 @@ use std::fmt; use super::error::XPubError; use crate::primitives::{ bitcoin::{DerivationPath, ExtendedPubKey}, - XPubId, + XPubFingerprint, }; #[derive(Serialize, Deserialize, PartialEq, Eq, Debug, Clone)] @@ -15,8 +15,8 @@ pub struct XPub { } impl XPub { - pub fn id(&self) -> XPubId { - XPubId::from(self.inner.fingerprint()) + pub fn fingerprint(&self) -> XPubFingerprint { + XPubFingerprint::from(self.inner.fingerprint()) } pub fn inner(&self) -> &ExtendedPubKey { diff --git a/tests/application_errors.rs b/tests/application_errors.rs index 7f4a9b3b..e9344974 100644 --- a/tests/application_errors.rs +++ b/tests/application_errors.rs @@ -1,5 +1,6 @@ mod helpers; +use es_entity::EsEntityError; use rand::distributions::{Alphanumeric, DistString}; use bria::{ @@ -23,9 +24,9 @@ async fn external_id_does_not_exist() -> anyhow::Result<()> { assert!(matches!( err, - Err(ApplicationError::AddressError( - AddressError::ExternalIdNotFound - )) + Err(ApplicationError::AddressError(AddressError::EsEntityError( + EsEntityError::NotFound + ))) )); Ok(()) @@ -93,7 +94,7 @@ async fn payout_queue_id_not_found() -> anyhow::Result<()> { assert!(matches!( err, Err(ApplicationError::PayoutQueueError( - PayoutQueueError::PayoutQueueIdNotFound(_) + PayoutQueueError::EsEntityError(EsEntityError::NotFound) )) )); Ok(()) @@ -108,9 +109,9 @@ async fn wallet_name_not_found() -> anyhow::Result<()> { let err = app.new_address(&profile, wallet_name, None, None).await; assert!(matches!( err, - Err(ApplicationError::WalletError( - WalletError::WalletNameNotFound(_) - )) + Err(ApplicationError::WalletError(WalletError::EsEntityError( + EsEntityError::NotFound + ))) )); Ok(()) } @@ -141,7 +142,7 @@ async fn payout_queue_name_not_found() -> anyhow::Result<()> { assert!(matches!( err, Err(ApplicationError::PayoutQueueError( - PayoutQueueError::PayoutQueueNameNotFound(_) + PayoutQueueError::EsEntityError(EsEntityError::NotFound) )) )); @@ -158,9 +159,9 @@ async fn profile_name_not_found() -> anyhow::Result<()> { .await; assert!(matches!( err, - Err(ApplicationError::ProfileError( - ProfileError::ProfileNameNotFound(_) - )) + Err(ApplicationError::ProfileError(ProfileError::EsEntityError( + EsEntityError::NotFound + ))) )); Ok(()) } diff --git a/tests/payout.rs b/tests/payout.rs index 56e8b922..d635293e 100644 --- a/tests/payout.rs +++ b/tests/payout.rs @@ -20,7 +20,7 @@ async fn payout() -> anyhow::Result<()> { let repo = XPubs::new(&pool); let id = repo - .persist( + .create( NewAccountXPub::builder() .account_id(profile.account_id) .original(original.to_owned()) @@ -29,7 +29,8 @@ async fn payout() -> anyhow::Result<()> { .build() .unwrap(), ) - .await?; + .await? + .fingerprint(); let app = App::run(pool, AppConfig::default()).await?; app.create_wpkh_wallet(&profile, wallet_name.clone(), id.to_string(), None) @@ -67,7 +68,7 @@ async fn spending_policy() -> anyhow::Result<()> { let repo = XPubs::new(&pool); let id = repo - .persist( + .create( NewAccountXPub::builder() .account_id(profile.account_id) .original(original.to_owned()) @@ -76,7 +77,8 @@ async fn spending_policy() -> anyhow::Result<()> { .build() .unwrap(), ) - .await?; + .await? + .fingerprint(); let app = App::run(pool, AppConfig::default()).await?; app.create_wpkh_wallet(&profile, wallet_name.clone(), id.to_string(), None) diff --git a/tests/wallet.rs b/tests/wallet.rs index b7055e42..4f7f277a 100644 --- a/tests/wallet.rs +++ b/tests/wallet.rs @@ -17,7 +17,7 @@ async fn create_wpkh_wallet() -> anyhow::Result<()> { let repo = XPubs::new(&pool); let id = repo - .persist( + .create( NewAccountXPub::builder() .account_id(profile.account_id) .original(original.to_owned()) @@ -26,8 +26,8 @@ async fn create_wpkh_wallet() -> anyhow::Result<()> { .build() .unwrap(), ) - .await?; - + .await? + .fingerprint(); let app = App::run(pool, AppConfig::default()).await?; app.create_wpkh_wallet(&profile, name.clone(), id.to_string(), None) .await?; @@ -58,10 +58,10 @@ async fn create_descriptors_wallet() -> anyhow::Result<()> { let internal = "wpkh([1ff51810/84'/0'/0']tpubDDdzmt7vndmNywiVAeBPuhYLTFa7hmtfaqUxxTv5iLy7bxU93B62M9WKFSmn1BEN2vte8GDD3SUNKbupRajFW4RK8hd3i6W15pvTRQfo1fK/1/*)#3nxmc294".to_owned(); let app = App::run(pool, AppConfig::default()).await?; let wallet_name = "test_import_descriptor".to_owned(); - let (_, xpub_ids) = app + let (_, xpub_fingerprints) = app .create_descriptors_wallet(&profile, wallet_name, external, internal) .await?; - assert_eq!(xpub_ids.len(), 1); - assert_eq!(xpub_ids[0].to_string(), "2f18f2f7"); + assert_eq!(xpub_fingerprints.len(), 1); + assert_eq!(xpub_fingerprints[0].to_string(), "2f18f2f7"); Ok(()) } diff --git a/tests/xpub.rs b/tests/xpub.rs index 548c16bf..d8be64bb 100644 --- a/tests/xpub.rs +++ b/tests/xpub.rs @@ -12,7 +12,7 @@ async fn test_xpub() -> anyhow::Result<()> { let xpub = XPub::try_from((original, Some("m/84'/0'/0'"))).unwrap(); let repo = XPubs::new(&pool); let _ = repo - .persist( + .create( NewAccountXPub::builder() .account_id(profile.account_id) .original(original.to_owned())