From a3581b3e75058639cf389f65b1ebb665634ba890 Mon Sep 17 00:00:00 2001 From: gerald <3949379+getong@users.noreply.github.com> Date: Wed, 18 Sep 2024 16:09:41 +0800 Subject: [PATCH] feat: add chs_signature and indexer_signature --- apps/indexer-proxy/proxy/src/payg.rs | 33 ++++++++++++++-------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/apps/indexer-proxy/proxy/src/payg.rs b/apps/indexer-proxy/proxy/src/payg.rs index c3682b4d..3e164a9c 100644 --- a/apps/indexer-proxy/proxy/src/payg.rs +++ b/apps/indexer-proxy/proxy/src/payg.rs @@ -741,16 +741,30 @@ pub async fn extend_channel( // send to coordinator let expired_at = expired + expiration as i64; + let account = ACCOUNT.read().await; + let indexer_sign = extend_sign2( + channel_id, + indexer, + state_cache.agent, + new_price, + U256::from(expired), + U256::from(expiration), + &account.controller, + ) + .await?; + drop(account); + let indexer_sign = convert_sign_to_string(&indexer_sign); let mdata = format!( r#"mutation {{ channelExtend( id:"{:#X}", expiration:{}, price:"{}", - ) + indexerSign:{}, + consumerSign:{} {{ id, expiredAt }} }}"#, - channel_id, expired_at, new_price, + channel_id, expired_at, new_price, indexer_sign, signature ); let url = COMMAND.graphql_url(); let query = GraphQLQuery::query(&mdata); @@ -763,20 +777,7 @@ pub async fn extend_channel( return Err(Error::ServiceException(1202)); } - let account = ACCOUNT.read().await; - let indexer_sign = extend_sign2( - channel_id, - indexer, - state_cache.agent, - new_price, - U256::from(expired), - U256::from(expiration), - &account.controller, - ) - .await?; - drop(account); - - Ok(convert_sign_to_string(&indexer_sign)) + Ok(indexer_sign) } pub async fn pay_channel(mut state: QueryState) -> Result {