MsgBuyDirect
a valid message
Given the message
{
"buyer": "regen1elq7ys34gpkj3jyvqee0h6yk4h9wsfxmgqelsw",
"orders": [
{
"sell_order_id": "1",
"quantity": "100",
"bid_price": {
"denom": "regen",
"amount": "100"
},
"retirement_jurisdiction": "US-WA",
"retirement_reason": "offsetting electricity consumption"
}
]
}
When the message is validated
Then expect no error.
a valid message without retirement reason
Given the message
{
"buyer": "regen1elq7ys34gpkj3jyvqee0h6yk4h9wsfxmgqelsw",
"orders": [
{
"sell_order_id": "1",
"quantity": "100",
"bid_price": {
"denom": "regen",
"amount": "100"
},
"retirement_jurisdiction": "US-WA"
}
]
}
When the message is validated
Then expect no error.
a valid message with multiple orders
Given the message
{
"buyer": "regen1elq7ys34gpkj3jyvqee0h6yk4h9wsfxmgqelsw",
"orders": [
{
"sell_order_id": "1",
"quantity": "100",
"bid_price": {
"denom": "regen",
"amount": "100"
},
"retirement_jurisdiction": "US-WA",
"retirement_reason": "offsetting electricity consumption"
},
{
"sell_order_id": "1",
"quantity": "100",
"bid_price": {
"denom": "regen",
"amount": "100"
},
"retirement_jurisdiction": "US-WA",
"retirement_reason": "offsetting electricity consumption"
}
]
}
When the message is validated
Then expect no error.
a valid message with disable auto-retire
Given the message
{
"buyer": "regen1elq7ys34gpkj3jyvqee0h6yk4h9wsfxmgqelsw",
"orders": [
{
"sell_order_id": "1",
"quantity": "100",
"bid_price": {
"denom": "regen",
"amount": "100"
},
"disable_auto_retire": true
}
]
}
When the message is validated
Then expect no error.
an error is returned if buyer is empty
Given the message
{}
When the message is validated
Then expect the error "buyer cannot be empty: invalid request".
an error is returned if buyer is not a valid bech32 address
Given the message
{
"buyer": "foo"
}
When the message is validated
Then expect the error "buyer is not a valid address: decoding bech32 failed: invalid bech32 string length 3: invalid request".
an error is returned if orders is empty
Given the message
{
"buyer": "regen1elq7ys34gpkj3jyvqee0h6yk4h9wsfxmgqelsw"
}
When the message is validated
Then expect the error "orders cannot be empty: invalid request".
an error is returned if sell order id is empty
Given the message
{
"buyer": "regen1elq7ys34gpkj3jyvqee0h6yk4h9wsfxmgqelsw",
"orders": [
{}
]
}
When the message is validated
Then expect the error "orders[0]: sell order id cannot be empty: invalid request".
an error is returned if order quantity is empty
Given the message
{
"buyer": "regen1elq7ys34gpkj3jyvqee0h6yk4h9wsfxmgqelsw",
"orders": [
{
"sell_order_id": 1
}
]
}
When the message is validated
Then expect the error "orders[0]: quantity cannot be empty: invalid request".
an error is returned if order quantity is not a positive decimal
Given the message
{
"buyer": "regen1elq7ys34gpkj3jyvqee0h6yk4h9wsfxmgqelsw",
"orders": [
{
"sell_order_id": 1,
"quantity": "-100"
}
]
}
When the message is validated
Then expect the error "orders[0]: quantity must be a positive decimal: invalid request".
an error is returned if bid price is empty
Given the message
{
"buyer": "regen1elq7ys34gpkj3jyvqee0h6yk4h9wsfxmgqelsw",
"orders": [
{
"sell_order_id": 1,
"quantity": "100"
}
]
}
When the message is validated
Then expect the error "orders[0]: bid price cannot be empty: invalid request".
an error is returned if bid price denom is empty
Given the message
{
"buyer": "regen1elq7ys34gpkj3jyvqee0h6yk4h9wsfxmgqelsw",
"orders": [
{
"sell_order_id": 1,
"quantity": "100",
"bid_price": {}
}
]
}
When the message is validated
Then expect the error "orders[0]: bid price: denom cannot be empty: invalid request".
an error is returned if bid price denom is not formatted
Given the message
{
"buyer": "regen1elq7ys34gpkj3jyvqee0h6yk4h9wsfxmgqelsw",
"orders": [
{
"sell_order_id": 1,
"quantity": "100",
"bid_price": {
"denom": "foo#bar"
}
}
]
}
When the message is validated
Then expect the error "orders[0]: bid price: invalid denom: foo#bar: invalid request".
an error is returned if bid price amount is empty
Given the message
{
"buyer": "regen1elq7ys34gpkj3jyvqee0h6yk4h9wsfxmgqelsw",
"orders": [
{
"sell_order_id": 1,
"quantity": "100",
"bid_price": {
"denom": "regen"
}
}
]
}
When the message is validated
Then expect the error "orders[0]: bid price: amount cannot be empty: invalid request".
an error is returned if bid price amount is not a positive integer
Given the message
{
"buyer": "regen1elq7ys34gpkj3jyvqee0h6yk4h9wsfxmgqelsw",
"orders": [
{
"sell_order_id": 1,
"quantity": "100",
"bid_price": {
"denom": "regen",
"amount": "-100"
}
}
]
}
When the message is validated
Then expect the error "orders[0]: bid price: amount must be a positive integer: invalid request".
an error is returned if disable auto-retire is true and retirement jurisdiction is empty
Given the message
{
"buyer": "regen1elq7ys34gpkj3jyvqee0h6yk4h9wsfxmgqelsw",
"orders": [
{
"sell_order_id": 1,
"quantity": "100",
"bid_price": {
"denom": "regen",
"amount": "100"
}
}
]
}
When the message is validated
Then expect the error "orders[0]: retirement jurisdiction: empty string is not allowed: parse error: invalid request".
an error is returned if disable auto-retire is true and retirement jurisdiction is not formatted
Given the message
{
"buyer": "regen1elq7ys34gpkj3jyvqee0h6yk4h9wsfxmgqelsw",
"orders": [
{
"sell_order_id": 1,
"quantity": "100",
"bid_price": {
"denom": "regen",
"amount": "100"
},
"retirement_jurisdiction": "foo"
}
]
}
When the message is validated
Then expect the error "orders[0]: retirement jurisdiction: expected format [country-code][-[region-code][ [postal-code]]]: parse error: invalid request".
an error is returned if disable auto-retire is true and retirement reason exceeds 512 characters
Given the message
{
"buyer": "regen1elq7ys34gpkj3jyvqee0h6yk4h9wsfxmgqelsw",
"orders": [
{
"sell_order_id": 1,
"quantity": "100",
"bid_price": {
"denom": "regen",
"amount": "100"
},
"retirement_jurisdiction": "US-WA"
}
]
}
And retirement reason with length "513"
When the message is validated
Then expect the error "orders[0]: retirement reason: max length 512: limit exceeded".
a valid amino message
Given the message
{
"buyer": "regen1elq7ys34gpkj3jyvqee0h6yk4h9wsfxmgqelsw",
"orders": [
{
"sell_order_id": "1",
"quantity": "100",
"bid_price": {
"denom": "regen",
"amount": "100"
},
"retirement_jurisdiction": "US-WA",
"retirement_reason": "offsetting electricity consumption"
}
]
}
When message sign bytes queried
Then expect the sign bytes
{
"type":"regen.marketplace/MsgBuyDirect",
"value":{
"buyer":"regen1elq7ys34gpkj3jyvqee0h6yk4h9wsfxmgqelsw",
"orders":[
{
"bid_price": {
"amount":"100",
"denom":"regen"
},
"quantity":"100",
"retirement_jurisdiction":"US-WA",
"retirement_reason": "offsetting electricity consumption",
"sell_order_id":"1"
}
]
}
}