diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 5978284d..ce13aa45 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -71,12 +71,13 @@ jobs: with: environment: "STAGING" - validate-staging-swift: - needs: deploy-infra-staging - uses: ./.github/workflows/validate_swift.yml - with: - notify-endpoint: 'staging.notify.walletconnect.com' - relay-endpoint: 'staging.relay.walletconnect.com' + # TODO: Restore once swift is ready for notify + # validate-staging-swift: + # needs: deploy-infra-staging + # uses: ./.github/workflows/validate_swift.yml + # with: + # notify-endpoint: 'staging.notify.walletconnect.com' + # relay-endpoint: 'staging.relay.walletconnect.com' ############################################################################## @@ -103,10 +104,11 @@ jobs: environment: "PROD" - validate-swift-prod: - needs: [deploy-infra-prod] - uses: ./.github/workflows/validate_swift.yml - with: - notify-endpoint: 'notify.walletconnect.com' - relay-endpoint: 'relay.walletconnect.com' + # TODO: Restore once swift is ready for notify + # validate-swift-prod: + # needs: [deploy-infra-prod] + # uses: ./.github/workflows/validate_swift.yml + # with: + # notify-endpoint: 'notify.walletconnect.com' + # relay-endpoint: 'relay.walletconnect.com' \ No newline at end of file diff --git a/src/handlers/subscribe_topic.rs b/src/handlers/subscribe_topic.rs index 7633e0cc..cd0e4c6b 100644 --- a/src/handlers/subscribe_topic.rs +++ b/src/handlers/subscribe_topic.rs @@ -27,9 +27,16 @@ pub struct Keypair { pub public_key: String, } +#[derive(Serialize, Deserialize, Debug)] +#[serde(rename_all = "camelCase")] +pub struct SubscribeTopicData { + dapp_url: String, +} + pub async fn handler( State(state): State>, AuthedProjectId(project_id, _): AuthedProjectId, + Json(subscribe_topic_data): Json, ) -> Result { info!("Generating keypair for project: {}", project_id); let db = state.database.clone(); @@ -48,6 +55,17 @@ pub async fn handler( project_data, signing_pubkey, identity_pubkey ); + if project_data.dapp_url != subscribe_topic_data.dapp_url { + info!("Updating dapp_url for project: {}", project_id); + db.collection::("project_data") + .update_one( + doc! { "_id": project_id.clone()}, + doc! { "$set": { "dapp_url": &subscribe_topic_data.dapp_url } }, + None, + ) + .await?; + } + return Ok(Json( json!({ "identityPublicKey": identity_pubkey, "subscribeTopicPublicKey": signing_pubkey}), ) @@ -74,8 +92,7 @@ pub async fn handler( private_key: hex::encode(identity_secret.to_bytes()), public_key: identity_public.clone(), }, - // TODO: Proper dapp url - dapp_url: "http://localhost:3000".into(), + dapp_url: subscribe_topic_data.dapp_url, topic: topic.clone(), }; diff --git a/src/lib.rs b/src/lib.rs index 6b78a804..9a86f7b0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -125,7 +125,7 @@ pub async fn bootstap(mut shutdown: broadcast::Receiver<()>, config: Configurati .route("/:project_id/notify", post(handlers::notify::handler)) .route( "/:project_id/subscribe-topic", - get(handlers::subscribe_topic::handler), + post(handlers::subscribe_topic::handler), ) .route( "/:project_id/register-webhook", diff --git a/tests/integration.rs b/tests/integration.rs index 696031ff..66a4254b 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -88,8 +88,9 @@ PROJECT_ID to be set", // Register project - generating subscribe topic let dapp_pubkey_response: serde_json::Value = http_client - .get(format!("{}/{}/subscribe-topic", ¬ify_url, &project_id)) + .post(format!("{}/{}/subscribe-topic", ¬ify_url, &project_id)) .bearer_auth(&project_secret) + .json(&json!({ "dappUrl": "https://my-test-app.com" })) .send() .await .unwrap()