Skip to content

Commit 22638d9

Browse files
committed
feat: expose Validate method
1 parent ac50e65 commit 22638d9

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

account.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ var (
2727

2828
func NewAccountID(chainID ChainID, address string) (AccountID, error) {
2929
aID := AccountID{chainID, address}
30-
if err := aID.validate(); err != nil {
30+
if err := aID.Validate(); err != nil {
3131
return AccountID{}, err
3232
}
3333

@@ -38,8 +38,8 @@ func UnsafeAccountID(chainID ChainID, address string) AccountID {
3838
return AccountID{chainID, address}
3939
}
4040

41-
func (c AccountID) validate() error {
42-
if err := c.ChainID.validate(); err != nil {
41+
func (c AccountID) Validate() error {
42+
if err := c.ChainID.Validate(); err != nil {
4343
return err
4444
}
4545

@@ -51,7 +51,7 @@ func (c AccountID) validate() error {
5151
}
5252

5353
func (c AccountID) String() string {
54-
if err := c.validate(); err != nil {
54+
if err := c.Validate(); err != nil {
5555
panic(err)
5656
}
5757
return c.ChainID.String() + ":" + c.Address
@@ -64,7 +64,7 @@ func (c *AccountID) Parse(s string) error {
6464
}
6565

6666
*c = AccountID{ChainID{split[0], split[1]}, split[2]}
67-
if err := c.validate(); err != nil {
67+
if err := c.Validate(); err != nil {
6868
return err
6969
}
7070

@@ -84,15 +84,15 @@ func (c *AccountID) UnmarshalJSON(data []byte) error {
8484
return err
8585
}
8686

87-
if err := c.validate(); err != nil {
87+
if err := c.Validate(); err != nil {
8888
return err
8989
}
9090

9191
return nil
9292
}
9393

9494
func (c AccountID) MarshalJSON() ([]byte, error) {
95-
if err := c.validate(); err != nil {
95+
if err := c.Validate(); err != nil {
9696
return nil, err
9797
}
9898

@@ -129,7 +129,7 @@ type EVMAccountID struct {
129129

130130
func NewEVMAccountID(chainID ChainID, address string) (EVMAccountID, error) {
131131
aID := AccountID{chainID, address}
132-
if err := aID.validate(); err != nil {
132+
if err := aID.Validate(); err != nil {
133133
return EVMAccountID{}, err
134134
}
135135

asset.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ var (
2323

2424
func NewAssetID(chainID ChainID, namespace, reference string) (AssetID, error) {
2525
aID := AssetID{chainID, namespace, reference}
26-
if err := aID.validate(); err != nil {
26+
if err := aID.Validate(); err != nil {
2727
return AssetID{}, err
2828
}
2929

@@ -34,7 +34,7 @@ func UnsafeAssetID(chainID ChainID, namespace, reference string) AssetID {
3434
return AssetID{chainID, namespace, reference}
3535
}
3636

37-
func (a AssetID) validate() error {
37+
func (a AssetID) Validate() error {
3838
if ok := assetNamespaceRegex.Match([]byte(a.Namespace)); !ok {
3939
return errors.New("asset namespace does not match spec")
4040
}
@@ -47,7 +47,7 @@ func (a AssetID) validate() error {
4747
}
4848

4949
func (a AssetID) String() string {
50-
if err := a.validate(); err != nil {
50+
if err := a.Validate(); err != nil {
5151
panic(err)
5252
}
5353
return a.ChainID.String() + "/" + a.Namespace + ":" + a.Reference
@@ -70,7 +70,7 @@ func (a *AssetID) Parse(s string) error {
7070
}
7171

7272
*a = AssetID{*cID, asset[0], asset[1]}
73-
if err := a.validate(); err != nil {
73+
if err := a.Validate(); err != nil {
7474
return err
7575
}
7676

@@ -90,15 +90,15 @@ func (a *AssetID) UnmarshalJSON(data []byte) error {
9090
return err
9191
}
9292

93-
if err := a.validate(); err != nil {
93+
if err := a.Validate(); err != nil {
9494
return err
9595
}
9696

9797
return nil
9898
}
9999

100100
func (a AssetID) MarshalJSON() ([]byte, error) {
101-
if err := a.validate(); err != nil {
101+
if err := a.Validate(); err != nil {
102102
return nil, err
103103
}
104104

chain.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ var (
2222

2323
func NewChainID(namespace, reference string) (ChainID, error) {
2424
cID := ChainID{namespace, reference}
25-
if err := cID.validate(); err != nil {
25+
if err := cID.Validate(); err != nil {
2626
return ChainID{}, err
2727
}
2828

@@ -33,7 +33,7 @@ func UnsafeChainID(namespace, reference string) ChainID {
3333
return ChainID{namespace, reference}
3434
}
3535

36-
func (c ChainID) validate() error {
36+
func (c ChainID) Validate() error {
3737
if ok := chainNamespaceRegex.Match([]byte(c.Namespace)); !ok {
3838
return errors.New("chain namespace does not match spec")
3939
}
@@ -46,7 +46,7 @@ func (c ChainID) validate() error {
4646
}
4747

4848
func (c ChainID) String() string {
49-
if err := c.validate(); err != nil {
49+
if err := c.Validate(); err != nil {
5050
panic(err)
5151
}
5252
return c.Namespace + ":" + c.Reference
@@ -59,7 +59,7 @@ func (c *ChainID) Parse(s string) error {
5959
}
6060

6161
*c = ChainID{split[0], split[1]}
62-
if err := c.validate(); err != nil {
62+
if err := c.Validate(); err != nil {
6363
return err
6464
}
6565

@@ -79,15 +79,15 @@ func (c *ChainID) UnmarshalJSON(data []byte) error {
7979
return err
8080
}
8181

82-
if err := c.validate(); err != nil {
82+
if err := c.Validate(); err != nil {
8383
return err
8484
}
8585

8686
return nil
8787
}
8888

8989
func (c ChainID) MarshalJSON() ([]byte, error) {
90-
if err := c.validate(); err != nil {
90+
if err := c.Validate(); err != nil {
9191
return nil, err
9292
}
9393

0 commit comments

Comments
 (0)