-
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow digits in first segment of account addresses (#839)
- Loading branch information
Showing
18 changed files
with
329 additions
and
1,259 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package ledger | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestValidateAddress(t *testing.T) { | ||
t.Parallel() | ||
|
||
type testCase struct { | ||
name string | ||
address string | ||
shouldBeOk bool | ||
} | ||
|
||
testsCases := []testCase{ | ||
{ | ||
name: "nominal", | ||
address: "foo:bar", | ||
shouldBeOk: true, | ||
}, | ||
{ | ||
name: "short segment", | ||
address: "a:b", | ||
shouldBeOk: true, | ||
}, | ||
{ | ||
name: "only one segment", | ||
address: "a", | ||
shouldBeOk: true, | ||
}, | ||
{ | ||
name: "using underscore as first char", | ||
address: "_a", | ||
shouldBeOk: true, | ||
}, | ||
{ | ||
name: "using digits", | ||
address: "_0123", | ||
shouldBeOk: true, | ||
}, | ||
{ | ||
name: "using empty segment", | ||
address: "a:", | ||
shouldBeOk: false, | ||
}, | ||
} | ||
|
||
for _, testCase := range testsCases { | ||
testCase := testCase | ||
t.Run(testCase.name, func(t *testing.T) { | ||
require.Equal(t, testCase.shouldBeOk, ValidateAddress(testCase.address)) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
components/ledger/internal/machine/script/parser/NumScriptLexer.interp
Large diffs are not rendered by default.
Oops, something went wrong.
302 changes: 151 additions & 151 deletions
302
components/ledger/internal/machine/script/parser/numscript_lexer.go
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
VERSION --arg-scope-and-set --pass-args 0.7 | ||
|
||
ARG core=github.com/formancehq/earthly:v0.5.2 | ||
IMPORT $core AS core | ||
|
||
FROM core+base-image | ||
|
||
sources: | ||
WORKDIR src | ||
COPY go.* . | ||
COPY *.go . | ||
SAVE ARTIFACT /src | ||
|
||
tidy: | ||
FROM core+builder-image | ||
COPY (+sources/*) /src | ||
WORKDIR /src | ||
RUN --mount=type=cache,id=gomod,target=${GOPATH}/pkg/mod \ | ||
--mount=type=cache,id=gobuild,target=/root/.cache/go-build \ | ||
go mod tidy | ||
SAVE ARTIFACT go.* AS LOCAL ./ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package logging | ||
|
||
// https://github.com/garsue/watermillzap/blob/master/adapter.go | ||
import ( | ||
"github.com/ThreeDotsLabs/watermill" | ||
"go.uber.org/zap" | ||
) | ||
|
||
// Logger implements watermill.LoggerAdapter with *zap.Logger. | ||
type ZapLoggerAdapter struct { | ||
backend *zap.Logger | ||
fields watermill.LogFields | ||
} | ||
|
||
// NewLogger returns new watermill.LoggerAdapter using passed *zap.Logger as backend. | ||
func NewZapLoggerAdapter(z *zap.Logger) watermill.LoggerAdapter { | ||
return &ZapLoggerAdapter{backend: z} | ||
} | ||
|
||
// Error writes error log with message, error and some fields. | ||
func (l *ZapLoggerAdapter) Error(msg string, err error, fields watermill.LogFields) { | ||
fields = l.fields.Add(fields) | ||
fs := make([]zap.Field, 0, len(fields)+1) | ||
fs = append(fs, zap.Error(err)) | ||
for k, v := range fields { | ||
fs = append(fs, zap.Any(k, v)) | ||
} | ||
l.backend.Error(msg, fs...) | ||
} | ||
|
||
// Info writes info log with message and some fields. | ||
func (l *ZapLoggerAdapter) Info(msg string, fields watermill.LogFields) { | ||
fields = l.fields.Add(fields) | ||
fs := make([]zap.Field, 0, len(fields)+1) | ||
for k, v := range fields { | ||
fs = append(fs, zap.Any(k, v)) | ||
} | ||
l.backend.Info(msg, fs...) | ||
} | ||
|
||
// Debug writes debug log with message and some fields. | ||
func (l *ZapLoggerAdapter) Debug(msg string, fields watermill.LogFields) { | ||
fields = l.fields.Add(fields) | ||
fs := make([]zap.Field, 0, len(fields)+1) | ||
for k, v := range fields { | ||
fs = append(fs, zap.Any(k, v)) | ||
} | ||
l.backend.Debug(msg, fs...) | ||
} | ||
|
||
// Trace writes debug log instead of trace log because zap does not support trace level logging. | ||
func (l *ZapLoggerAdapter) Trace(msg string, fields watermill.LogFields) { | ||
fields = l.fields.Add(fields) | ||
fs := make([]zap.Field, 0, len(fields)+1) | ||
for k, v := range fields { | ||
fs = append(fs, zap.Any(k, v)) | ||
} | ||
l.backend.Debug(msg, fs...) | ||
} | ||
|
||
// With returns new LoggerAdapter with passed fields. | ||
func (l *ZapLoggerAdapter) With(fields watermill.LogFields) watermill.LoggerAdapter { | ||
return &ZapLoggerAdapter{ | ||
backend: l.backend, | ||
fields: l.fields.Add(fields), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
3e645a1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
docs – ./
docs-formance.vercel.app
docs-git-main-formance.vercel.app
developers.numary.com
docs.numary.com
docs.formance.com
developers.formance.com