Skip to content

Commit

Permalink
Include all flags in allow trust operation details.
Browse files Browse the repository at this point in the history
  • Loading branch information
abuiles committed Mar 30, 2020
1 parent 53ccc09 commit 750cca0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -257,14 +257,8 @@ func (operation *transactionOperationWrapper) Details() map[string]interface{} {
assetDetails(details, op.Asset.ToAsset(*source), "")
details["trustee"] = source.Address()
details["trustor"] = op.Trustor.Address()
switch {
case xdr.TrustLineFlags(op.Authorize).IsAuthorized():
details["authorize"] = xdr.TrustLineFlags(op.Authorize).IsAuthorized()
case xdr.TrustLineFlags(op.Authorize).IsAuthorizedToMaintainLiabilitiesFlag():
details["authorize_to_maintain_liabilities"] = xdr.TrustLineFlags(op.Authorize).IsAuthorizedToMaintainLiabilitiesFlag()
default:
details["authorize"] = false
}
details["authorize"] = xdr.TrustLineFlags(op.Authorize).IsAuthorized()
details["authorize_to_maintain_liabilities"] = xdr.TrustLineFlags(op.Authorize).IsAuthorized() || xdr.TrustLineFlags(op.Authorize).IsAuthorizedToMaintainLiabilitiesFlag()
case xdr.OperationTypeAccountMerge:
aid := operation.operation.Body.MustDestination()
details["account"] = source.Address()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,12 +443,13 @@ func TestTransactionOperationDetails(t *testing.T) {
hash: "6d2e30fd57492bf2e2b132e1bc91a548a369189bebf77eb2b3d829121a9d2c50",
index: 0,
expected: map[string]interface{}{
"asset_code": "USD",
"asset_issuer": "GD4SMOE3VPSF7ZR3CTEQ3P5UNTBMEJDA2GLXTHR7MMARANKKJDZ7RPGF",
"asset_type": "credit_alphanum4",
"authorize": true,
"trustee": "GD4SMOE3VPSF7ZR3CTEQ3P5UNTBMEJDA2GLXTHR7MMARANKKJDZ7RPGF",
"trustor": "GCVW5LCRZFP7PENXTAGOVIQXADDNUXXZJCNKF4VQB2IK7W2LPJWF73UG",
"asset_code": "USD",
"asset_issuer": "GD4SMOE3VPSF7ZR3CTEQ3P5UNTBMEJDA2GLXTHR7MMARANKKJDZ7RPGF",
"asset_type": "credit_alphanum4",
"authorize": true,
"authorize_to_maintain_liabilities": true,
"trustee": "GD4SMOE3VPSF7ZR3CTEQ3P5UNTBMEJDA2GLXTHR7MMARANKKJDZ7RPGF",
"trustor": "GCVW5LCRZFP7PENXTAGOVIQXADDNUXXZJCNKF4VQB2IK7W2LPJWF73UG",
},
},
{
Expand Down Expand Up @@ -885,12 +886,13 @@ func TestTransactionOperationAllowTrustDetails(t *testing.T) {
},
},
expected: map[string]interface{}{
"asset_code": "COP",
"asset_issuer": "GDRW375MAYR46ODGF2WGANQC2RRZL7O246DYHHCGWTV2RE7IHE2QUQLD",
"asset_type": "credit_alphanum4",
"authorize": true,
"trustee": "GDRW375MAYR46ODGF2WGANQC2RRZL7O246DYHHCGWTV2RE7IHE2QUQLD",
"trustor": "GDQNY3PBOJOKYZSRMK2S7LHHGWZIUISD4QORETLMXEWXBI7KFZZMKTL3",
"asset_code": "COP",
"asset_issuer": "GDRW375MAYR46ODGF2WGANQC2RRZL7O246DYHHCGWTV2RE7IHE2QUQLD",
"asset_type": "credit_alphanum4",
"authorize": true,
"authorize_to_maintain_liabilities": true,
"trustee": "GDRW375MAYR46ODGF2WGANQC2RRZL7O246DYHHCGWTV2RE7IHE2QUQLD",
"trustor": "GDQNY3PBOJOKYZSRMK2S7LHHGWZIUISD4QORETLMXEWXBI7KFZZMKTL3",
},
},
{
Expand All @@ -910,6 +912,7 @@ func TestTransactionOperationAllowTrustDetails(t *testing.T) {
"asset_code": "COP",
"asset_issuer": "GDRW375MAYR46ODGF2WGANQC2RRZL7O246DYHHCGWTV2RE7IHE2QUQLD",
"asset_type": "credit_alphanum4",
"authorize": false,
"authorize_to_maintain_liabilities": true,
"trustee": "GDRW375MAYR46ODGF2WGANQC2RRZL7O246DYHHCGWTV2RE7IHE2QUQLD",
"trustor": "GDQNY3PBOJOKYZSRMK2S7LHHGWZIUISD4QORETLMXEWXBI7KFZZMKTL3",
Expand All @@ -929,12 +932,13 @@ func TestTransactionOperationAllowTrustDetails(t *testing.T) {
},
},
expected: map[string]interface{}{
"asset_code": "COP",
"asset_issuer": "GDRW375MAYR46ODGF2WGANQC2RRZL7O246DYHHCGWTV2RE7IHE2QUQLD",
"asset_type": "credit_alphanum4",
"authorize": false,
"trustee": "GDRW375MAYR46ODGF2WGANQC2RRZL7O246DYHHCGWTV2RE7IHE2QUQLD",
"trustor": "GDQNY3PBOJOKYZSRMK2S7LHHGWZIUISD4QORETLMXEWXBI7KFZZMKTL3",
"asset_code": "COP",
"asset_issuer": "GDRW375MAYR46ODGF2WGANQC2RRZL7O246DYHHCGWTV2RE7IHE2QUQLD",
"asset_type": "credit_alphanum4",
"authorize": false,
"authorize_to_maintain_liabilities": false,
"trustee": "GDRW375MAYR46ODGF2WGANQC2RRZL7O246DYHHCGWTV2RE7IHE2QUQLD",
"trustor": "GDQNY3PBOJOKYZSRMK2S7LHHGWZIUISD4QORETLMXEWXBI7KFZZMKTL3",
},
},
}
Expand Down

0 comments on commit 750cca0

Please sign in to comment.