Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions cmd/cli/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ var (
Short: "edit an existing sell order - use the simulate flag to generate json only",
Args: cobra.MinimumNArgs(6),
Run: func(cmd *cobra.Command, args []string) {
writeTxResultToConsole(client.TxEditOrder(argGetAddrOrNickname(args[0]), uint64(argToInt(args[1])), uint64(argToInt(args[2])), uint64(argToInt(args[3])), uint64(argToInt(args[4])), args[5], getPassword(), !sim, fee))
writeTxResultToConsole(client.TxEditOrder(argGetAddrOrNickname(args[0]), uint64(argToInt(args[1])), uint64(argToInt(args[2])), args[3], uint64(argToInt(args[4])), args[5], getPassword(), !sim, fee))
},
}

Expand All @@ -237,7 +237,7 @@ var (
Short: "delete an existing sell order - use the simulate flag to generate json only",
Args: cobra.MinimumNArgs(3),
Run: func(cmd *cobra.Command, args []string) {
writeTxResultToConsole(client.TxDeleteOrder(argGetAddrOrNickname(args[0]), uint64(argToInt(args[1])), uint64(argToInt(args[2])), getPassword(), !sim, fee))
writeTxResultToConsole(client.TxDeleteOrder(argGetAddrOrNickname(args[0]), args[1], uint64(argToInt(args[2])), getPassword(), !sim, fee))
},
}

Expand All @@ -246,7 +246,16 @@ var (
Short: "lock an existing sell order - use the simulate flag to generate json only",
Args: cobra.MinimumNArgs(3),
Run: func(cmd *cobra.Command, args []string) {
writeTxResultToConsole(client.TxLockOrder(argGetAddrOrNickname(args[0]), argGetAddr(args[1]), uint64(argToInt(args[2])), getPassword(), !sim, fee))
writeTxResultToConsole(client.TxLockOrder(argGetAddrOrNickname(args[0]), argGetAddr(args[1]), args[2], getPassword(), !sim, fee))
},
}

txCloseOrderCmd = &cobra.Command{
Use: "tx-close-order <address or nickname> <canopy-receive-address> <order-id> --fee=10000 --simulate=true",
Short: "closes an existing locked sell order - use the simulate flag to generate json only",
Args: cobra.MinimumNArgs(2),
Run: func(cmd *cobra.Command, args []string) {
writeTxResultToConsole(client.TxCloseOrder(argGetAddrOrNickname(args[0]), args[1], getPassword(), !sim, fee))
},
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ var (
Short: "query a specific sell order",
Args: cobra.MinimumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
writeToConsole(client.Order(height, uint64(argToInt(args[0])), committee))
writeToConsole(client.Order(height, args[0], committee))
},
}

Expand Down
14 changes: 12 additions & 2 deletions cmd/rpc/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,13 @@ func (s *Server) TransactionLockOrder(w http.ResponseWriter, r *http.Request, _
if err := s.getFeeFromState(w, ptr, fsm.MessageSendName, true); err != nil {
return nil, err
}
// convert the order id to bytes
oId, err := lib.StringToBytes(ptr.OrderId)
if err != nil {
return nil, err
}
// Create and return the transaction to be sent
return fsm.NewLockOrderTx(p, lib.LockOrder{OrderId: ptr.OrderId, BuyerSendAddress: p.PublicKey().Address().Bytes(), BuyerReceiveAddress: ptr.ReceiveAddress}, s.config.NetworkID, s.config.ChainId, ptr.Fee, s.controller.ChainHeight())
return fsm.NewLockOrderTx(p, lib.LockOrder{OrderId: oId, BuyerSendAddress: p.PublicKey().Address().Bytes(), BuyerReceiveAddress: ptr.ReceiveAddress}, s.config.NetworkID, s.config.ChainId, ptr.Fee, s.controller.ChainHeight())
})
}

Expand Down Expand Up @@ -382,8 +387,13 @@ func (s *Server) TransactionCloseOrder(w http.ResponseWriter, r *http.Request, _
if int64(order.BuyerChainDeadline)-int64(s.controller.ChainHeight()) < 10 {
return nil, fmt.Errorf("too close to buyer chain deadline")
}
// convert the order id to bytes
oId, err := lib.StringToBytes(ptr.OrderId)
if err != nil {
return nil, err
}
// Create the close order structure
co := lib.CloseOrder{OrderId: ptr.OrderId, CloseOrder: true}
co := lib.CloseOrder{OrderId: oId, CloseOrder: true}
// Exit with the new CloseOrderTx
return fsm.NewCloseOrderTx(p, co, crypto.NewAddress(order.SellerReceiveAddress), order.RequestedAmount, s.config.NetworkID, s.config.ChainId, ptr.Fee, s.controller.ChainHeight())
})
Expand Down
12 changes: 6 additions & 6 deletions cmd/rpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func (c *Client) RetiredCommittees(height uint64) (p *[]uint64, err lib.ErrorI)
return
}

func (c *Client) Order(height, orderId, chainId uint64) (p *lib.SellOrder, err lib.ErrorI) {
func (c *Client) Order(height uint64, orderId string, chainId uint64) (p *lib.SellOrder, err lib.ErrorI) {
p = new(lib.SellOrder)
err = c.orderRequest(OrderRouteName, height, orderId, chainId, p)
return
Expand Down Expand Up @@ -578,7 +578,7 @@ func (c *Client) TxCreateOrder(from AddrOrNickname, sellAmount, receiveAmount, c
return c.transactionRequest(TxCreateOrderRouteName, txReq, submit)
}

func (c *Client) TxEditOrder(from AddrOrNickname, sellAmount, receiveAmount, orderId, chainId uint64, receiveAddress string,
func (c *Client) TxEditOrder(from AddrOrNickname, sellAmount, receiveAmount uint64, orderId string, chainId uint64, receiveAddress string,
pwd string, submit bool, optFee uint64) (hash *string, tx json.RawMessage, e lib.ErrorI) {
receiveAddr, err := lib.NewHexBytesFromString(receiveAddress)
if err != nil {
Expand All @@ -603,7 +603,7 @@ func (c *Client) TxEditOrder(from AddrOrNickname, sellAmount, receiveAmount, ord
return c.transactionRequest(TxEditOrderRouteName, txReq, submit)
}

func (c *Client) TxDeleteOrder(from AddrOrNickname, orderId, chainId uint64,
func (c *Client) TxDeleteOrder(from AddrOrNickname, orderId string, chainId uint64,
pwd string, submit bool, optFee uint64) (hash *string, tx json.RawMessage, e lib.ErrorI) {
txReq := txDeleteOrder{
Fee: optFee,
Expand All @@ -620,7 +620,7 @@ func (c *Client) TxDeleteOrder(from AddrOrNickname, orderId, chainId uint64,
return c.transactionRequest(TxDeleteOrderRouteName, txReq, submit)
}

func (c *Client) TxLockOrder(from AddrOrNickname, receiveAddress string, orderId uint64,
func (c *Client) TxLockOrder(from AddrOrNickname, receiveAddress string, orderId string,
pwd string, submit bool, optFee uint64) (hash *string, tx json.RawMessage, e lib.ErrorI) {
receiveHex, err := lib.NewHexBytesFromString(receiveAddress)
if err != nil {
Expand All @@ -640,7 +640,7 @@ func (c *Client) TxLockOrder(from AddrOrNickname, receiveAddress string, orderId
return c.transactionRequest(TxLockOrderRouteName, txReq, submit)
}

func (c *Client) TxCloseOrder(from AddrOrNickname, orderId uint64, pwd string, submit bool, optFee uint64) (hash *string, tx json.RawMessage, e lib.ErrorI) {
func (c *Client) TxCloseOrder(from AddrOrNickname, orderId string, pwd string, submit bool, optFee uint64) (hash *string, tx json.RawMessage, e lib.ErrorI) {
txReq := txCloseOrder{
Fee: optFee,
OrderId: orderId,
Expand Down Expand Up @@ -850,7 +850,7 @@ func (c *Client) heightRequest(routeName string, height uint64, ptr any) (err li
return
}

func (c *Client) orderRequest(routeName string, height, orderId, chainId uint64, ptr any) (err lib.ErrorI) {
func (c *Client) orderRequest(routeName string, height uint64, orderId string, chainId uint64, ptr any) (err lib.ErrorI) {
bz, err := lib.MarshalJSON(orderRequest{
ChainId: chainId,
OrderId: orderId,
Expand Down
6 changes: 5 additions & 1 deletion cmd/rpc/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,11 @@ func (s *Server) RetiredCommittees(w http.ResponseWriter, r *http.Request, _ htt
func (s *Server) Order(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
// Invoke helper with the HTTP request, response writer and an inline callback
s.orderParams(w, r, func(s *fsm.StateMachine, p *orderRequest) (any, lib.ErrorI) {
return s.GetOrder(p.OrderId, p.ChainId)
orderId, err := lib.StringToBytes(p.OrderId)
if err != nil {
return nil, err
}
return s.GetOrder(orderId, p.ChainId)
})
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/rpc/sock.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func (r *RCManager) GetOrders(rootChainId, rootHeight, id uint64) (*lib.OrderBoo
}

// Order() returns a specific order from the root order book
func (r *RCManager) GetOrder(rootChainId, height, orderId, chainId uint64) (*lib.SellOrder, lib.ErrorI) {
func (r *RCManager) GetOrder(rootChainId, height uint64, orderId string, chainId uint64) (*lib.SellOrder, lib.ErrorI) {
// if the root chain id is the same as the info
sub, found := r.subscriptions[rootChainId]
if !found {
Expand Down
12 changes: 6 additions & 6 deletions cmd/rpc/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type chainRequest struct {

type orderRequest struct {
ChainId uint64 `json:"chainId"`
OrderId uint64 `json:"orderId"`
OrderId string `json:"orderId"`
heightRequest
}

Expand Down Expand Up @@ -224,15 +224,15 @@ type txEditOrder struct {
Submit bool `json:"submit"`
ReceiveAmount uint64 `json:"receiveAmount"`
ReceiveAddress lib.HexBytes `json:"receiveAddress"`
OrderId uint64 `json:"orderId"`
OrderId string `json:"orderId"`
fromFields
txChangeParamRequest
committeesRequest
}

type txDeleteOrder struct {
Fee uint64 `json:"fee"`
OrderId uint64 `json:"orderId"`
OrderId string `json:"orderId"`
Password string `json:"password"`
fromFields
txChangeParamRequest
Expand All @@ -241,7 +241,7 @@ type txDeleteOrder struct {

type txLockOrder struct {
Fee uint64 `json:"fee"`
OrderId uint64 `json:"orderId"`
OrderId string `json:"orderId"`
Password string `json:"password"`
ReceiveAddress lib.HexBytes `json:"receiveAddress"`
fromFields
Expand All @@ -251,7 +251,7 @@ type txLockOrder struct {

type txCloseOrder struct {
Fee uint64 `json:"fee"`
OrderId uint64 `json:"orderId"`
OrderId string `json:"orderId"`
Password string `json:"password"`
fromFields
}
Expand Down Expand Up @@ -304,7 +304,7 @@ type txRequest struct {
Submit bool `json:"submit"`
ReceiveAmount uint64 `json:"receiveAmount"`
ReceiveAddress lib.HexBytes `json:"receiveAddress"`
OrderId uint64 `json:"orderId"`
OrderId string `json:"orderId"`
Memo string `json:"memo"`
PollJSON json.RawMessage `json:"pollJSON"`
PollApprove bool `json:"pollApprove"`
Expand Down
5 changes: 3 additions & 2 deletions cmd/rpc/web/explorer/components/table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {

// convertValue() converts the value based on its key and handles different types
function convertValue(k, v, openModal) {
if (k === "Id") return v;
if (k === "publicKey") return <Truncate text={v} />;
if (isHex(v) || k === "height") {
const content = isNumber(v) ? v : <Truncate text={v} />;
Expand Down Expand Up @@ -122,7 +123,7 @@ function convertGovernanceParams(v) {
function convertOrder(v) {
const exchangeRate = v.requestedAmount / v.amountForSale;
return {
Id: v.id ?? 0,
Id: v.id ?? "error",
Chain: v.committee,
AmountForSale: toCNPY(v.amountForSale),
Rate: exchangeRate.toFixed(2),
Expand Down Expand Up @@ -226,7 +227,7 @@ export default function DTable(props) {
{sortedData.map((val, idx) => (
<tr key={idx}>
{Object.keys(val).map((k, i) => (
<td key={i} className="table-col">
<td key={i} className={k === 'Id' ? 'large-table-col' : 'table-col'}>
{convertValue(k, val[k], props.openModal)}
</td>
))}
Expand Down
17 changes: 13 additions & 4 deletions cmd/rpc/web/explorer/styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ input::placeholder {
}

.table {
table-layout: auto;
background-color: #d2d2d2;
border: 1px solid #d2d2d2;
border-radius: 5px !important;
Expand Down Expand Up @@ -364,10 +365,6 @@ h5 {
margin-bottom: 25px !important;
}

th {
font-family: var(--font-heading);
}

.detail-table-title {
white-space: nowrap;
font-weight: 600;
Expand Down Expand Up @@ -411,6 +408,18 @@ th {
float: right;
}

td, th {
font-family: var(--font-heading);
}

.large-table-col {
max-width: 1000px !important;
font-size: 13px !important;
padding-left: 10px !important;
padding-top: 15px !important;
padding-bottom: 15px !important;
}

.table-col {
max-width: 200px !important;
font-size: 13px !important;
Expand Down
Loading
Loading