Skip to content

Commit

Permalink
Change type from int64 to strings for multiple fields in protocol.
Browse files Browse the repository at this point in the history
Change the type for multiple JSON fields using `int64` to be of type `string`:

  - Attribute `offer_id` in [manage buy offer](https://www.stellar.org/developers/horizon/reference/resources/operation.html#manage-buy-offer) and [manage sell offer](https://www.stellar.org/developers/horizon/reference/resources/operation.html#manage-sell-offer) operations.
  - Attribute `offer_id` in [Trade](https://www.stellar.org/developers/horizon/reference/resources/effect.html#trading-effects) effect.
  - Attribute `id` in [Offer](https://www.stellar.org/developers/horizon/reference/resources/offer.html) resource.
  - Attribute `timestamp` and `trade_count` in [Trade Aggregation](https://www.stellar.org/developers/horizon/reference/resources/trade_aggregation.html) resource.
  - Attribute `new_seq` in [Sequence Bumpeed](https://www.stellar.org/developers/horizon/reference/resources/effect.html#misc-effects) effect.
  • Loading branch information
abuiles committed Dec 6, 2019
1 parent 39df62a commit 4bbfbd5
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 29 deletions.
4 changes: 2 additions & 2 deletions clients/horizon/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ var accountOffersResponse = `{
"href": "https://horizon.stellar.org/accounts/GC2BQYBXFOVPRDH35D5HT2AFVCDGXJM5YVTAF5THFSAISYOWAJQKRESK"
}
},
"id": 161,
"id": "161",
"paging_token": "161",
"seller": "GC2BQYBXFOVPRDH35D5HT2AFVCDGXJM5YVTAF5THFSAISYOWAJQKRESK",
"selling": {
Expand All @@ -730,7 +730,7 @@ var accountOffersResponse = `{
"href": "https://horizon.stellar.org/accounts/GC2BQYBXFOVPRDH35D5HT2AFVCDGXJM5YVTAF5THFSAISYOWAJQKRESK"
}
},
"id": 2539,
"id": "2539",
"paging_token": "2539",
"seller": "GC2BQYBXFOVPRDH35D5HT2AFVCDGXJM5YVTAF5THFSAISYOWAJQKRESK",
"selling": {
Expand Down
4 changes: 2 additions & 2 deletions clients/horizonclient/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1194,7 +1194,7 @@ var offersResponse = `{
"href": "https://horizon-testnet.stellar.org/accounts/GDOJCPYIB66RY4XNDLRRHQQXB27YLNNAGAYV5HMHEYNYY4KUNV5FDV2F"
}
},
"id": 432323,
"id": "432323",
"paging_token": "432323",
"seller": "GDOJCPYIB66RY4XNDLRRHQQXB27YLNNAGAYV5HMHEYNYY4KUNV5FDV2F",
"selling": {
Expand Down Expand Up @@ -1301,7 +1301,7 @@ var multipleOpsResponse = `{
"selling_asset_type": "credit_alphanum4",
"selling_asset_code": "XRP",
"selling_asset_issuer": "GBVOL67TMUQBGL4TZYNMY3ZQ5WGQYFPFD5VJRWXR72VA33VFNL225PL5",
"offer_id": 73938565
"offer_id": "73938565"
},
{
"_links": {
Expand Down
6 changes: 3 additions & 3 deletions clients/horizonclient/offer_request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func TestOfferRequestStreamOffers(t *testing.T) {
}
}

var offerStreamResponse = `data: {"_links":{"self":{"href":"https://horizon-testnet.stellar.org/offers/5269100"},"offer_maker":{"href":"https://horizon-testnet.stellar.org/accounts/GAQHWQYBBW272OOXNQMMLCA5WY2XAZPODGB7Q3S5OKKIXVESKO55ZQ7C"}},"id":5269100,"paging_token":"5269100","seller":"GAQHWQYBBW272OOXNQMMLCA5WY2XAZPODGB7Q3S5OKKIXVESKO55ZQ7C","selling":{"asset_type":"credit_alphanum4","asset_code":"DSQ","asset_issuer":"GBDQPTQJDATT7Z7EO4COS4IMYXH44RDLLI6N6WIL5BZABGMUOVMLWMQF"},"buying":{"asset_type":"credit_alphanum4","asset_code":"XCS6","asset_issuer":"GBH2V47NOZRC56QAYCPV5JUBG5NVFJQF5AQTUNFNWNDHSWWTKH2MWR2L"},"amount":"20.4266087","price_r":{"n":24819,"d":10000000},"price":"0.0024819","last_modified_ledger":674449,"last_modified_time":"2019-04-08T11:56:41Z"}
var offerStreamResponse = `data: {"_links":{"self":{"href":"https://horizon-testnet.stellar.org/offers/5269100"},"offer_maker":{"href":"https://horizon-testnet.stellar.org/accounts/GAQHWQYBBW272OOXNQMMLCA5WY2XAZPODGB7Q3S5OKKIXVESKO55ZQ7C"}},"id":"5269100","paging_token":"5269100","seller":"GAQHWQYBBW272OOXNQMMLCA5WY2XAZPODGB7Q3S5OKKIXVESKO55ZQ7C","selling":{"asset_type":"credit_alphanum4","asset_code":"DSQ","asset_issuer":"GBDQPTQJDATT7Z7EO4COS4IMYXH44RDLLI6N6WIL5BZABGMUOVMLWMQF"},"buying":{"asset_type":"credit_alphanum4","asset_code":"XCS6","asset_issuer":"GBH2V47NOZRC56QAYCPV5JUBG5NVFJQF5AQTUNFNWNDHSWWTKH2MWR2L"},"amount":"20.4266087","price_r":{"n":24819,"d":10000000},"price":"0.0024819","last_modified_ledger":674449,"last_modified_time":"2019-04-08T11:56:41Z"}
`

var firstOffersPage = `{
Expand All @@ -131,7 +131,7 @@ var firstOffersPage = `{
"href": "https://horizon-testnet.stellar.org/accounts/GBZ5OD56VRTRQKMNADD6VUZUG3FCILMAMYQY5ZSC3AW3GBXNEPIK76IG"
}
},
"id": 2946580,
"id": "2946580",
"paging_token": "2946580",
"seller": "GBZ5OD56VRTRQKMNADD6VUZUG3FCILMAMYQY5ZSC3AW3GBXNEPIK76IG",
"selling": {
Expand Down Expand Up @@ -162,7 +162,7 @@ var firstOffersPage = `{
"href": "https://horizon-testnet.stellar.org/accounts/GBZ5OD56VRTRQKMNADD6VUZUG3FCILMAMYQY5ZSC3AW3GBXNEPIK76IG"
}
},
"id": 2946581,
"id": "2946581",
"paging_token": "2946581",
"seller": "GBZ5OD56VRTRQKMNADD6VUZUG3FCILMAMYQY5ZSC3AW3GBXNEPIK76IG",
"selling": {
Expand Down
16 changes: 8 additions & 8 deletions clients/horizonclient/trade_aggregation_request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ var tradeAggsResponse = `{
"_embedded": {
"records": [
{
"timestamp": 1517522400000,
"trade_count": 26,
"timestamp": "1517522400000",
"trade_count": "26",
"base_volume": "27575.0201596",
"counter_volume": "5085.6410385",
"avg": "0.1844293",
Expand All @@ -211,8 +211,8 @@ var tradeAggsResponse = `{
}
},
{
"timestamp": 1517526000000,
"trade_count": 15,
"timestamp": "1517526000000",
"trade_count": "15",
"base_volume": "3913.8224543",
"counter_volume": "719.4993608",
"avg": "0.1838355",
Expand Down Expand Up @@ -256,8 +256,8 @@ var firstTradeAggsPage = `{
"_embedded": {
"records": [
{
"timestamp": 1565026860000,
"trade_count": 3,
"timestamp": "1565026860000",
"trade_count": "3",
"base_volume": "23781.2128418",
"counter_volume": "2.0000000",
"avg": "0.0000841",
Expand All @@ -283,8 +283,8 @@ var firstTradeAggsPage = `{
}
},
{
"timestamp": 1565026920000,
"trade_count": 1,
"timestamp": "1565026920000",
"trade_count": "1",
"base_volume": "11890.6052319",
"counter_volume": "0.9999999",
"avg": "0.0000841",
Expand Down
7 changes: 3 additions & 4 deletions protocols/horizon/effects/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ type AccountFlagsUpdated struct {

type SequenceBumped struct {
Base
NewSeq int64 `json:"new_seq"`
NewSeq int64 `json:"new_seq,string"`
}

// UnmarshalJSON is the custom unmarshal method for SequenceBumped. It allows
Expand Down Expand Up @@ -280,9 +280,8 @@ type TrustlineDeauthorized struct {

type Trade struct {
Base
Seller string `json:"seller"`
// Action needed in release: horizon-v0.25.0
OfferID int64 `json:"offer_id"`
Seller string `json:"seller"`
OfferID int64 `json:"offer_id,string"`
SoldAmount string `json:"sold_amount"`
SoldAssetType string `json:"sold_asset_type"`
SoldAssetCode string `json:"sold_asset_code,omitempty"`
Expand Down
9 changes: 3 additions & 6 deletions protocols/horizon/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,7 @@ type Offer struct {
OfferMaker hal.Link `json:"offer_maker"`
} `json:"_links"`

// Action needed in release: horizon-v0.25.0
ID int64 `json:"id"`
ID int64 `json:"id,string"`
PT string `json:"paging_token"`
Seller string `json:"seller"`
Selling Asset `json:"selling"`
Expand Down Expand Up @@ -384,10 +383,8 @@ type TradeEffect struct {

// TradeAggregation represents trade data aggregation over a period of time
type TradeAggregation struct {
// Action needed in release: horizon-v0.22.0
Timestamp int64 `json:"timestamp"`
// Action needed in release: horizon-v0.22.0
TradeCount int64 `json:"trade_count"`
Timestamp int64 `json:"timestamp,string"`
TradeCount int64 `json:"trade_count,string"`
BaseVolume string `json:"base_volume"`
CounterVolume string `json:"counter_volume"`
Average string `json:"avg"`
Expand Down
6 changes: 2 additions & 4 deletions protocols/horizon/operations/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,16 +151,14 @@ type CreatePassiveSellOffer struct {
// is ManageSellOffer.
type ManageSellOffer struct {
Offer
// Action needed in release: horizon-v0.25.0
OfferID int64 `json:"offer_id"`
OfferID int64 `json:"offer_id,string"`
}

// ManageBuyOffer is the json resource representing a single operation whose type
// is ManageBuyOffer.
type ManageBuyOffer struct {
Offer
// Action needed in release: horizon-v0.25.0
OfferID int64 `json:"offer_id"`
OfferID int64 `json:"offer_id,string"`
}

// SetOptions is the json resource representing a single operation whose type is
Expand Down
9 changes: 9 additions & 0 deletions services/horizon/internal/actions_operation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,15 @@ func TestOperationEffect_BumpSequence(t *testing.T) {
var result []effects.SequenceBumped
ht.UnmarshalPage(w.Body, &result)
ht.Assert.Equal(int64(300000000000), result[0].NewSeq)

data, err := json.Marshal(&result[0])
ht.Assert.NoError(err)
effect := struct {
NewSeq string `json:"new_seq"`
}{}

json.Unmarshal(data, &effect)
ht.Assert.Equal("300000000000", effect.NewSeq)
}
}

Expand Down

0 comments on commit 4bbfbd5

Please sign in to comment.