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

Make actions returned from HTTP API self-descriptive #673

Closed
thomaseizinger opened this Issue Jan 17, 2019 · 0 comments

Comments

Projects
None yet
3 participants
@thomaseizinger
Copy link
Member

thomaseizinger commented Jan 17, 2019

This is implementation ticket for the results of the spike #494.

Currently, the actions returned in the HTTP API are not self-descriptive. This means, a client has to infer from out-of-band information, how to interpret the payload. The design proposed in #494 fixes this.

For reference, this is the current list of all actions:

#[derive(Clone, Debug, Serialize)]
#[serde(untagged)]
pub enum ActionResponseBody {
SendToBitcoinAddress {
address: bitcoin_support::Address,
value: BitcoinQuantity,
},
BroadcastSignedBitcoinTransaction {
hex: String,
},
SendEthereumTransaction {
to: Option<ethereum_support::Address>,
data: ethereum_support::Bytes,
value: EtherQuantity,
gas_limit: ethereum_support::U256,
},
}

According to that, the following changes have to made to the currently returned actions:

  1. Split up the SendEthereumTransaction into two distinct actions:
  • deploy contract
  • invoke contract
  1. Change the action payloads to match the following:

Send-to-bitcoin address action

{
	"type": "bitcoin-send-amount-to-address",
	"payload": {
		"to": "...",
		"amount": "5000000",
	}
}

broadcast signed bitcoin transaction action

{
	"type": "bitcoin-broadcast-signed-transaction",
	"payload": {
		"hex": "..."
	}
}

deploy ethereum contract

{
	"type": "ethereum-deploy-contract",
	"payload": {
		"data": "...",
		"amount": "...",
		"gas_limit": "..."
	}
}

invoke ethereum contract

{
	"type": "ethereum-invoke-contract",
	"payload": {
		"contract_address": "...",
		"data": "...",
		"gas_limit": "...",
        "amount": 0
	}
}
  1. Make the serialized JSON contain the type attribute.

  2. All actions should be extended with a "network" attribute in the "payload".

Implementation hint:

The following serde features might be very helpful in doing this:

@D4nte D4nte added the groomed label Jan 20, 2019

@luckysori luckysori self-assigned this Jan 21, 2019

@luckysori luckysori added this to the Sprint 6 🔄📖 milestone Jan 21, 2019

@wafflebot wafflebot bot added review and removed work-in-progress labels Jan 22, 2019

@D4nte D4nte modified the milestones: Sprint 6 🔄📖, Sprint 7 Jan 22, 2019

@mergify mergify bot closed this in #687 Jan 23, 2019

@wafflebot wafflebot bot removed the review label Jan 23, 2019

thomaseizinger added a commit that referenced this issue Jan 24, 2019

Remove TODO
With the implementation in #673, this question is now answered and
the answer is no.

D4nte pushed a commit that referenced this issue Jan 24, 2019

Remove TODO
With the implementation in #673, this question is now answered and
the answer is no.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment