Skip to content

Commit b7bec9f

Browse files
Remove addition of protocols/horizon dependency
1 parent f20703f commit b7bec9f

File tree

3 files changed

+7
-46
lines changed

3 files changed

+7
-46
lines changed

txnbuild/set_options.go

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package txnbuild
22

33
import (
4-
hProtocol "github.com/stellar/go/protocols/horizon"
54
"github.com/stellar/go/support/errors"
65
"github.com/stellar/go/xdr"
76
)
@@ -33,25 +32,6 @@ type Signer struct {
3332
Weight Threshold
3433
}
3534

36-
// SignerFromHorizon converts a signer retrieved from Horizon to a txnbuild
37-
// Signer.
38-
func SignerFromHorizon(horizonSigner hProtocol.Signer) Signer {
39-
return Signer{
40-
Address: horizonSigner.Key,
41-
Weight: Threshold(horizonSigner.Weight),
42-
}
43-
}
44-
45-
// SignersFromHorizon converts a list of signers retrieved from Horizon to
46-
// txnbuild Signers.
47-
func SignersFromHorizon(horizonSigners []hProtocol.Signer) []Signer {
48-
signers := make([]Signer, 0, len(horizonSigners))
49-
for _, hs := range horizonSigners {
50-
signers = append(signers, SignerFromHorizon(hs))
51-
}
52-
return signers
53-
}
54-
5535
// NewHomeDomain is syntactic sugar that makes instantiating SetOptions more convenient.
5636
func NewHomeDomain(hd string) *string {
5737
return &hd

txnbuild/set_options_test.go

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package txnbuild
33
import (
44
"testing"
55

6-
hProtocol "github.com/stellar/go/protocols/horizon"
76
"github.com/stellar/go/xdr"
87
"github.com/stretchr/testify/assert"
98
)
@@ -137,27 +136,3 @@ func TestEmptyHomeDomainOK(t *testing.T) {
137136
assert.Equal(t, string(*options.xdrOp.HomeDomain), "", "empty string home domain is set")
138137

139138
}
140-
141-
func TestSignerFromHorizon(t *testing.T) {
142-
horizonSigner := hProtocol.Signer{Key: "GAABGBW5DINUS456OTHH6IUPTQSQZVVFCZGAO467OLIPFUWTMV6XR5XS", Weight: 10}
143-
wantSigner := Signer{Address: "GAABGBW5DINUS456OTHH6IUPTQSQZVVFCZGAO467OLIPFUWTMV6XR5XS", Weight: 10}
144-
signer := SignerFromHorizon(horizonSigner)
145-
assert.Equal(t, wantSigner, signer)
146-
}
147-
148-
func TestSignersFromHorizon(t *testing.T) {
149-
horizonSigners := []hProtocol.Signer{
150-
{Key: "GAABGBW5DINUS456OTHH6IUPTQSQZVVFCZGAO467OLIPFUWTMV6XR5XS", Weight: 0},
151-
{Key: "GAT4FUGQNKOIDLOIXCJJYFSAFJHQY5MZEZLRBXXFKDCXGUHJQ63XZFTD", Weight: 10},
152-
{Key: "GCB35H32SU5ME4OALQUPOM4AADJICL2H2NLWAGLOMMTSYOVTXWYP6Q4T", Weight: 100},
153-
{Key: "GAVJHRCK5CEFE3MHL4JALMNX35Z5NLUIODSJIC44VRRLQQZGTDJWANV4", Weight: 255},
154-
}
155-
wantSigners := []Signer{
156-
{Address: "GAABGBW5DINUS456OTHH6IUPTQSQZVVFCZGAO467OLIPFUWTMV6XR5XS", Weight: 0},
157-
{Address: "GAT4FUGQNKOIDLOIXCJJYFSAFJHQY5MZEZLRBXXFKDCXGUHJQ63XZFTD", Weight: 10},
158-
{Address: "GCB35H32SU5ME4OALQUPOM4AADJICL2H2NLWAGLOMMTSYOVTXWYP6Q4T", Weight: 100},
159-
{Address: "GAVJHRCK5CEFE3MHL4JALMNX35Z5NLUIODSJIC44VRRLQQZGTDJWANV4", Weight: 255},
160-
}
161-
signers := SignersFromHorizon(horizonSigners)
162-
assert.Equal(t, wantSigners, signers)
163-
}

txnbuild/transaction_challenge_example_test.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,13 @@ func ExampleVerifyChallengeTxThreshold() {
9292

9393
if clientAccountExists {
9494
// Server gets list of signers from account
95-
signers := txnbuild.SignersFromHorizon(horizonClientAccount.Signers)
95+
signers := make([]txnbuild.Signer, 0, len(horizonClientAccount.Signers))
96+
for _, hs := range horizonClientAccount.Signers {
97+
signers = append(signers, txnbuild.Signer{
98+
Address: hs.Key,
99+
Weight: txnbuild.Threshold(hs.Weight),
100+
})
101+
}
96102

97103
// Server chooses the threshold to require: low, med or high
98104
threshold := txnbuild.Threshold(horizonClientAccount.Thresholds.MedThreshold)

0 commit comments

Comments
 (0)