-
Notifications
You must be signed in to change notification settings - Fork 4
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
Conversation
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, | ||
}) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move do_sign_change_pubkey_with_create2data_auth
to sign_transfer.rs as a function
#[cfg(not(feature = "ffi"))] | ||
pub fn check_create2data( | ||
zklink_singer: &ZkLinkSigner, | ||
data: Create2Data, | ||
account_address: ZkLinkAddress, | ||
) -> Result<(), SignError> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check_create2data(
#[cfg(feature = "ffi")]
zklink_singer: Arc<ZkLinkSigner>,
#[cfg(not(feature = "ffi"))]
zklink_singer: &ZkLinkSigner,
)
|
||
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) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let mut order = Order();
sign_order(&mut order, xxx);
create_signed_order
?
pub fn sign_order(&self, order: &Order) -> Result<Order, SignError> { | ||
let signed_order = sign_order(order, &self.zklink_signer)?; | ||
Ok(signed_order) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create_signed_order
&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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
server already make a check for from_account
|
||
#[cfg(not(feature = "ffi"))] | ||
#[cfg(not(any(feature = "ffi")))] | ||
pub fn sign_withdraw( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove any
#[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) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove sign_order
// #[cfg(feature = "web")] | ||
pub mod json_rpc_signer; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove "//"
#[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) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new_from_eth_rpc_signer
No description provided.