MsgTake

a valid message

Given the message

{
  "owner": "regen1elq7ys34gpkj3jyvqee0h6yk4h9wsfxmgqelsw",
  "basket_denom": "eco.uC.NCT",
  "amount": "100",
  "retirement_jurisdiction": "US-WA",
  "retire_on_take": true,
  "retirement_reason": "offsetting electricity consumption"
}

When the message is validated

Then expect no error.

a valid message without retirement reason

Given the message

{
  "owner": "regen1elq7ys34gpkj3jyvqee0h6yk4h9wsfxmgqelsw",
  "basket_denom": "eco.uC.NCT",
  "amount": "100",
  "retirement_jurisdiction": "US-WA",
  "retire_on_take": true
}

When the message is validated

Then expect no error.

a valid message without retire on take

Given the message

{
  "owner": "regen1elq7ys34gpkj3jyvqee0h6yk4h9wsfxmgqelsw",
  "basket_denom": "eco.uC.NCT",
  "amount": "100"
}

When the message is validated

Then expect no error.

an error is returned if owner is empty

Given the message

{}

When the message is validated

Then expect the error "empty address string is not allowed: invalid request".

an error is returned if owner is not a bech32 address

Given the message

{
  "owner": "foo"
}

When the message is validated

Then expect the error "decoding bech32 failed: invalid bech32 string length 3: invalid request".

an error is returned if basket denom is empty

Given the message

{
  "owner": "regen1elq7ys34gpkj3jyvqee0h6yk4h9wsfxmgqelsw"
}

When the message is validated

Then expect the error "basket denom: empty string is not allowed: parse error: invalid request".

an error is returned if basket denom is not formatted

Given the message

{
  "owner": "regen1elq7ys34gpkj3jyvqee0h6yk4h9wsfxmgqelsw",
  "basket_denom": "foo"
}

When the message is validated

Then expect the error "basket denom: expected format eco.[exponent-prefix][credit-type-abbrev].[name]: parse error: invalid request".

an error is returned if amount is empty

Given the message

{
  "owner": "regen1elq7ys34gpkj3jyvqee0h6yk4h9wsfxmgqelsw",
  "basket_denom": "eco.uC.NCT"
}

When the message is validated

Then expect the error "amount cannot be empty: invalid request".

an error is returned if a amount is not an integer

Given the message

{
  "owner": "regen1elq7ys34gpkj3jyvqee0h6yk4h9wsfxmgqelsw",
  "basket_denom": "eco.uC.NCT",
  "amount": "100.5"
}

When the message is validated

Then expect the error "100.5 is not a valid integer: invalid request".

an error is returned if a amount is less than zero

Given the message

{
  "owner": "regen1elq7ys34gpkj3jyvqee0h6yk4h9wsfxmgqelsw",
  "basket_denom": "eco.uC.NCT",
  "amount": "-100"
}

When the message is validated

Then expect the error "amount must be positive, got -100: invalid request".

an error is returned if retirement jurisdiction is empty and retire on take is true

Given the message

{
  "owner": "regen1elq7ys34gpkj3jyvqee0h6yk4h9wsfxmgqelsw",
  "basket_denom": "eco.uC.NCT",
  "amount": "100",
  "retire_on_take": true
}

When the message is validated

Then expect the error "retirement jurisdiction cannot be empty if retire on take is true: invalid request".

an error is returned if retirement jurisdiction is not formatted and retire on take is true

Given the message

{
  "owner": "regen1elq7ys34gpkj3jyvqee0h6yk4h9wsfxmgqelsw",
  "basket_denom": "eco.uC.NCT",
  "amount": "100",
  "retirement_jurisdiction": "foo",
  "retire_on_take": true
}

When the message is validated

Then expect the error "retirement jurisdiction: expected format [country-code][-[region-code][ [postal-code]]]: parse error: invalid request".

no error is returned if retirement jurisdiction is not formatted and retire on take is false

Given the message

{
  "owner": "regen1elq7ys34gpkj3jyvqee0h6yk4h9wsfxmgqelsw",
  "basket_denom": "eco.uC.NCT",
  "amount": "100",
  "retirement_jurisdiction": "foo",
  "retire_on_take": false
}

When the message is validated

Then expect no error.

an error is returned if retirement reason exceeds 512 characters

Given the message

{
  "owner": "regen1elq7ys34gpkj3jyvqee0h6yk4h9wsfxmgqelsw",
  "basket_denom": "eco.uC.NCT",
  "amount": "100",
  "retirement_jurisdiction": "US-WA",
  "retire_on_take": true
}

And retirement reason with length "513"

When the message is validated

Then expect the error "retirement reason: max length 512: limit exceeded".

a valid amino message

Given the message

{
  "owner": "regen1elq7ys34gpkj3jyvqee0h6yk4h9wsfxmgqelsw",
  "basket_denom": "eco.uC.NCT",
  "amount": "100",
  "retirement_jurisdiction": "US-WA",
  "retire_on_take": true,
  "retirement_reason": "offsetting electricity consumption"
}

When message sign bytes queried

Then expect the sign bytes

{
  "type":"regen.basket/MsgTake",
  "value":{
    "amount":"100",
    "basket_denom":"eco.uC.NCT",
    "owner":"regen1elq7ys34gpkj3jyvqee0h6yk4h9wsfxmgqelsw",
    "retire_on_take":true,
    "retirement_jurisdiction":"US-WA",
    "retirement_reason": "offsetting electricity consumption"
  }
}