Skip to content

Commit 62ea18a

Browse files
authored
Merge pull request #180 from XRPLF/v0.1.x
chore: sync main branch with v0.1.x
2 parents 7efab35 + b0395a7 commit 62ea18a

File tree

479 files changed

+7783
-2487
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

479 files changed

+7783
-2487
lines changed
Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
name: XRPL-GO Lint and Test
22
on:
33
push:
4-
branches: [ main ]
4+
branches: [main]
55
pull_request:
6-
branches: [ '**' ]
6+
branches: ["**"]
77
jobs:
88
build:
99
name: Lint and Test
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v3
13-
- uses: actions/setup-go@v3
14-
with:
15-
go-version: '1.23'
16-
cache: true
17-
18-
- name: Install golangci-lint
19-
run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.8
20-
21-
- name: Run linter
22-
run: make lint
23-
24-
- name: Run tests
25-
run: make test-ci
12+
- uses: actions/checkout@v4
13+
- uses: actions/setup-go@v4
14+
with:
15+
go-version: "1.24"
16+
cache: true
17+
18+
- name: Install golangci-lint
19+
run: go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.2.2
20+
21+
- name: Run linter.
22+
run: make lint
23+
24+
- name: Run tests
25+
run: make test-ci

.golangci.yml

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,36 @@
1+
version: "2"
2+
13
linters:
24
enable:
3-
- gofmt
45
- govet
5-
# - dupl TODO: enable
6-
- gocritic
76
- errcheck
87
- staticcheck
98
- ineffassign
10-
- typecheck
11-
- gosimple
12-
- misspell
13-
- unparam
149
- unused
10+
- gocritic
1511
- gosec
12+
- misspell
13+
- unparam
1614
- revive
15+
exclusions:
16+
rules:
17+
- path: examples/
18+
linters:
19+
- revive
20+
text: "package-comments"
21+
22+
formatters:
23+
enable:
24+
- gofmt
1725

1826
run:
19-
timeout: 1m
2027
tests: false
21-
22-
issues:
23-
exclude-rules:
24-
- path: examples/
25-
linters:
26-
- gosec
27-
- path: _test\.go
28-
linters:
29-
- errcheck
30-
- path: _mock\.go
31-
linters:
32-
- errcheck
33-
- unused
28+
timeout: 1m
3429

3530
output:
3631
formats:
37-
- format: colored-line-number
38-
print-issued-lines: true
39-
print-linter-name: true
32+
text:
33+
path: stdout
34+
color: true
35+
print-linter-name: true
36+
print-issued-lines: true

CHANGELOG.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,50 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Refactored
11+
12+
- `TxResponse` `Meta` field type changed to `TxMetadataBuilder`, enabling custom parsing for specific transactions metadata such as `Payment`, `NFTokenMint`, etc.
13+
14+
## [v0.1.13]
15+
16+
### Added
17+
18+
#### binary-codec
19+
20+
- `Number` and `AssetScale` fields to `definitions.json`.
21+
22+
#### xrpl
23+
24+
- `PermissionedDEX` support (XLS-81d).
25+
26+
### Fixed
27+
28+
#### xrpl
29+
30+
- `OracleSet` transaction to Flatten correctly and `Oracle` PriceDataSeries array.
31+
32+
#### binary-codec
33+
34+
- `definitions.json` where `LastUpdatedTime` had a typo issue.
35+
36+
### Refactored
37+
38+
#### xrpl
39+
40+
- Replaced `bip32` and `bip39` dependencies due to repository deletion and, therefore, dependency outdated.
41+
42+
## [v0.1.12]
43+
1044
### Added
1145

1246
#### xrpl
1347

1448
- Adds `PermissionedDomain` ledger entry type (XLS-80d).
49+
- Adds `TokenEscrow` support (XLS-85).
50+
51+
### Fixed
52+
53+
- Flatten function in Escrow transaction types for Destination and Owner fields.
1554

1655
## [v0.1.11]
1756

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.23-alpine AS install
1+
FROM golang:1.24-alpine AS install
22
RUN apk add --no-cache make git ca-certificates
33

44
WORKDIR /app
@@ -7,7 +7,7 @@ RUN go mod download
77
COPY . .
88

99
FROM install AS lint
10-
RUN go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.8
10+
RUN go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.2.2
1111
RUN make lint
1212

1313
FROM lint AS test

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ INTEGRATION_TEST_PACKAGES = ./xrpl/transaction/integration
88
PARALLEL_TESTS = 4
99
TEST_TIMEOUT = 5m
1010

11+
GOLANGCI_LINT_MAJOR_VERSION = 2
12+
GOLANGCI_LINT_VERSION = v2.2.2
13+
1114
RIPPLED_IMAGE = rippleci/rippled:2.3.0
1215

1316
################################################################################
@@ -16,11 +19,13 @@ RIPPLED_IMAGE = rippleci/rippled:2.3.0
1619

1720
lint:
1821
@echo "Linting Go code..."
22+
@go install github.com/golangci/golangci-lint/v$(GOLANGCI_LINT_MAJOR_VERSION)/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)
1923
@golangci-lint run
2024
@echo "Linting complete!"
2125

2226
lint-fix:
2327
@echo "Fixing Go code..."
28+
@go install github.com/golangci/golangci-lint/v$(GOLANGCI_LINT_MAJOR_VERSION)/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)
2429
@gofmt -w -s .
2530
@echo "Fixing complete!"
2631

address-codec/alphabet.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// btcsuite base58 repo: https://github.com/btcsuite/btcd/tree/master/btcutil/base58
33
//
44
// AUTOGENERATED by gen_alphabet.go; do not edit.
5+
6+
// Package addresscodec provides base58 encoding and decoding functionality for XRPL addresses and keys.
57
package addresscodec
68

79
const (

address-codec/base58.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ var bigRadix = [...]*big.Int{
2020

2121
var bigRadix10 = big.NewInt(58 * 58 * 58 * 58 * 58 * 58 * 58 * 58 * 58 * 58)
2222

23-
// Encodes a byte slice to a base58 string encoded with the XRP alphabet.
23+
// EncodeBase58 encodes a byte slice to a base58 string using the XRP alphabet.
2424
func EncodeBase58(b []byte) string {
2525

2626
x := new(big.Int)
@@ -76,7 +76,7 @@ func EncodeBase58(b []byte) string {
7676

7777
}
7878

79-
// Decodes a modified base58 string to a byte slice.
79+
// DecodeBase58 decodes a modified base58 string to a byte slice.
8080
func DecodeBase58(b string) []byte {
8181
answer := big.NewInt(0)
8282
scratch := new(big.Int)

address-codec/base58check.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ func checksum(input []byte) (cksum [4]byte) {
1212
return cksum
1313
}
1414

15-
// CheckEncode prepends a version byte, appends a four byte checksum and returns
16-
// a base58 encoding of the byte slice.
15+
// Base58CheckEncode prepends a version byte, appends a four-byte checksum, and returns
16+
// the Base58Check encoding of the input byte slice.
1717
func Base58CheckEncode(input []byte, prefix ...byte) string {
1818
b := make([]byte, 0, 1+len(input)+4)
1919
b = append(b, prefix...)
@@ -24,7 +24,7 @@ func Base58CheckEncode(input []byte, prefix ...byte) string {
2424
return EncodeBase58(b)
2525
}
2626

27-
// CheckDecode decodes a string that was encoded with CheckEncode and verifies the checksum.
27+
// Base58CheckDecode decodes a Base58Check encoded string and verifies the checksum.
2828
func Base58CheckDecode(input string) (result []byte, err error) {
2929
decoded := DecodeBase58(input)
3030
if len(decoded) < 5 {

address-codec/codec.go

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,33 @@ import (
1010
)
1111

1212
const (
13-
// Lengths in bytes
14-
AccountAddressLength = 20
13+
// AccountAddressLength is the length in bytes of a classic account address.
14+
AccountAddressLength = 20
15+
16+
// AccountPublicKeyLength is the length in bytes of an account public key.
1517
AccountPublicKeyLength = 33
16-
FamilySeedLength = 16
17-
NodePublicKeyLength = 33
1818

19-
// Account/classic address prefix - value is 0
19+
// FamilySeedLength is the length in bytes of a family seed.
20+
FamilySeedLength = 16
21+
22+
// NodePublicKeyLength is the length in bytes of a node/validation public key.
23+
NodePublicKeyLength = 33
24+
25+
// AccountAddressPrefix is the classic address prefix (0x00).
2026
AccountAddressPrefix = 0x00
21-
// Account public key prefix - value is 35
27+
28+
// AccountPublicKeyPrefix is the prefix for account public keys (0x23).
2229
AccountPublicKeyPrefix = 0x23
23-
// Family seed prefix - value is 33
30+
31+
// FamilySeedPrefix is the prefix for family seeds (0x21).
2432
FamilySeedPrefix = 0x21
25-
// Node/validation public key prefix - value is 28
33+
34+
// NodePublicKeyPrefix is the prefix for node/validation public keys (0x1C).
2635
NodePublicKeyPrefix = 0x1C
2736
)
2837

29-
// Returns the base58 encoding of byte slice, with the given type prefix, whilst ensuring that the byte slice is the expected length.
38+
// Encode returns the Base58Check encoding of a byte slice with the given type prefix,
39+
// ensuring the byte slice has the expected length.
3040
func Encode(b []byte, typePrefix []byte, expectedLength int) (string, error) {
3141

3242
if len(b) != expectedLength {
@@ -36,7 +46,7 @@ func Encode(b []byte, typePrefix []byte, expectedLength int) (string, error) {
3646
return Base58CheckEncode(b, typePrefix...), nil
3747
}
3848

39-
// Returns the byte slice decoding of the base58-encoded string and prefix.
49+
// Decode returns the decoded byte slice of the base58-encoded string for the given prefix.
4050
func Decode(b58string string, typePrefix []byte) ([]byte, error) {
4151

4252
prefixLength := len(typePrefix)
@@ -51,7 +61,7 @@ func Decode(b58string string, typePrefix []byte) ([]byte, error) {
5161
return result, err
5262
}
5363

54-
// Returns the classic address from public key hex string.
64+
// EncodeClassicAddressFromPublicKeyHex returns the classic address from a public key hex string.
5565
func EncodeClassicAddressFromPublicKeyHex(pubkeyhex string) (string, error) {
5666

5767
pubkey, err := hex.DecodeString(pubkeyhex)
@@ -76,7 +86,7 @@ func EncodeClassicAddressFromPublicKeyHex(pubkeyhex string) (string, error) {
7686
return address, nil
7787
}
7888

79-
// Returns the decoded 'accountID' byte slice of the classic address.
89+
// DecodeClassicAddressToAccountID returns the prefix and accountID byte slice from a classic address.
8090
func DecodeClassicAddressToAccountID(cAddress string) (typePrefix, accountID []byte, err error) {
8191
if len(DecodeBase58(cAddress)) != 25 {
8292
return nil, nil, ErrInvalidClassicAddress
@@ -94,7 +104,7 @@ func EncodeAccountIDToClassicAddress(accountID []byte) (string, error) {
94104
return Base58CheckEncode(accountID, AccountAddressPrefix), nil
95105
}
96106

97-
// Returns a base58 encoding of a seed.
107+
// EncodeSeed returns a base58 encoding of a seed using the specified encoding type.
98108
func EncodeSeed(entropy []byte, encodingType interfaces.CryptoImplementation) (string, error) {
99109

100110
if len(entropy) != FamilySeedLength {
@@ -112,7 +122,7 @@ func EncodeSeed(entropy []byte, encodingType interfaces.CryptoImplementation) (s
112122

113123
}
114124

115-
// Returns decoded seed and its algorithm.
125+
// DecodeSeed returns the decoded seed and its corresponding algorithm.
116126
func DecodeSeed(seed string) ([]byte, interfaces.CryptoImplementation, error) {
117127

118128
// decoded := DecodeBase58(seed)
@@ -130,7 +140,7 @@ func DecodeSeed(seed string) ([]byte, interfaces.CryptoImplementation, error) {
130140

131141
}
132142

133-
// Returns the node public key encoding of the byte slice as a base58 string.
143+
// EncodeNodePublicKey returns the base58 encoding of a node public key byte slice.
134144
func EncodeNodePublicKey(b []byte) (string, error) {
135145

136146
if len(b) != NodePublicKeyLength {
@@ -142,7 +152,7 @@ func EncodeNodePublicKey(b []byte) (string, error) {
142152
return npk, nil
143153
}
144154

145-
// Returns the decoded node public key encoding as a byte slice from a base58 string.
155+
// DecodeNodePublicKey returns the decoded node public key byte slice from a base58 string.
146156
func DecodeNodePublicKey(key string) ([]byte, error) {
147157

148158
decodedNodeKey, err := Decode(key, []byte{NodePublicKeyPrefix})
@@ -153,7 +163,7 @@ func DecodeNodePublicKey(key string) ([]byte, error) {
153163
return decodedNodeKey, nil
154164
}
155165

156-
// Returns the account public key encoding of the byte slice as a base58 string.
166+
// EncodeAccountPublicKey returns the base58 encoding of an account public key byte slice.
157167
func EncodeAccountPublicKey(b []byte) (string, error) {
158168

159169
if len(b) != AccountPublicKeyLength {
@@ -165,7 +175,7 @@ func EncodeAccountPublicKey(b []byte) (string, error) {
165175
return apk, nil
166176
}
167177

168-
// Returns the decoded account public key encoding as a byte slice from a base58 string.
178+
// DecodeAccountPublicKey returns the decoded account public key byte slice from a base58 string.
169179
func DecodeAccountPublicKey(key string) ([]byte, error) {
170180

171181
decodedAccountKey, err := Decode(key, []byte{AccountPublicKeyPrefix})

address-codec/errors.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,23 @@ import (
66
)
77

88
var (
9-
// Static errors
9+
// address
1010

11-
// Invalid classic address
11+
// ErrInvalidClassicAddress indicates an invalid classic address.
1212
ErrInvalidClassicAddress = errors.New("invalid classic address")
13-
// Invalid seed
13+
// ErrInvalidSeed indicates an invalid seed; could not determine encoding algorithm.
1414
ErrInvalidSeed = errors.New("invalid seed; could not determine encoding algorithm")
15-
16-
// Invalid x-address
15+
// ErrInvalidXAddress indicates an invalid x-address.
1716
ErrInvalidXAddress = errors.New("invalid x-address")
18-
// Invalid tag
17+
// ErrInvalidTag indicates an invalid tag.
1918
ErrInvalidTag = errors.New("invalid tag")
20-
// Invalid accountId
21-
ErrInvalidAccountID = errors.New("invalid accountId")
22-
23-
// Invalid xrpl address, general error
19+
// ErrInvalidAccountID indicates an invalid account ID.
20+
ErrInvalidAccountID = errors.New("invalid account ID")
21+
// ErrInvalidAddressFormat indicates a general invalid XRPL address format.
2422
ErrInvalidAddressFormat = errors.New("invalid address format")
2523

24+
// checksum
25+
2626
// ErrChecksum indicates that the checksum of a check-encoded string does not verify against
2727
// the checksum.
2828
ErrChecksum = errors.New("checksum error")

0 commit comments

Comments
 (0)