From 41d0422340009f34b2d789c8fc825278f405710b Mon Sep 17 00:00:00 2001 From: Fred Date: Wed, 11 Oct 2023 11:47:19 +0800 Subject: [PATCH] add signature arguement when creat Order(fix #21) --- binding_tests/interface_test.go | 2 ++ bindings/sdk/src/ffi.udl | 3 ++- examples/Golang/5_order_matching.go | 2 ++ types/src/tx_type/order_matching.rs | 3 ++- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/binding_tests/interface_test.go b/binding_tests/interface_test.go index 9de8b93b..d84875d4 100644 --- a/binding_tests/interface_test.go +++ b/binding_tests/interface_test.go @@ -145,6 +145,7 @@ func TestSignOrderMatching(t *testing.T) { true, 2, 5, + nil, ) taker, err = sdk.CreateSignedOrder( zklink_signer, @@ -166,6 +167,7 @@ func TestSignOrderMatching(t *testing.T) { false, 2, 5, + nil, ) maker, err = sdk.CreateSignedOrder( zklink_signer, diff --git a/bindings/sdk/src/ffi.udl b/bindings/sdk/src/ffi.udl index 232cc475..9f57d3ed 100644 --- a/bindings/sdk/src/ffi.udl +++ b/bindings/sdk/src/ffi.udl @@ -242,7 +242,8 @@ interface Order { BigUint price, boolean is_sell, u8 fee_ratio1, - u8 fee_ratio2 + u8 fee_ratio2, + ZkLinkSignature ?signature ); ZkLinkSignature signature(); sequence get_bytes(); diff --git a/examples/Golang/5_order_matching.go b/examples/Golang/5_order_matching.go index 33ed27a8..03060fff 100644 --- a/examples/Golang/5_order_matching.go +++ b/examples/Golang/5_order_matching.go @@ -36,6 +36,7 @@ func HighLevelOrderMatching() { true, 2, 5, + nil, ) taker, err = sdk.CreateSignedOrder( zklinkSigner, @@ -54,6 +55,7 @@ func HighLevelOrderMatching() { false, 2, 5, + nil, ) maker, err = sdk.CreateSignedOrder( zklinkSigner, diff --git a/types/src/tx_type/order_matching.rs b/types/src/tx_type/order_matching.rs index 5e93932b..42361fc0 100644 --- a/types/src/tx_type/order_matching.rs +++ b/types/src/tx_type/order_matching.rs @@ -71,6 +71,7 @@ impl Order { is_sell: bool, fee_ratio1: u8, fee_ratio2: u8, + signature: Option, ) -> Self { Self { account_id, @@ -84,7 +85,7 @@ impl Order { is_sell: u8::from(is_sell), fee_ratio1, fee_ratio2, - signature: ZkLinkSignature::default(), + signature: signature.unwrap_or_default(), } }