Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

add wasm support for sdk #28

Closed
wants to merge 8 commits into from
Closed

add wasm support for sdk #28

wants to merge 8 commits into from

Conversation

nick-zkp
Copy link
Contributor

No description provided.

@nick-zkp nick-zkp requested a review from Fred0327 October 12, 2023 07:54
Comment on lines +49 to +64
fn do_sign_change_pubkey_with_create2data_auth(
&self,
mut tx: ChangePubKey,
create2data: Create2Data,
) -> Result<TxSignature, SignError> {
tx.sign(&self.zklink_signer)?;
let should_valid = tx.is_signature_valid();
assert!(should_valid);

// create onchain auth data
tx.eth_auth_data = ChangePubKeyAuthData::EthCreate2 { data: create2data };
Ok(TxSignature {
tx: tx.into(),
eth_signature: None,
})
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move do_sign_change_pubkey_with_create2data_auth to sign_transfer.rs as a function

Comment on lines +121 to +126
#[cfg(not(feature = "ffi"))]
pub fn check_create2data(
zklink_singer: &ZkLinkSigner,
data: Create2Data,
account_address: ZkLinkAddress,
) -> Result<(), SignError> {
Copy link
Contributor

@Fred0327 Fred0327 Oct 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check_create2data(
#[cfg(feature = "ffi")]
zklink_singer: Arc<ZkLinkSigner>,
#[cfg(not(feature = "ffi"))]
zklink_singer: &ZkLinkSigner,
)

Comment on lines +7 to 12

pub fn sign_order(order: &Order, zklink_signer: &ZkLinkSigner) -> Result<Order, ZkSignerError> {
let mut order = order.clone();
order.signature = zklink_signer.sign_musig(&order.get_bytes())?;
Ok(order)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let mut order = Order();
sign_order(&mut order, xxx);

create_signed_order ?

Comment on lines +145 to +149
pub fn sign_order(&self, order: &Order) -> Result<Order, SignError> {
let signed_order = sign_order(order, &self.zklink_signer)?;
Ok(signed_order)
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

create_signed_order

Comment on lines 76 to 82
&self,
tx: ChangePubKey,
create2data: Create2Data,
from_account: ZkLinkAddress,
) -> Result<TxSignature, SignError> {
check_create2data(&self.zklink_signer, create2data.clone(), from_account)?;
self.do_sign_change_pubkey_with_create2data_auth(tx, create2data)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

server already make a check for from_account

Comment on lines 193 to 195

#[cfg(not(feature = "ffi"))]
#[cfg(not(any(feature = "ffi")))]
pub fn sign_withdraw(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove any

Comment on lines +221 to +225
#[cfg(not(feature = "ffi"))]
pub fn sign_order(&self, order: &Order) -> Result<Order, SignError> {
let signed_order = sign_order(order, &self.zklink_signer)?;
Ok(signed_order)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove sign_order

Comment on lines +15 to 17
// #[cfg(feature = "web")]
pub mod json_rpc_signer;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove "//"

Comment on lines +101 to +108
#[cfg(feature = "web")]
pub async fn new_from_eth_json_rpc_signer(eth_signer: &JsonRpcSigner) -> Result<Self, Error> {
let signature = eth_signer
.sign_message(Self::SIGN_MESSAGE.as_bytes())
.await?;
let seed = signature.serialize_packed();
Self::new_from_seed(&seed)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new_from_eth_rpc_signer

@nick-zkp nick-zkp closed this Oct 20, 2023
@Fred0327 Fred0327 deleted the wasm-dev-v2 branch January 12, 2024 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants