diff --git a/README.md b/README.md
index 93e9fbb60..4dcbcb839 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
-# src
+# ledger
```go
import "github.com/formancehq/ledger"
diff --git a/internal/api/common/middleware_resolver_test.go b/internal/api/common/middleware_resolver_test.go
index 05a4240ec..1f63e4942 100644
--- a/internal/api/common/middleware_resolver_test.go
+++ b/internal/api/common/middleware_resolver_test.go
@@ -10,7 +10,6 @@ import (
"github.com/formancehq/go-libs/api"
"github.com/formancehq/go-libs/logging"
ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger"
- systemcontroller "github.com/formancehq/ledger/internal/controller/system"
"github.com/stretchr/testify/require"
"go.uber.org/mock/gomock"
)
@@ -73,8 +72,8 @@ func TestResolverMiddleware(t *testing.T) {
ctrl := gomock.NewController(t)
ctx := logging.TestingContext()
- systemController := systemcontroller.NewMockController(ctrl)
- ledgerController := ledgercontroller.NewMockController(ctrl)
+ systemController := NewSystemController(ctrl)
+ ledgerController := NewLedgerController(ctrl)
ledger := tc.ledger
diff --git a/internal/api/common/mocks.go b/internal/api/common/mocks.go
new file mode 100644
index 000000000..ffc0edce4
--- /dev/null
+++ b/internal/api/common/mocks.go
@@ -0,0 +1,3 @@
+//go:generate mockgen -write_source_comment=false -write_package_comment=false -source ../../controller/system/controller.go -destination mocks_system_controller_test.go -package common --mock_names Controller=SystemController . Controller
+//go:generate mockgen -write_source_comment=false -write_package_comment=false -source ../../controller/ledger/controller.go -destination mocks_ledger_controller_test.go -package common --mock_names Controller=LedgerController . Controller
+package common
\ No newline at end of file
diff --git a/internal/api/common/mocks_ledger_controller_test.go b/internal/api/common/mocks_ledger_controller_test.go
new file mode 100644
index 000000000..a3db56118
--- /dev/null
+++ b/internal/api/common/mocks_ledger_controller_test.go
@@ -0,0 +1,334 @@
+// Code generated by MockGen. DO NOT EDIT.
+//
+// Generated by this command:
+//
+// mockgen -write_source_comment=false -write_package_comment=false -source ../../controller/ledger/controller.go -destination mocks_ledger_controller_test.go -package common --mock_names Controller=LedgerController . Controller
+package common
+
+import (
+ context "context"
+ reflect "reflect"
+
+ bunpaginate "github.com/formancehq/go-libs/bun/bunpaginate"
+ migrations "github.com/formancehq/go-libs/migrations"
+ ledger "github.com/formancehq/ledger/internal"
+ ledger0 "github.com/formancehq/ledger/internal/controller/ledger"
+ gomock "go.uber.org/mock/gomock"
+)
+
+// LedgerController is a mock of Controller interface.
+type LedgerController struct {
+ ctrl *gomock.Controller
+ recorder *LedgerControllerMockRecorder
+}
+
+// LedgerControllerMockRecorder is the mock recorder for LedgerController.
+type LedgerControllerMockRecorder struct {
+ mock *LedgerController
+}
+
+// NewLedgerController creates a new mock instance.
+func NewLedgerController(ctrl *gomock.Controller) *LedgerController {
+ mock := &LedgerController{ctrl: ctrl}
+ mock.recorder = &LedgerControllerMockRecorder{mock}
+ return mock
+}
+
+// EXPECT returns an object that allows the caller to indicate expected use.
+func (m *LedgerController) EXPECT() *LedgerControllerMockRecorder {
+ return m.recorder
+}
+
+// CountAccounts mocks base method.
+func (m *LedgerController) CountAccounts(ctx context.Context, query ledger0.ListAccountsQuery) (int, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "CountAccounts", ctx, query)
+ ret0, _ := ret[0].(int)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// CountAccounts indicates an expected call of CountAccounts.
+func (mr *LedgerControllerMockRecorder) CountAccounts(ctx, query any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CountAccounts", reflect.TypeOf((*LedgerController)(nil).CountAccounts), ctx, query)
+}
+
+// CountTransactions mocks base method.
+func (m *LedgerController) CountTransactions(ctx context.Context, query ledger0.ListTransactionsQuery) (int, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "CountTransactions", ctx, query)
+ ret0, _ := ret[0].(int)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// CountTransactions indicates an expected call of CountTransactions.
+func (mr *LedgerControllerMockRecorder) CountTransactions(ctx, query any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CountTransactions", reflect.TypeOf((*LedgerController)(nil).CountTransactions), ctx, query)
+}
+
+// CreateTransaction mocks base method.
+func (m *LedgerController) CreateTransaction(ctx context.Context, parameters ledger0.Parameters[ledger0.RunScript]) (*ledger.CreatedTransaction, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "CreateTransaction", ctx, parameters)
+ ret0, _ := ret[0].(*ledger.CreatedTransaction)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// CreateTransaction indicates an expected call of CreateTransaction.
+func (mr *LedgerControllerMockRecorder) CreateTransaction(ctx, parameters any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateTransaction", reflect.TypeOf((*LedgerController)(nil).CreateTransaction), ctx, parameters)
+}
+
+// DeleteAccountMetadata mocks base method.
+func (m *LedgerController) DeleteAccountMetadata(ctx context.Context, parameters ledger0.Parameters[ledger0.DeleteAccountMetadata]) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "DeleteAccountMetadata", ctx, parameters)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// DeleteAccountMetadata indicates an expected call of DeleteAccountMetadata.
+func (mr *LedgerControllerMockRecorder) DeleteAccountMetadata(ctx, parameters any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteAccountMetadata", reflect.TypeOf((*LedgerController)(nil).DeleteAccountMetadata), ctx, parameters)
+}
+
+// DeleteTransactionMetadata mocks base method.
+func (m *LedgerController) DeleteTransactionMetadata(ctx context.Context, parameters ledger0.Parameters[ledger0.DeleteTransactionMetadata]) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "DeleteTransactionMetadata", ctx, parameters)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// DeleteTransactionMetadata indicates an expected call of DeleteTransactionMetadata.
+func (mr *LedgerControllerMockRecorder) DeleteTransactionMetadata(ctx, parameters any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteTransactionMetadata", reflect.TypeOf((*LedgerController)(nil).DeleteTransactionMetadata), ctx, parameters)
+}
+
+// Export mocks base method.
+func (m *LedgerController) Export(ctx context.Context, w ledger0.ExportWriter) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "Export", ctx, w)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// Export indicates an expected call of Export.
+func (mr *LedgerControllerMockRecorder) Export(ctx, w any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Export", reflect.TypeOf((*LedgerController)(nil).Export), ctx, w)
+}
+
+// GetAccount mocks base method.
+func (m *LedgerController) GetAccount(ctx context.Context, query ledger0.GetAccountQuery) (*ledger.Account, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetAccount", ctx, query)
+ ret0, _ := ret[0].(*ledger.Account)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetAccount indicates an expected call of GetAccount.
+func (mr *LedgerControllerMockRecorder) GetAccount(ctx, query any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccount", reflect.TypeOf((*LedgerController)(nil).GetAccount), ctx, query)
+}
+
+// GetAggregatedBalances mocks base method.
+func (m *LedgerController) GetAggregatedBalances(ctx context.Context, q ledger0.GetAggregatedBalanceQuery) (ledger.BalancesByAssets, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetAggregatedBalances", ctx, q)
+ ret0, _ := ret[0].(ledger.BalancesByAssets)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetAggregatedBalances indicates an expected call of GetAggregatedBalances.
+func (mr *LedgerControllerMockRecorder) GetAggregatedBalances(ctx, q any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAggregatedBalances", reflect.TypeOf((*LedgerController)(nil).GetAggregatedBalances), ctx, q)
+}
+
+// GetMigrationsInfo mocks base method.
+func (m *LedgerController) GetMigrationsInfo(ctx context.Context) ([]migrations.Info, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetMigrationsInfo", ctx)
+ ret0, _ := ret[0].([]migrations.Info)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetMigrationsInfo indicates an expected call of GetMigrationsInfo.
+func (mr *LedgerControllerMockRecorder) GetMigrationsInfo(ctx any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetMigrationsInfo", reflect.TypeOf((*LedgerController)(nil).GetMigrationsInfo), ctx)
+}
+
+// GetStats mocks base method.
+func (m *LedgerController) GetStats(ctx context.Context) (ledger0.Stats, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetStats", ctx)
+ ret0, _ := ret[0].(ledger0.Stats)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetStats indicates an expected call of GetStats.
+func (mr *LedgerControllerMockRecorder) GetStats(ctx any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetStats", reflect.TypeOf((*LedgerController)(nil).GetStats), ctx)
+}
+
+// GetTransaction mocks base method.
+func (m *LedgerController) GetTransaction(ctx context.Context, query ledger0.GetTransactionQuery) (*ledger.Transaction, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetTransaction", ctx, query)
+ ret0, _ := ret[0].(*ledger.Transaction)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetTransaction indicates an expected call of GetTransaction.
+func (mr *LedgerControllerMockRecorder) GetTransaction(ctx, query any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTransaction", reflect.TypeOf((*LedgerController)(nil).GetTransaction), ctx, query)
+}
+
+// GetVolumesWithBalances mocks base method.
+func (m *LedgerController) GetVolumesWithBalances(ctx context.Context, q ledger0.GetVolumesWithBalancesQuery) (*bunpaginate.Cursor[ledger.VolumesWithBalanceByAssetByAccount], error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetVolumesWithBalances", ctx, q)
+ ret0, _ := ret[0].(*bunpaginate.Cursor[ledger.VolumesWithBalanceByAssetByAccount])
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetVolumesWithBalances indicates an expected call of GetVolumesWithBalances.
+func (mr *LedgerControllerMockRecorder) GetVolumesWithBalances(ctx, q any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetVolumesWithBalances", reflect.TypeOf((*LedgerController)(nil).GetVolumesWithBalances), ctx, q)
+}
+
+// Import mocks base method.
+func (m *LedgerController) Import(ctx context.Context, stream chan ledger.Log) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "Import", ctx, stream)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// Import indicates an expected call of Import.
+func (mr *LedgerControllerMockRecorder) Import(ctx, stream any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Import", reflect.TypeOf((*LedgerController)(nil).Import), ctx, stream)
+}
+
+// IsDatabaseUpToDate mocks base method.
+func (m *LedgerController) IsDatabaseUpToDate(ctx context.Context) (bool, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "IsDatabaseUpToDate", ctx)
+ ret0, _ := ret[0].(bool)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// IsDatabaseUpToDate indicates an expected call of IsDatabaseUpToDate.
+func (mr *LedgerControllerMockRecorder) IsDatabaseUpToDate(ctx any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsDatabaseUpToDate", reflect.TypeOf((*LedgerController)(nil).IsDatabaseUpToDate), ctx)
+}
+
+// ListAccounts mocks base method.
+func (m *LedgerController) ListAccounts(ctx context.Context, query ledger0.ListAccountsQuery) (*bunpaginate.Cursor[ledger.Account], error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "ListAccounts", ctx, query)
+ ret0, _ := ret[0].(*bunpaginate.Cursor[ledger.Account])
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// ListAccounts indicates an expected call of ListAccounts.
+func (mr *LedgerControllerMockRecorder) ListAccounts(ctx, query any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListAccounts", reflect.TypeOf((*LedgerController)(nil).ListAccounts), ctx, query)
+}
+
+// ListLogs mocks base method.
+func (m *LedgerController) ListLogs(ctx context.Context, query ledger0.GetLogsQuery) (*bunpaginate.Cursor[ledger.Log], error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "ListLogs", ctx, query)
+ ret0, _ := ret[0].(*bunpaginate.Cursor[ledger.Log])
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// ListLogs indicates an expected call of ListLogs.
+func (mr *LedgerControllerMockRecorder) ListLogs(ctx, query any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListLogs", reflect.TypeOf((*LedgerController)(nil).ListLogs), ctx, query)
+}
+
+// ListTransactions mocks base method.
+func (m *LedgerController) ListTransactions(ctx context.Context, query ledger0.ListTransactionsQuery) (*bunpaginate.Cursor[ledger.Transaction], error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "ListTransactions", ctx, query)
+ ret0, _ := ret[0].(*bunpaginate.Cursor[ledger.Transaction])
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// ListTransactions indicates an expected call of ListTransactions.
+func (mr *LedgerControllerMockRecorder) ListTransactions(ctx, query any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListTransactions", reflect.TypeOf((*LedgerController)(nil).ListTransactions), ctx, query)
+}
+
+// RevertTransaction mocks base method.
+func (m *LedgerController) RevertTransaction(ctx context.Context, parameters ledger0.Parameters[ledger0.RevertTransaction]) (*ledger.RevertedTransaction, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "RevertTransaction", ctx, parameters)
+ ret0, _ := ret[0].(*ledger.RevertedTransaction)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// RevertTransaction indicates an expected call of RevertTransaction.
+func (mr *LedgerControllerMockRecorder) RevertTransaction(ctx, parameters any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RevertTransaction", reflect.TypeOf((*LedgerController)(nil).RevertTransaction), ctx, parameters)
+}
+
+// SaveAccountMetadata mocks base method.
+func (m *LedgerController) SaveAccountMetadata(ctx context.Context, parameters ledger0.Parameters[ledger0.SaveAccountMetadata]) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "SaveAccountMetadata", ctx, parameters)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// SaveAccountMetadata indicates an expected call of SaveAccountMetadata.
+func (mr *LedgerControllerMockRecorder) SaveAccountMetadata(ctx, parameters any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SaveAccountMetadata", reflect.TypeOf((*LedgerController)(nil).SaveAccountMetadata), ctx, parameters)
+}
+
+// SaveTransactionMetadata mocks base method.
+func (m *LedgerController) SaveTransactionMetadata(ctx context.Context, parameters ledger0.Parameters[ledger0.SaveTransactionMetadata]) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "SaveTransactionMetadata", ctx, parameters)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// SaveTransactionMetadata indicates an expected call of SaveTransactionMetadata.
+func (mr *LedgerControllerMockRecorder) SaveTransactionMetadata(ctx, parameters any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SaveTransactionMetadata", reflect.TypeOf((*LedgerController)(nil).SaveTransactionMetadata), ctx, parameters)
+}
diff --git a/internal/api/common/mocks_system_controller_test.go b/internal/api/common/mocks_system_controller_test.go
new file mode 100644
index 000000000..d98364fa1
--- /dev/null
+++ b/internal/api/common/mocks_system_controller_test.go
@@ -0,0 +1,126 @@
+// Code generated by MockGen. DO NOT EDIT.
+//
+// Generated by this command:
+//
+// mockgen -write_source_comment=false -write_package_comment=false -source ../../controller/system/controller.go -destination mocks_system_controller_test.go -package common --mock_names Controller=SystemController . Controller
+package common
+
+import (
+ context "context"
+ reflect "reflect"
+
+ bunpaginate "github.com/formancehq/go-libs/bun/bunpaginate"
+ ledger "github.com/formancehq/ledger/internal"
+ ledger0 "github.com/formancehq/ledger/internal/controller/ledger"
+ gomock "go.uber.org/mock/gomock"
+)
+
+// SystemController is a mock of Controller interface.
+type SystemController struct {
+ ctrl *gomock.Controller
+ recorder *SystemControllerMockRecorder
+}
+
+// SystemControllerMockRecorder is the mock recorder for SystemController.
+type SystemControllerMockRecorder struct {
+ mock *SystemController
+}
+
+// NewSystemController creates a new mock instance.
+func NewSystemController(ctrl *gomock.Controller) *SystemController {
+ mock := &SystemController{ctrl: ctrl}
+ mock.recorder = &SystemControllerMockRecorder{mock}
+ return mock
+}
+
+// EXPECT returns an object that allows the caller to indicate expected use.
+func (m *SystemController) EXPECT() *SystemControllerMockRecorder {
+ return m.recorder
+}
+
+// CreateLedger mocks base method.
+func (m *SystemController) CreateLedger(ctx context.Context, name string, configuration ledger.Configuration) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "CreateLedger", ctx, name, configuration)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// CreateLedger indicates an expected call of CreateLedger.
+func (mr *SystemControllerMockRecorder) CreateLedger(ctx, name, configuration any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateLedger", reflect.TypeOf((*SystemController)(nil).CreateLedger), ctx, name, configuration)
+}
+
+// DeleteLedgerMetadata mocks base method.
+func (m *SystemController) DeleteLedgerMetadata(ctx context.Context, param, key string) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "DeleteLedgerMetadata", ctx, param, key)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// DeleteLedgerMetadata indicates an expected call of DeleteLedgerMetadata.
+func (mr *SystemControllerMockRecorder) DeleteLedgerMetadata(ctx, param, key any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteLedgerMetadata", reflect.TypeOf((*SystemController)(nil).DeleteLedgerMetadata), ctx, param, key)
+}
+
+// GetLedger mocks base method.
+func (m *SystemController) GetLedger(ctx context.Context, name string) (*ledger.Ledger, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetLedger", ctx, name)
+ ret0, _ := ret[0].(*ledger.Ledger)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetLedger indicates an expected call of GetLedger.
+func (mr *SystemControllerMockRecorder) GetLedger(ctx, name any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLedger", reflect.TypeOf((*SystemController)(nil).GetLedger), ctx, name)
+}
+
+// GetLedgerController mocks base method.
+func (m *SystemController) GetLedgerController(ctx context.Context, name string) (ledger0.Controller, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetLedgerController", ctx, name)
+ ret0, _ := ret[0].(ledger0.Controller)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetLedgerController indicates an expected call of GetLedgerController.
+func (mr *SystemControllerMockRecorder) GetLedgerController(ctx, name any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLedgerController", reflect.TypeOf((*SystemController)(nil).GetLedgerController), ctx, name)
+}
+
+// ListLedgers mocks base method.
+func (m *SystemController) ListLedgers(ctx context.Context, query ledger0.ListLedgersQuery) (*bunpaginate.Cursor[ledger.Ledger], error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "ListLedgers", ctx, query)
+ ret0, _ := ret[0].(*bunpaginate.Cursor[ledger.Ledger])
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// ListLedgers indicates an expected call of ListLedgers.
+func (mr *SystemControllerMockRecorder) ListLedgers(ctx, query any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListLedgers", reflect.TypeOf((*SystemController)(nil).ListLedgers), ctx, query)
+}
+
+// UpdateLedgerMetadata mocks base method.
+func (m_2 *SystemController) UpdateLedgerMetadata(ctx context.Context, name string, m map[string]string) error {
+ m_2.ctrl.T.Helper()
+ ret := m_2.ctrl.Call(m_2, "UpdateLedgerMetadata", ctx, name, m)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// UpdateLedgerMetadata indicates an expected call of UpdateLedgerMetadata.
+func (mr *SystemControllerMockRecorder) UpdateLedgerMetadata(ctx, name, m any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateLedgerMetadata", reflect.TypeOf((*SystemController)(nil).UpdateLedgerMetadata), ctx, name, m)
+}
diff --git a/internal/api/v1/api_utils_test.go b/internal/api/v1/api_utils_test.go
index 0f6799ec6..2eb3f859a 100644
--- a/internal/api/v1/api_utils_test.go
+++ b/internal/api/v1/api_utils_test.go
@@ -3,18 +3,15 @@ package v1
import (
"testing"
- ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger"
- systemcontroller "github.com/formancehq/ledger/internal/controller/system"
-
ledger "github.com/formancehq/ledger/internal"
"go.uber.org/mock/gomock"
)
-func newTestingSystemController(t *testing.T, expectedSchemaCheck bool) (*systemcontroller.MockController, *ledgercontroller.MockController) {
+func newTestingSystemController(t *testing.T, expectedSchemaCheck bool) (*SystemController, *LedgerController) {
ctrl := gomock.NewController(t)
- mockLedger := ledgercontroller.NewMockController(ctrl)
- backend := systemcontroller.NewMockController(ctrl)
+ mockLedger := NewLedgerController(ctrl)
+ backend := NewSystemController(ctrl)
backend.
EXPECT().
GetLedger(gomock.Any(), gomock.Any()).
diff --git a/internal/api/v1/mocks.go b/internal/api/v1/mocks.go
new file mode 100644
index 000000000..f10db2ce4
--- /dev/null
+++ b/internal/api/v1/mocks.go
@@ -0,0 +1,3 @@
+//go:generate mockgen -write_source_comment=false -write_package_comment=false -source ../../controller/system/controller.go -destination mocks_system_controller_test.go -package v1 --mock_names Controller=SystemController . Controller
+//go:generate mockgen -write_source_comment=false -write_package_comment=false -source ../../controller/ledger/controller.go -destination mocks_ledger_controller_test.go -package v1 --mock_names Controller=LedgerController . Controller
+package v1
\ No newline at end of file
diff --git a/internal/api/v1/mocks_ledger_controller_test.go b/internal/api/v1/mocks_ledger_controller_test.go
new file mode 100644
index 000000000..1502bb4ed
--- /dev/null
+++ b/internal/api/v1/mocks_ledger_controller_test.go
@@ -0,0 +1,334 @@
+// Code generated by MockGen. DO NOT EDIT.
+//
+// Generated by this command:
+//
+// mockgen -write_source_comment=false -write_package_comment=false -source ../../controller/ledger/controller.go -destination mocks_ledger_controller_test.go -package v1 --mock_names Controller=LedgerController . Controller
+package v1
+
+import (
+ context "context"
+ reflect "reflect"
+
+ bunpaginate "github.com/formancehq/go-libs/bun/bunpaginate"
+ migrations "github.com/formancehq/go-libs/migrations"
+ ledger "github.com/formancehq/ledger/internal"
+ ledger0 "github.com/formancehq/ledger/internal/controller/ledger"
+ gomock "go.uber.org/mock/gomock"
+)
+
+// LedgerController is a mock of Controller interface.
+type LedgerController struct {
+ ctrl *gomock.Controller
+ recorder *LedgerControllerMockRecorder
+}
+
+// LedgerControllerMockRecorder is the mock recorder for LedgerController.
+type LedgerControllerMockRecorder struct {
+ mock *LedgerController
+}
+
+// NewLedgerController creates a new mock instance.
+func NewLedgerController(ctrl *gomock.Controller) *LedgerController {
+ mock := &LedgerController{ctrl: ctrl}
+ mock.recorder = &LedgerControllerMockRecorder{mock}
+ return mock
+}
+
+// EXPECT returns an object that allows the caller to indicate expected use.
+func (m *LedgerController) EXPECT() *LedgerControllerMockRecorder {
+ return m.recorder
+}
+
+// CountAccounts mocks base method.
+func (m *LedgerController) CountAccounts(ctx context.Context, query ledger0.ListAccountsQuery) (int, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "CountAccounts", ctx, query)
+ ret0, _ := ret[0].(int)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// CountAccounts indicates an expected call of CountAccounts.
+func (mr *LedgerControllerMockRecorder) CountAccounts(ctx, query any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CountAccounts", reflect.TypeOf((*LedgerController)(nil).CountAccounts), ctx, query)
+}
+
+// CountTransactions mocks base method.
+func (m *LedgerController) CountTransactions(ctx context.Context, query ledger0.ListTransactionsQuery) (int, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "CountTransactions", ctx, query)
+ ret0, _ := ret[0].(int)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// CountTransactions indicates an expected call of CountTransactions.
+func (mr *LedgerControllerMockRecorder) CountTransactions(ctx, query any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CountTransactions", reflect.TypeOf((*LedgerController)(nil).CountTransactions), ctx, query)
+}
+
+// CreateTransaction mocks base method.
+func (m *LedgerController) CreateTransaction(ctx context.Context, parameters ledger0.Parameters[ledger0.RunScript]) (*ledger.CreatedTransaction, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "CreateTransaction", ctx, parameters)
+ ret0, _ := ret[0].(*ledger.CreatedTransaction)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// CreateTransaction indicates an expected call of CreateTransaction.
+func (mr *LedgerControllerMockRecorder) CreateTransaction(ctx, parameters any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateTransaction", reflect.TypeOf((*LedgerController)(nil).CreateTransaction), ctx, parameters)
+}
+
+// DeleteAccountMetadata mocks base method.
+func (m *LedgerController) DeleteAccountMetadata(ctx context.Context, parameters ledger0.Parameters[ledger0.DeleteAccountMetadata]) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "DeleteAccountMetadata", ctx, parameters)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// DeleteAccountMetadata indicates an expected call of DeleteAccountMetadata.
+func (mr *LedgerControllerMockRecorder) DeleteAccountMetadata(ctx, parameters any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteAccountMetadata", reflect.TypeOf((*LedgerController)(nil).DeleteAccountMetadata), ctx, parameters)
+}
+
+// DeleteTransactionMetadata mocks base method.
+func (m *LedgerController) DeleteTransactionMetadata(ctx context.Context, parameters ledger0.Parameters[ledger0.DeleteTransactionMetadata]) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "DeleteTransactionMetadata", ctx, parameters)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// DeleteTransactionMetadata indicates an expected call of DeleteTransactionMetadata.
+func (mr *LedgerControllerMockRecorder) DeleteTransactionMetadata(ctx, parameters any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteTransactionMetadata", reflect.TypeOf((*LedgerController)(nil).DeleteTransactionMetadata), ctx, parameters)
+}
+
+// Export mocks base method.
+func (m *LedgerController) Export(ctx context.Context, w ledger0.ExportWriter) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "Export", ctx, w)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// Export indicates an expected call of Export.
+func (mr *LedgerControllerMockRecorder) Export(ctx, w any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Export", reflect.TypeOf((*LedgerController)(nil).Export), ctx, w)
+}
+
+// GetAccount mocks base method.
+func (m *LedgerController) GetAccount(ctx context.Context, query ledger0.GetAccountQuery) (*ledger.Account, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetAccount", ctx, query)
+ ret0, _ := ret[0].(*ledger.Account)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetAccount indicates an expected call of GetAccount.
+func (mr *LedgerControllerMockRecorder) GetAccount(ctx, query any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccount", reflect.TypeOf((*LedgerController)(nil).GetAccount), ctx, query)
+}
+
+// GetAggregatedBalances mocks base method.
+func (m *LedgerController) GetAggregatedBalances(ctx context.Context, q ledger0.GetAggregatedBalanceQuery) (ledger.BalancesByAssets, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetAggregatedBalances", ctx, q)
+ ret0, _ := ret[0].(ledger.BalancesByAssets)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetAggregatedBalances indicates an expected call of GetAggregatedBalances.
+func (mr *LedgerControllerMockRecorder) GetAggregatedBalances(ctx, q any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAggregatedBalances", reflect.TypeOf((*LedgerController)(nil).GetAggregatedBalances), ctx, q)
+}
+
+// GetMigrationsInfo mocks base method.
+func (m *LedgerController) GetMigrationsInfo(ctx context.Context) ([]migrations.Info, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetMigrationsInfo", ctx)
+ ret0, _ := ret[0].([]migrations.Info)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetMigrationsInfo indicates an expected call of GetMigrationsInfo.
+func (mr *LedgerControllerMockRecorder) GetMigrationsInfo(ctx any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetMigrationsInfo", reflect.TypeOf((*LedgerController)(nil).GetMigrationsInfo), ctx)
+}
+
+// GetStats mocks base method.
+func (m *LedgerController) GetStats(ctx context.Context) (ledger0.Stats, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetStats", ctx)
+ ret0, _ := ret[0].(ledger0.Stats)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetStats indicates an expected call of GetStats.
+func (mr *LedgerControllerMockRecorder) GetStats(ctx any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetStats", reflect.TypeOf((*LedgerController)(nil).GetStats), ctx)
+}
+
+// GetTransaction mocks base method.
+func (m *LedgerController) GetTransaction(ctx context.Context, query ledger0.GetTransactionQuery) (*ledger.Transaction, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetTransaction", ctx, query)
+ ret0, _ := ret[0].(*ledger.Transaction)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetTransaction indicates an expected call of GetTransaction.
+func (mr *LedgerControllerMockRecorder) GetTransaction(ctx, query any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTransaction", reflect.TypeOf((*LedgerController)(nil).GetTransaction), ctx, query)
+}
+
+// GetVolumesWithBalances mocks base method.
+func (m *LedgerController) GetVolumesWithBalances(ctx context.Context, q ledger0.GetVolumesWithBalancesQuery) (*bunpaginate.Cursor[ledger.VolumesWithBalanceByAssetByAccount], error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetVolumesWithBalances", ctx, q)
+ ret0, _ := ret[0].(*bunpaginate.Cursor[ledger.VolumesWithBalanceByAssetByAccount])
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetVolumesWithBalances indicates an expected call of GetVolumesWithBalances.
+func (mr *LedgerControllerMockRecorder) GetVolumesWithBalances(ctx, q any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetVolumesWithBalances", reflect.TypeOf((*LedgerController)(nil).GetVolumesWithBalances), ctx, q)
+}
+
+// Import mocks base method.
+func (m *LedgerController) Import(ctx context.Context, stream chan ledger.Log) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "Import", ctx, stream)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// Import indicates an expected call of Import.
+func (mr *LedgerControllerMockRecorder) Import(ctx, stream any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Import", reflect.TypeOf((*LedgerController)(nil).Import), ctx, stream)
+}
+
+// IsDatabaseUpToDate mocks base method.
+func (m *LedgerController) IsDatabaseUpToDate(ctx context.Context) (bool, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "IsDatabaseUpToDate", ctx)
+ ret0, _ := ret[0].(bool)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// IsDatabaseUpToDate indicates an expected call of IsDatabaseUpToDate.
+func (mr *LedgerControllerMockRecorder) IsDatabaseUpToDate(ctx any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsDatabaseUpToDate", reflect.TypeOf((*LedgerController)(nil).IsDatabaseUpToDate), ctx)
+}
+
+// ListAccounts mocks base method.
+func (m *LedgerController) ListAccounts(ctx context.Context, query ledger0.ListAccountsQuery) (*bunpaginate.Cursor[ledger.Account], error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "ListAccounts", ctx, query)
+ ret0, _ := ret[0].(*bunpaginate.Cursor[ledger.Account])
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// ListAccounts indicates an expected call of ListAccounts.
+func (mr *LedgerControllerMockRecorder) ListAccounts(ctx, query any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListAccounts", reflect.TypeOf((*LedgerController)(nil).ListAccounts), ctx, query)
+}
+
+// ListLogs mocks base method.
+func (m *LedgerController) ListLogs(ctx context.Context, query ledger0.GetLogsQuery) (*bunpaginate.Cursor[ledger.Log], error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "ListLogs", ctx, query)
+ ret0, _ := ret[0].(*bunpaginate.Cursor[ledger.Log])
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// ListLogs indicates an expected call of ListLogs.
+func (mr *LedgerControllerMockRecorder) ListLogs(ctx, query any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListLogs", reflect.TypeOf((*LedgerController)(nil).ListLogs), ctx, query)
+}
+
+// ListTransactions mocks base method.
+func (m *LedgerController) ListTransactions(ctx context.Context, query ledger0.ListTransactionsQuery) (*bunpaginate.Cursor[ledger.Transaction], error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "ListTransactions", ctx, query)
+ ret0, _ := ret[0].(*bunpaginate.Cursor[ledger.Transaction])
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// ListTransactions indicates an expected call of ListTransactions.
+func (mr *LedgerControllerMockRecorder) ListTransactions(ctx, query any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListTransactions", reflect.TypeOf((*LedgerController)(nil).ListTransactions), ctx, query)
+}
+
+// RevertTransaction mocks base method.
+func (m *LedgerController) RevertTransaction(ctx context.Context, parameters ledger0.Parameters[ledger0.RevertTransaction]) (*ledger.RevertedTransaction, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "RevertTransaction", ctx, parameters)
+ ret0, _ := ret[0].(*ledger.RevertedTransaction)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// RevertTransaction indicates an expected call of RevertTransaction.
+func (mr *LedgerControllerMockRecorder) RevertTransaction(ctx, parameters any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RevertTransaction", reflect.TypeOf((*LedgerController)(nil).RevertTransaction), ctx, parameters)
+}
+
+// SaveAccountMetadata mocks base method.
+func (m *LedgerController) SaveAccountMetadata(ctx context.Context, parameters ledger0.Parameters[ledger0.SaveAccountMetadata]) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "SaveAccountMetadata", ctx, parameters)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// SaveAccountMetadata indicates an expected call of SaveAccountMetadata.
+func (mr *LedgerControllerMockRecorder) SaveAccountMetadata(ctx, parameters any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SaveAccountMetadata", reflect.TypeOf((*LedgerController)(nil).SaveAccountMetadata), ctx, parameters)
+}
+
+// SaveTransactionMetadata mocks base method.
+func (m *LedgerController) SaveTransactionMetadata(ctx context.Context, parameters ledger0.Parameters[ledger0.SaveTransactionMetadata]) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "SaveTransactionMetadata", ctx, parameters)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// SaveTransactionMetadata indicates an expected call of SaveTransactionMetadata.
+func (mr *LedgerControllerMockRecorder) SaveTransactionMetadata(ctx, parameters any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SaveTransactionMetadata", reflect.TypeOf((*LedgerController)(nil).SaveTransactionMetadata), ctx, parameters)
+}
diff --git a/internal/controller/system/controller_generated.go b/internal/api/v1/mocks_system_controller_test.go
similarity index 50%
rename from internal/controller/system/controller_generated.go
rename to internal/api/v1/mocks_system_controller_test.go
index c2dd825e9..3a383b08b 100644
--- a/internal/controller/system/controller_generated.go
+++ b/internal/api/v1/mocks_system_controller_test.go
@@ -1,13 +1,9 @@
// Code generated by MockGen. DO NOT EDIT.
-// Source: controller.go
//
// Generated by this command:
//
-// mockgen -source controller.go -destination controller_generated.go -package system . Controller
-//
-
-// Package system is a generated GoMock package.
-package system
+// mockgen -write_source_comment=false -write_package_comment=false -source ../../controller/system/controller.go -destination mocks_system_controller_test.go -package v1 --mock_names Controller=SystemController . Controller
+package v1
import (
context "context"
@@ -19,31 +15,31 @@ import (
gomock "go.uber.org/mock/gomock"
)
-// MockController is a mock of Controller interface.
-type MockController struct {
+// SystemController is a mock of Controller interface.
+type SystemController struct {
ctrl *gomock.Controller
- recorder *MockControllerMockRecorder
+ recorder *SystemControllerMockRecorder
}
-// MockControllerMockRecorder is the mock recorder for MockController.
-type MockControllerMockRecorder struct {
- mock *MockController
+// SystemControllerMockRecorder is the mock recorder for SystemController.
+type SystemControllerMockRecorder struct {
+ mock *SystemController
}
-// NewMockController creates a new mock instance.
-func NewMockController(ctrl *gomock.Controller) *MockController {
- mock := &MockController{ctrl: ctrl}
- mock.recorder = &MockControllerMockRecorder{mock}
+// NewSystemController creates a new mock instance.
+func NewSystemController(ctrl *gomock.Controller) *SystemController {
+ mock := &SystemController{ctrl: ctrl}
+ mock.recorder = &SystemControllerMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
-func (m *MockController) EXPECT() *MockControllerMockRecorder {
+func (m *SystemController) EXPECT() *SystemControllerMockRecorder {
return m.recorder
}
// CreateLedger mocks base method.
-func (m *MockController) CreateLedger(ctx context.Context, name string, configuration ledger.Configuration) error {
+func (m *SystemController) CreateLedger(ctx context.Context, name string, configuration ledger.Configuration) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "CreateLedger", ctx, name, configuration)
ret0, _ := ret[0].(error)
@@ -51,13 +47,13 @@ func (m *MockController) CreateLedger(ctx context.Context, name string, configur
}
// CreateLedger indicates an expected call of CreateLedger.
-func (mr *MockControllerMockRecorder) CreateLedger(ctx, name, configuration any) *gomock.Call {
+func (mr *SystemControllerMockRecorder) CreateLedger(ctx, name, configuration any) *gomock.Call {
mr.mock.ctrl.T.Helper()
- return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateLedger", reflect.TypeOf((*MockController)(nil).CreateLedger), ctx, name, configuration)
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateLedger", reflect.TypeOf((*SystemController)(nil).CreateLedger), ctx, name, configuration)
}
// DeleteLedgerMetadata mocks base method.
-func (m *MockController) DeleteLedgerMetadata(ctx context.Context, param, key string) error {
+func (m *SystemController) DeleteLedgerMetadata(ctx context.Context, param, key string) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "DeleteLedgerMetadata", ctx, param, key)
ret0, _ := ret[0].(error)
@@ -65,13 +61,13 @@ func (m *MockController) DeleteLedgerMetadata(ctx context.Context, param, key st
}
// DeleteLedgerMetadata indicates an expected call of DeleteLedgerMetadata.
-func (mr *MockControllerMockRecorder) DeleteLedgerMetadata(ctx, param, key any) *gomock.Call {
+func (mr *SystemControllerMockRecorder) DeleteLedgerMetadata(ctx, param, key any) *gomock.Call {
mr.mock.ctrl.T.Helper()
- return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteLedgerMetadata", reflect.TypeOf((*MockController)(nil).DeleteLedgerMetadata), ctx, param, key)
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteLedgerMetadata", reflect.TypeOf((*SystemController)(nil).DeleteLedgerMetadata), ctx, param, key)
}
// GetLedger mocks base method.
-func (m *MockController) GetLedger(ctx context.Context, name string) (*ledger.Ledger, error) {
+func (m *SystemController) GetLedger(ctx context.Context, name string) (*ledger.Ledger, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetLedger", ctx, name)
ret0, _ := ret[0].(*ledger.Ledger)
@@ -80,13 +76,13 @@ func (m *MockController) GetLedger(ctx context.Context, name string) (*ledger.Le
}
// GetLedger indicates an expected call of GetLedger.
-func (mr *MockControllerMockRecorder) GetLedger(ctx, name any) *gomock.Call {
+func (mr *SystemControllerMockRecorder) GetLedger(ctx, name any) *gomock.Call {
mr.mock.ctrl.T.Helper()
- return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLedger", reflect.TypeOf((*MockController)(nil).GetLedger), ctx, name)
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLedger", reflect.TypeOf((*SystemController)(nil).GetLedger), ctx, name)
}
// GetLedgerController mocks base method.
-func (m *MockController) GetLedgerController(ctx context.Context, name string) (ledger0.Controller, error) {
+func (m *SystemController) GetLedgerController(ctx context.Context, name string) (ledger0.Controller, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetLedgerController", ctx, name)
ret0, _ := ret[0].(ledger0.Controller)
@@ -95,13 +91,13 @@ func (m *MockController) GetLedgerController(ctx context.Context, name string) (
}
// GetLedgerController indicates an expected call of GetLedgerController.
-func (mr *MockControllerMockRecorder) GetLedgerController(ctx, name any) *gomock.Call {
+func (mr *SystemControllerMockRecorder) GetLedgerController(ctx, name any) *gomock.Call {
mr.mock.ctrl.T.Helper()
- return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLedgerController", reflect.TypeOf((*MockController)(nil).GetLedgerController), ctx, name)
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLedgerController", reflect.TypeOf((*SystemController)(nil).GetLedgerController), ctx, name)
}
// ListLedgers mocks base method.
-func (m *MockController) ListLedgers(ctx context.Context, query ledger0.ListLedgersQuery) (*bunpaginate.Cursor[ledger.Ledger], error) {
+func (m *SystemController) ListLedgers(ctx context.Context, query ledger0.ListLedgersQuery) (*bunpaginate.Cursor[ledger.Ledger], error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ListLedgers", ctx, query)
ret0, _ := ret[0].(*bunpaginate.Cursor[ledger.Ledger])
@@ -110,13 +106,13 @@ func (m *MockController) ListLedgers(ctx context.Context, query ledger0.ListLedg
}
// ListLedgers indicates an expected call of ListLedgers.
-func (mr *MockControllerMockRecorder) ListLedgers(ctx, query any) *gomock.Call {
+func (mr *SystemControllerMockRecorder) ListLedgers(ctx, query any) *gomock.Call {
mr.mock.ctrl.T.Helper()
- return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListLedgers", reflect.TypeOf((*MockController)(nil).ListLedgers), ctx, query)
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListLedgers", reflect.TypeOf((*SystemController)(nil).ListLedgers), ctx, query)
}
// UpdateLedgerMetadata mocks base method.
-func (m_2 *MockController) UpdateLedgerMetadata(ctx context.Context, name string, m map[string]string) error {
+func (m_2 *SystemController) UpdateLedgerMetadata(ctx context.Context, name string, m map[string]string) error {
m_2.ctrl.T.Helper()
ret := m_2.ctrl.Call(m_2, "UpdateLedgerMetadata", ctx, name, m)
ret0, _ := ret[0].(error)
@@ -124,7 +120,7 @@ func (m_2 *MockController) UpdateLedgerMetadata(ctx context.Context, name string
}
// UpdateLedgerMetadata indicates an expected call of UpdateLedgerMetadata.
-func (mr *MockControllerMockRecorder) UpdateLedgerMetadata(ctx, name, m any) *gomock.Call {
+func (mr *SystemControllerMockRecorder) UpdateLedgerMetadata(ctx, name, m any) *gomock.Call {
mr.mock.ctrl.T.Helper()
- return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateLedgerMetadata", reflect.TypeOf((*MockController)(nil).UpdateLedgerMetadata), ctx, name, m)
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateLedgerMetadata", reflect.TypeOf((*SystemController)(nil).UpdateLedgerMetadata), ctx, name, m)
}
diff --git a/internal/api/v2/api_utils_test.go b/internal/api/v2/api_utils_test.go
index bd94bec3c..a73a084bb 100644
--- a/internal/api/v2/api_utils_test.go
+++ b/internal/api/v2/api_utils_test.go
@@ -3,16 +3,13 @@ package v2
import (
"testing"
- ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger"
- systemcontroller "github.com/formancehq/ledger/internal/controller/system"
-
"go.uber.org/mock/gomock"
)
-func newTestingSystemController(t *testing.T, expectedSchemaCheck bool) (*systemcontroller.MockController, *ledgercontroller.MockController) {
+func newTestingSystemController(t *testing.T, expectedSchemaCheck bool) (*SystemController, *LedgerController) {
ctrl := gomock.NewController(t)
- mockLedger := ledgercontroller.NewMockController(ctrl)
- backend := systemcontroller.NewMockController(ctrl)
+ mockLedger := NewLedgerController(ctrl)
+ backend := NewSystemController(ctrl)
backend.
EXPECT().
GetLedgerController(gomock.Any(), gomock.Any()).
diff --git a/internal/api/v2/controllers_bulk_test.go b/internal/api/v2/controllers_bulk_test.go
index 4229f9e77..3d1f469ab 100644
--- a/internal/api/v2/controllers_bulk_test.go
+++ b/internal/api/v2/controllers_bulk_test.go
@@ -33,7 +33,7 @@ func TestBulk(t *testing.T) {
name string
queryParams url.Values
body string
- expectations func(mockLedger *ledgercontroller.MockController)
+ expectations func(mockLedger *LedgerController)
expectError bool
expectResults []Result
}
@@ -53,7 +53,7 @@ func TestBulk(t *testing.T) {
"timestamp": "%s"
}
}]`, now.Format(time.RFC3339Nano)),
- expectations: func(mockLedger *ledgercontroller.MockController) {
+ expectations: func(mockLedger *LedgerController) {
postings := []ledger.Posting{{
Source: "world",
Destination: "bank",
@@ -107,7 +107,7 @@ func TestBulk(t *testing.T) {
}
}
}]`,
- expectations: func(mockLedger *ledgercontroller.MockController) {
+ expectations: func(mockLedger *LedgerController) {
mockLedger.EXPECT().
SaveTransactionMetadata(gomock.Any(), ledgercontroller.Parameters[ledgercontroller.SaveTransactionMetadata]{
Input: ledgercontroller.SaveTransactionMetadata{
@@ -135,7 +135,7 @@ func TestBulk(t *testing.T) {
}
}
}]`,
- expectations: func(mockLedger *ledgercontroller.MockController) {
+ expectations: func(mockLedger *LedgerController) {
mockLedger.EXPECT().
SaveAccountMetadata(gomock.Any(), ledgercontroller.Parameters[ledgercontroller.SaveAccountMetadata]{
Input: ledgercontroller.SaveAccountMetadata{
@@ -159,7 +159,7 @@ func TestBulk(t *testing.T) {
"id": 1
}
}]`,
- expectations: func(mockLedger *ledgercontroller.MockController) {
+ expectations: func(mockLedger *LedgerController) {
mockLedger.EXPECT().
RevertTransaction(gomock.Any(), ledgercontroller.Parameters[ledgercontroller.RevertTransaction]{
Input: ledgercontroller.RevertTransaction{
@@ -189,7 +189,7 @@ func TestBulk(t *testing.T) {
"key": "foo"
}
}]`,
- expectations: func(mockLedger *ledgercontroller.MockController) {
+ expectations: func(mockLedger *LedgerController) {
mockLedger.EXPECT().
DeleteTransactionMetadata(gomock.Any(), ledgercontroller.Parameters[ledgercontroller.DeleteTransactionMetadata]{
Input: ledgercontroller.DeleteTransactionMetadata{
@@ -237,7 +237,7 @@ func TestBulk(t *testing.T) {
}
}
]`,
- expectations: func(mockLedger *ledgercontroller.MockController) {
+ expectations: func(mockLedger *LedgerController) {
mockLedger.EXPECT().
SaveAccountMetadata(gomock.Any(), ledgercontroller.Parameters[ledgercontroller.SaveAccountMetadata]{
Input: ledgercontroller.SaveAccountMetadata{
@@ -305,7 +305,7 @@ func TestBulk(t *testing.T) {
queryParams: map[string][]string{
"continueOnFailure": {"true"},
},
- expectations: func(mockLedger *ledgercontroller.MockController) {
+ expectations: func(mockLedger *LedgerController) {
mockLedger.EXPECT().
SaveAccountMetadata(gomock.Any(), ledgercontroller.Parameters[ledgercontroller.SaveAccountMetadata]{
Input: ledgercontroller.SaveAccountMetadata{
diff --git a/internal/api/v2/mocks.go b/internal/api/v2/mocks.go
new file mode 100644
index 000000000..c082bd6a6
--- /dev/null
+++ b/internal/api/v2/mocks.go
@@ -0,0 +1,3 @@
+//go:generate mockgen -write_source_comment=false -write_package_comment=false -source ../../controller/system/controller.go -destination mocks_system_controller_test.go -package v2 --mock_names Controller=SystemController . Controller
+//go:generate mockgen -write_source_comment=false -write_package_comment=false -source ../../controller/ledger/controller.go -destination mocks_ledger_controller_test.go -package v2 --mock_names Controller=LedgerController . Controller
+package v2
\ No newline at end of file
diff --git a/internal/api/v2/mocks_ledger_controller_test.go b/internal/api/v2/mocks_ledger_controller_test.go
new file mode 100644
index 000000000..b0311e6a1
--- /dev/null
+++ b/internal/api/v2/mocks_ledger_controller_test.go
@@ -0,0 +1,334 @@
+// Code generated by MockGen. DO NOT EDIT.
+//
+// Generated by this command:
+//
+// mockgen -write_source_comment=false -write_package_comment=false -source ../../controller/ledger/controller.go -destination mocks_ledger_controller_test.go -package v2 --mock_names Controller=LedgerController . Controller
+package v2
+
+import (
+ context "context"
+ reflect "reflect"
+
+ bunpaginate "github.com/formancehq/go-libs/bun/bunpaginate"
+ migrations "github.com/formancehq/go-libs/migrations"
+ ledger "github.com/formancehq/ledger/internal"
+ ledger0 "github.com/formancehq/ledger/internal/controller/ledger"
+ gomock "go.uber.org/mock/gomock"
+)
+
+// LedgerController is a mock of Controller interface.
+type LedgerController struct {
+ ctrl *gomock.Controller
+ recorder *LedgerControllerMockRecorder
+}
+
+// LedgerControllerMockRecorder is the mock recorder for LedgerController.
+type LedgerControllerMockRecorder struct {
+ mock *LedgerController
+}
+
+// NewLedgerController creates a new mock instance.
+func NewLedgerController(ctrl *gomock.Controller) *LedgerController {
+ mock := &LedgerController{ctrl: ctrl}
+ mock.recorder = &LedgerControllerMockRecorder{mock}
+ return mock
+}
+
+// EXPECT returns an object that allows the caller to indicate expected use.
+func (m *LedgerController) EXPECT() *LedgerControllerMockRecorder {
+ return m.recorder
+}
+
+// CountAccounts mocks base method.
+func (m *LedgerController) CountAccounts(ctx context.Context, query ledger0.ListAccountsQuery) (int, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "CountAccounts", ctx, query)
+ ret0, _ := ret[0].(int)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// CountAccounts indicates an expected call of CountAccounts.
+func (mr *LedgerControllerMockRecorder) CountAccounts(ctx, query any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CountAccounts", reflect.TypeOf((*LedgerController)(nil).CountAccounts), ctx, query)
+}
+
+// CountTransactions mocks base method.
+func (m *LedgerController) CountTransactions(ctx context.Context, query ledger0.ListTransactionsQuery) (int, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "CountTransactions", ctx, query)
+ ret0, _ := ret[0].(int)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// CountTransactions indicates an expected call of CountTransactions.
+func (mr *LedgerControllerMockRecorder) CountTransactions(ctx, query any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CountTransactions", reflect.TypeOf((*LedgerController)(nil).CountTransactions), ctx, query)
+}
+
+// CreateTransaction mocks base method.
+func (m *LedgerController) CreateTransaction(ctx context.Context, parameters ledger0.Parameters[ledger0.RunScript]) (*ledger.CreatedTransaction, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "CreateTransaction", ctx, parameters)
+ ret0, _ := ret[0].(*ledger.CreatedTransaction)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// CreateTransaction indicates an expected call of CreateTransaction.
+func (mr *LedgerControllerMockRecorder) CreateTransaction(ctx, parameters any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateTransaction", reflect.TypeOf((*LedgerController)(nil).CreateTransaction), ctx, parameters)
+}
+
+// DeleteAccountMetadata mocks base method.
+func (m *LedgerController) DeleteAccountMetadata(ctx context.Context, parameters ledger0.Parameters[ledger0.DeleteAccountMetadata]) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "DeleteAccountMetadata", ctx, parameters)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// DeleteAccountMetadata indicates an expected call of DeleteAccountMetadata.
+func (mr *LedgerControllerMockRecorder) DeleteAccountMetadata(ctx, parameters any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteAccountMetadata", reflect.TypeOf((*LedgerController)(nil).DeleteAccountMetadata), ctx, parameters)
+}
+
+// DeleteTransactionMetadata mocks base method.
+func (m *LedgerController) DeleteTransactionMetadata(ctx context.Context, parameters ledger0.Parameters[ledger0.DeleteTransactionMetadata]) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "DeleteTransactionMetadata", ctx, parameters)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// DeleteTransactionMetadata indicates an expected call of DeleteTransactionMetadata.
+func (mr *LedgerControllerMockRecorder) DeleteTransactionMetadata(ctx, parameters any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteTransactionMetadata", reflect.TypeOf((*LedgerController)(nil).DeleteTransactionMetadata), ctx, parameters)
+}
+
+// Export mocks base method.
+func (m *LedgerController) Export(ctx context.Context, w ledger0.ExportWriter) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "Export", ctx, w)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// Export indicates an expected call of Export.
+func (mr *LedgerControllerMockRecorder) Export(ctx, w any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Export", reflect.TypeOf((*LedgerController)(nil).Export), ctx, w)
+}
+
+// GetAccount mocks base method.
+func (m *LedgerController) GetAccount(ctx context.Context, query ledger0.GetAccountQuery) (*ledger.Account, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetAccount", ctx, query)
+ ret0, _ := ret[0].(*ledger.Account)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetAccount indicates an expected call of GetAccount.
+func (mr *LedgerControllerMockRecorder) GetAccount(ctx, query any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccount", reflect.TypeOf((*LedgerController)(nil).GetAccount), ctx, query)
+}
+
+// GetAggregatedBalances mocks base method.
+func (m *LedgerController) GetAggregatedBalances(ctx context.Context, q ledger0.GetAggregatedBalanceQuery) (ledger.BalancesByAssets, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetAggregatedBalances", ctx, q)
+ ret0, _ := ret[0].(ledger.BalancesByAssets)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetAggregatedBalances indicates an expected call of GetAggregatedBalances.
+func (mr *LedgerControllerMockRecorder) GetAggregatedBalances(ctx, q any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAggregatedBalances", reflect.TypeOf((*LedgerController)(nil).GetAggregatedBalances), ctx, q)
+}
+
+// GetMigrationsInfo mocks base method.
+func (m *LedgerController) GetMigrationsInfo(ctx context.Context) ([]migrations.Info, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetMigrationsInfo", ctx)
+ ret0, _ := ret[0].([]migrations.Info)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetMigrationsInfo indicates an expected call of GetMigrationsInfo.
+func (mr *LedgerControllerMockRecorder) GetMigrationsInfo(ctx any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetMigrationsInfo", reflect.TypeOf((*LedgerController)(nil).GetMigrationsInfo), ctx)
+}
+
+// GetStats mocks base method.
+func (m *LedgerController) GetStats(ctx context.Context) (ledger0.Stats, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetStats", ctx)
+ ret0, _ := ret[0].(ledger0.Stats)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetStats indicates an expected call of GetStats.
+func (mr *LedgerControllerMockRecorder) GetStats(ctx any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetStats", reflect.TypeOf((*LedgerController)(nil).GetStats), ctx)
+}
+
+// GetTransaction mocks base method.
+func (m *LedgerController) GetTransaction(ctx context.Context, query ledger0.GetTransactionQuery) (*ledger.Transaction, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetTransaction", ctx, query)
+ ret0, _ := ret[0].(*ledger.Transaction)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetTransaction indicates an expected call of GetTransaction.
+func (mr *LedgerControllerMockRecorder) GetTransaction(ctx, query any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTransaction", reflect.TypeOf((*LedgerController)(nil).GetTransaction), ctx, query)
+}
+
+// GetVolumesWithBalances mocks base method.
+func (m *LedgerController) GetVolumesWithBalances(ctx context.Context, q ledger0.GetVolumesWithBalancesQuery) (*bunpaginate.Cursor[ledger.VolumesWithBalanceByAssetByAccount], error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetVolumesWithBalances", ctx, q)
+ ret0, _ := ret[0].(*bunpaginate.Cursor[ledger.VolumesWithBalanceByAssetByAccount])
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetVolumesWithBalances indicates an expected call of GetVolumesWithBalances.
+func (mr *LedgerControllerMockRecorder) GetVolumesWithBalances(ctx, q any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetVolumesWithBalances", reflect.TypeOf((*LedgerController)(nil).GetVolumesWithBalances), ctx, q)
+}
+
+// Import mocks base method.
+func (m *LedgerController) Import(ctx context.Context, stream chan ledger.Log) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "Import", ctx, stream)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// Import indicates an expected call of Import.
+func (mr *LedgerControllerMockRecorder) Import(ctx, stream any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Import", reflect.TypeOf((*LedgerController)(nil).Import), ctx, stream)
+}
+
+// IsDatabaseUpToDate mocks base method.
+func (m *LedgerController) IsDatabaseUpToDate(ctx context.Context) (bool, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "IsDatabaseUpToDate", ctx)
+ ret0, _ := ret[0].(bool)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// IsDatabaseUpToDate indicates an expected call of IsDatabaseUpToDate.
+func (mr *LedgerControllerMockRecorder) IsDatabaseUpToDate(ctx any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsDatabaseUpToDate", reflect.TypeOf((*LedgerController)(nil).IsDatabaseUpToDate), ctx)
+}
+
+// ListAccounts mocks base method.
+func (m *LedgerController) ListAccounts(ctx context.Context, query ledger0.ListAccountsQuery) (*bunpaginate.Cursor[ledger.Account], error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "ListAccounts", ctx, query)
+ ret0, _ := ret[0].(*bunpaginate.Cursor[ledger.Account])
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// ListAccounts indicates an expected call of ListAccounts.
+func (mr *LedgerControllerMockRecorder) ListAccounts(ctx, query any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListAccounts", reflect.TypeOf((*LedgerController)(nil).ListAccounts), ctx, query)
+}
+
+// ListLogs mocks base method.
+func (m *LedgerController) ListLogs(ctx context.Context, query ledger0.GetLogsQuery) (*bunpaginate.Cursor[ledger.Log], error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "ListLogs", ctx, query)
+ ret0, _ := ret[0].(*bunpaginate.Cursor[ledger.Log])
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// ListLogs indicates an expected call of ListLogs.
+func (mr *LedgerControllerMockRecorder) ListLogs(ctx, query any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListLogs", reflect.TypeOf((*LedgerController)(nil).ListLogs), ctx, query)
+}
+
+// ListTransactions mocks base method.
+func (m *LedgerController) ListTransactions(ctx context.Context, query ledger0.ListTransactionsQuery) (*bunpaginate.Cursor[ledger.Transaction], error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "ListTransactions", ctx, query)
+ ret0, _ := ret[0].(*bunpaginate.Cursor[ledger.Transaction])
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// ListTransactions indicates an expected call of ListTransactions.
+func (mr *LedgerControllerMockRecorder) ListTransactions(ctx, query any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListTransactions", reflect.TypeOf((*LedgerController)(nil).ListTransactions), ctx, query)
+}
+
+// RevertTransaction mocks base method.
+func (m *LedgerController) RevertTransaction(ctx context.Context, parameters ledger0.Parameters[ledger0.RevertTransaction]) (*ledger.RevertedTransaction, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "RevertTransaction", ctx, parameters)
+ ret0, _ := ret[0].(*ledger.RevertedTransaction)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// RevertTransaction indicates an expected call of RevertTransaction.
+func (mr *LedgerControllerMockRecorder) RevertTransaction(ctx, parameters any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RevertTransaction", reflect.TypeOf((*LedgerController)(nil).RevertTransaction), ctx, parameters)
+}
+
+// SaveAccountMetadata mocks base method.
+func (m *LedgerController) SaveAccountMetadata(ctx context.Context, parameters ledger0.Parameters[ledger0.SaveAccountMetadata]) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "SaveAccountMetadata", ctx, parameters)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// SaveAccountMetadata indicates an expected call of SaveAccountMetadata.
+func (mr *LedgerControllerMockRecorder) SaveAccountMetadata(ctx, parameters any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SaveAccountMetadata", reflect.TypeOf((*LedgerController)(nil).SaveAccountMetadata), ctx, parameters)
+}
+
+// SaveTransactionMetadata mocks base method.
+func (m *LedgerController) SaveTransactionMetadata(ctx context.Context, parameters ledger0.Parameters[ledger0.SaveTransactionMetadata]) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "SaveTransactionMetadata", ctx, parameters)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// SaveTransactionMetadata indicates an expected call of SaveTransactionMetadata.
+func (mr *LedgerControllerMockRecorder) SaveTransactionMetadata(ctx, parameters any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SaveTransactionMetadata", reflect.TypeOf((*LedgerController)(nil).SaveTransactionMetadata), ctx, parameters)
+}
diff --git a/internal/api/v2/mocks_system_controller_test.go b/internal/api/v2/mocks_system_controller_test.go
new file mode 100644
index 000000000..579a731b8
--- /dev/null
+++ b/internal/api/v2/mocks_system_controller_test.go
@@ -0,0 +1,126 @@
+// Code generated by MockGen. DO NOT EDIT.
+//
+// Generated by this command:
+//
+// mockgen -write_source_comment=false -write_package_comment=false -source ../../controller/system/controller.go -destination mocks_system_controller_test.go -package v2 --mock_names Controller=SystemController . Controller
+package v2
+
+import (
+ context "context"
+ reflect "reflect"
+
+ bunpaginate "github.com/formancehq/go-libs/bun/bunpaginate"
+ ledger "github.com/formancehq/ledger/internal"
+ ledger0 "github.com/formancehq/ledger/internal/controller/ledger"
+ gomock "go.uber.org/mock/gomock"
+)
+
+// SystemController is a mock of Controller interface.
+type SystemController struct {
+ ctrl *gomock.Controller
+ recorder *SystemControllerMockRecorder
+}
+
+// SystemControllerMockRecorder is the mock recorder for SystemController.
+type SystemControllerMockRecorder struct {
+ mock *SystemController
+}
+
+// NewSystemController creates a new mock instance.
+func NewSystemController(ctrl *gomock.Controller) *SystemController {
+ mock := &SystemController{ctrl: ctrl}
+ mock.recorder = &SystemControllerMockRecorder{mock}
+ return mock
+}
+
+// EXPECT returns an object that allows the caller to indicate expected use.
+func (m *SystemController) EXPECT() *SystemControllerMockRecorder {
+ return m.recorder
+}
+
+// CreateLedger mocks base method.
+func (m *SystemController) CreateLedger(ctx context.Context, name string, configuration ledger.Configuration) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "CreateLedger", ctx, name, configuration)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// CreateLedger indicates an expected call of CreateLedger.
+func (mr *SystemControllerMockRecorder) CreateLedger(ctx, name, configuration any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateLedger", reflect.TypeOf((*SystemController)(nil).CreateLedger), ctx, name, configuration)
+}
+
+// DeleteLedgerMetadata mocks base method.
+func (m *SystemController) DeleteLedgerMetadata(ctx context.Context, param, key string) error {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "DeleteLedgerMetadata", ctx, param, key)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// DeleteLedgerMetadata indicates an expected call of DeleteLedgerMetadata.
+func (mr *SystemControllerMockRecorder) DeleteLedgerMetadata(ctx, param, key any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteLedgerMetadata", reflect.TypeOf((*SystemController)(nil).DeleteLedgerMetadata), ctx, param, key)
+}
+
+// GetLedger mocks base method.
+func (m *SystemController) GetLedger(ctx context.Context, name string) (*ledger.Ledger, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetLedger", ctx, name)
+ ret0, _ := ret[0].(*ledger.Ledger)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetLedger indicates an expected call of GetLedger.
+func (mr *SystemControllerMockRecorder) GetLedger(ctx, name any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLedger", reflect.TypeOf((*SystemController)(nil).GetLedger), ctx, name)
+}
+
+// GetLedgerController mocks base method.
+func (m *SystemController) GetLedgerController(ctx context.Context, name string) (ledger0.Controller, error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "GetLedgerController", ctx, name)
+ ret0, _ := ret[0].(ledger0.Controller)
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// GetLedgerController indicates an expected call of GetLedgerController.
+func (mr *SystemControllerMockRecorder) GetLedgerController(ctx, name any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLedgerController", reflect.TypeOf((*SystemController)(nil).GetLedgerController), ctx, name)
+}
+
+// ListLedgers mocks base method.
+func (m *SystemController) ListLedgers(ctx context.Context, query ledger0.ListLedgersQuery) (*bunpaginate.Cursor[ledger.Ledger], error) {
+ m.ctrl.T.Helper()
+ ret := m.ctrl.Call(m, "ListLedgers", ctx, query)
+ ret0, _ := ret[0].(*bunpaginate.Cursor[ledger.Ledger])
+ ret1, _ := ret[1].(error)
+ return ret0, ret1
+}
+
+// ListLedgers indicates an expected call of ListLedgers.
+func (mr *SystemControllerMockRecorder) ListLedgers(ctx, query any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListLedgers", reflect.TypeOf((*SystemController)(nil).ListLedgers), ctx, query)
+}
+
+// UpdateLedgerMetadata mocks base method.
+func (m_2 *SystemController) UpdateLedgerMetadata(ctx context.Context, name string, m map[string]string) error {
+ m_2.ctrl.T.Helper()
+ ret := m_2.ctrl.Call(m_2, "UpdateLedgerMetadata", ctx, name, m)
+ ret0, _ := ret[0].(error)
+ return ret0
+}
+
+// UpdateLedgerMetadata indicates an expected call of UpdateLedgerMetadata.
+func (mr *SystemControllerMockRecorder) UpdateLedgerMetadata(ctx, name, m any) *gomock.Call {
+ mr.mock.ctrl.T.Helper()
+ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateLedgerMetadata", reflect.TypeOf((*SystemController)(nil).UpdateLedgerMetadata), ctx, name, m)
+}
diff --git a/internal/controller/ledger/README.md b/internal/controller/ledger/README.md
new file mode 100644
index 000000000..e50d7fed3
--- /dev/null
+++ b/internal/controller/ledger/README.md
@@ -0,0 +1,1897 @@
+
+
+# ledger
+
+```go
+import "github.com/formancehq/ledger/internal/controller/ledger"
+```
+
+Controller doc
+
+## Index
+
+- [Variables](<#variables>)
+- [type Balance](<#Balance>)
+- [type BalanceQuery](<#BalanceQuery>)
+- [type Balances](<#Balances>)
+- [type CacheConfiguration](<#CacheConfiguration>)
+- [type CachedCompiler](<#CachedCompiler>)
+ - [func NewCachedCompiler\(compiler Compiler, configuration CacheConfiguration\) \*CachedCompiler](<#NewCachedCompiler>)
+ - [func \(c \*CachedCompiler\) Compile\(script string\) \(\*program.Program, error\)](<#CachedCompiler.Compile>)
+- [type Compiler](<#Compiler>)
+- [type CompilerFn](<#CompilerFn>)
+ - [func NewDefaultCompiler\(\) CompilerFn](<#NewDefaultCompiler>)
+ - [func \(fn CompilerFn\) Compile\(script string\) \(\*program.Program, error\)](<#CompilerFn.Compile>)
+- [type Controller](<#Controller>)
+- [type ControllerWithCache](<#ControllerWithCache>)
+ - [func NewControllerWithCache\(ledger ledger.Ledger, underlying Controller, registry \*StateRegistry\) \*ControllerWithCache](<#NewControllerWithCache>)
+ - [func \(c \*ControllerWithCache\) IsDatabaseUpToDate\(ctx context.Context\) \(bool, error\)](<#ControllerWithCache.IsDatabaseUpToDate>)
+- [type ControllerWithEvents](<#ControllerWithEvents>)
+ - [func NewControllerWithEvents\(ledger ledger.Ledger, underlying Controller, listener Listener\) \*ControllerWithEvents](<#NewControllerWithEvents>)
+ - [func \(ctrl \*ControllerWithEvents\) CreateTransaction\(ctx context.Context, parameters Parameters\[RunScript\]\) \(\*ledger.CreatedTransaction, error\)](<#ControllerWithEvents.CreateTransaction>)
+ - [func \(ctrl \*ControllerWithEvents\) DeleteAccountMetadata\(ctx context.Context, parameters Parameters\[DeleteAccountMetadata\]\) error](<#ControllerWithEvents.DeleteAccountMetadata>)
+ - [func \(ctrl \*ControllerWithEvents\) DeleteTransactionMetadata\(ctx context.Context, parameters Parameters\[DeleteTransactionMetadata\]\) error](<#ControllerWithEvents.DeleteTransactionMetadata>)
+ - [func \(ctrl \*ControllerWithEvents\) RevertTransaction\(ctx context.Context, parameters Parameters\[RevertTransaction\]\) \(\*ledger.RevertedTransaction, error\)](<#ControllerWithEvents.RevertTransaction>)
+ - [func \(ctrl \*ControllerWithEvents\) SaveAccountMetadata\(ctx context.Context, parameters Parameters\[SaveAccountMetadata\]\) error](<#ControllerWithEvents.SaveAccountMetadata>)
+ - [func \(ctrl \*ControllerWithEvents\) SaveTransactionMetadata\(ctx context.Context, parameters Parameters\[SaveTransactionMetadata\]\) error](<#ControllerWithEvents.SaveTransactionMetadata>)
+- [type ControllerWithTraces](<#ControllerWithTraces>)
+ - [func NewControllerWithTraces\(underlying Controller\) \*ControllerWithTraces](<#NewControllerWithTraces>)
+ - [func \(ctrl \*ControllerWithTraces\) CountAccounts\(ctx context.Context, a ListAccountsQuery\) \(int, error\)](<#ControllerWithTraces.CountAccounts>)
+ - [func \(ctrl \*ControllerWithTraces\) CountTransactions\(ctx context.Context, q ListTransactionsQuery\) \(int, error\)](<#ControllerWithTraces.CountTransactions>)
+ - [func \(ctrl \*ControllerWithTraces\) CreateTransaction\(ctx context.Context, parameters Parameters\[RunScript\]\) \(\*ledger.CreatedTransaction, error\)](<#ControllerWithTraces.CreateTransaction>)
+ - [func \(ctrl \*ControllerWithTraces\) DeleteAccountMetadata\(ctx context.Context, parameters Parameters\[DeleteAccountMetadata\]\) error](<#ControllerWithTraces.DeleteAccountMetadata>)
+ - [func \(ctrl \*ControllerWithTraces\) DeleteTransactionMetadata\(ctx context.Context, parameters Parameters\[DeleteTransactionMetadata\]\) error](<#ControllerWithTraces.DeleteTransactionMetadata>)
+ - [func \(ctrl \*ControllerWithTraces\) Export\(ctx context.Context, w ExportWriter\) error](<#ControllerWithTraces.Export>)
+ - [func \(ctrl \*ControllerWithTraces\) GetAccount\(ctx context.Context, q GetAccountQuery\) \(\*ledger.Account, error\)](<#ControllerWithTraces.GetAccount>)
+ - [func \(ctrl \*ControllerWithTraces\) GetAggregatedBalances\(ctx context.Context, q GetAggregatedBalanceQuery\) \(ledger.BalancesByAssets, error\)](<#ControllerWithTraces.GetAggregatedBalances>)
+ - [func \(ctrl \*ControllerWithTraces\) GetMigrationsInfo\(ctx context.Context\) \(\[\]migrations.Info, error\)](<#ControllerWithTraces.GetMigrationsInfo>)
+ - [func \(ctrl \*ControllerWithTraces\) GetStats\(ctx context.Context\) \(Stats, error\)](<#ControllerWithTraces.GetStats>)
+ - [func \(ctrl \*ControllerWithTraces\) GetTransaction\(ctx context.Context, query GetTransactionQuery\) \(\*ledger.Transaction, error\)](<#ControllerWithTraces.GetTransaction>)
+ - [func \(ctrl \*ControllerWithTraces\) GetVolumesWithBalances\(ctx context.Context, q GetVolumesWithBalancesQuery\) \(\*bunpaginate.Cursor\[ledger.VolumesWithBalanceByAssetByAccount\], error\)](<#ControllerWithTraces.GetVolumesWithBalances>)
+ - [func \(ctrl \*ControllerWithTraces\) Import\(ctx context.Context, stream chan ledger.Log\) error](<#ControllerWithTraces.Import>)
+ - [func \(ctrl \*ControllerWithTraces\) IsDatabaseUpToDate\(ctx context.Context\) \(bool, error\)](<#ControllerWithTraces.IsDatabaseUpToDate>)
+ - [func \(ctrl \*ControllerWithTraces\) ListAccounts\(ctx context.Context, a ListAccountsQuery\) \(\*bunpaginate.Cursor\[ledger.Account\], error\)](<#ControllerWithTraces.ListAccounts>)
+ - [func \(ctrl \*ControllerWithTraces\) ListLogs\(ctx context.Context, q GetLogsQuery\) \(\*bunpaginate.Cursor\[ledger.Log\], error\)](<#ControllerWithTraces.ListLogs>)
+ - [func \(ctrl \*ControllerWithTraces\) ListTransactions\(ctx context.Context, q ListTransactionsQuery\) \(\*bunpaginate.Cursor\[ledger.Transaction\], error\)](<#ControllerWithTraces.ListTransactions>)
+ - [func \(ctrl \*ControllerWithTraces\) RevertTransaction\(ctx context.Context, parameters Parameters\[RevertTransaction\]\) \(\*ledger.RevertedTransaction, error\)](<#ControllerWithTraces.RevertTransaction>)
+ - [func \(ctrl \*ControllerWithTraces\) SaveAccountMetadata\(ctx context.Context, parameters Parameters\[SaveAccountMetadata\]\) error](<#ControllerWithTraces.SaveAccountMetadata>)
+ - [func \(ctrl \*ControllerWithTraces\) SaveTransactionMetadata\(ctx context.Context, parameters Parameters\[SaveTransactionMetadata\]\) error](<#ControllerWithTraces.SaveTransactionMetadata>)
+- [type DefaultController](<#DefaultController>)
+ - [func NewDefaultController\(ledger ledger.Ledger, store Store, machineFactory MachineFactory\) \*DefaultController](<#NewDefaultController>)
+ - [func \(ctrl \*DefaultController\) CountAccounts\(ctx context.Context, a ListAccountsQuery\) \(int, error\)](<#DefaultController.CountAccounts>)
+ - [func \(ctrl \*DefaultController\) CountTransactions\(ctx context.Context, q ListTransactionsQuery\) \(int, error\)](<#DefaultController.CountTransactions>)
+ - [func \(ctrl \*DefaultController\) CreateTransaction\(ctx context.Context, parameters Parameters\[RunScript\]\) \(\*ledger.CreatedTransaction, error\)](<#DefaultController.CreateTransaction>)
+ - [func \(ctrl \*DefaultController\) DeleteAccountMetadata\(ctx context.Context, parameters Parameters\[DeleteAccountMetadata\]\) error](<#DefaultController.DeleteAccountMetadata>)
+ - [func \(ctrl \*DefaultController\) DeleteTransactionMetadata\(ctx context.Context, parameters Parameters\[DeleteTransactionMetadata\]\) error](<#DefaultController.DeleteTransactionMetadata>)
+ - [func \(ctrl \*DefaultController\) Export\(ctx context.Context, w ExportWriter\) error](<#DefaultController.Export>)
+ - [func \(ctrl \*DefaultController\) GetAccount\(ctx context.Context, q GetAccountQuery\) \(\*ledger.Account, error\)](<#DefaultController.GetAccount>)
+ - [func \(ctrl \*DefaultController\) GetAggregatedBalances\(ctx context.Context, q GetAggregatedBalanceQuery\) \(ledger.BalancesByAssets, error\)](<#DefaultController.GetAggregatedBalances>)
+ - [func \(ctrl \*DefaultController\) GetMigrationsInfo\(ctx context.Context\) \(\[\]migrations.Info, error\)](<#DefaultController.GetMigrationsInfo>)
+ - [func \(ctrl \*DefaultController\) GetStats\(ctx context.Context\) \(Stats, error\)](<#DefaultController.GetStats>)
+ - [func \(ctrl \*DefaultController\) GetTransaction\(ctx context.Context, query GetTransactionQuery\) \(\*ledger.Transaction, error\)](<#DefaultController.GetTransaction>)
+ - [func \(ctrl \*DefaultController\) GetVolumesWithBalances\(ctx context.Context, q GetVolumesWithBalancesQuery\) \(\*bunpaginate.Cursor\[ledger.VolumesWithBalanceByAssetByAccount\], error\)](<#DefaultController.GetVolumesWithBalances>)
+ - [func \(ctrl \*DefaultController\) Import\(ctx context.Context, stream chan ledger.Log\) error](<#DefaultController.Import>)
+ - [func \(ctrl \*DefaultController\) IsDatabaseUpToDate\(ctx context.Context\) \(bool, error\)](<#DefaultController.IsDatabaseUpToDate>)
+ - [func \(ctrl \*DefaultController\) ListAccounts\(ctx context.Context, a ListAccountsQuery\) \(\*bunpaginate.Cursor\[ledger.Account\], error\)](<#DefaultController.ListAccounts>)
+ - [func \(ctrl \*DefaultController\) ListLogs\(ctx context.Context, q GetLogsQuery\) \(\*bunpaginate.Cursor\[ledger.Log\], error\)](<#DefaultController.ListLogs>)
+ - [func \(ctrl \*DefaultController\) ListTransactions\(ctx context.Context, q ListTransactionsQuery\) \(\*bunpaginate.Cursor\[ledger.Transaction\], error\)](<#DefaultController.ListTransactions>)
+ - [func \(ctrl \*DefaultController\) RevertTransaction\(ctx context.Context, parameters Parameters\[RevertTransaction\]\) \(\*ledger.RevertedTransaction, error\)](<#DefaultController.RevertTransaction>)
+ - [func \(ctrl \*DefaultController\) SaveAccountMetadata\(ctx context.Context, parameters Parameters\[SaveAccountMetadata\]\) error](<#DefaultController.SaveAccountMetadata>)
+ - [func \(ctrl \*DefaultController\) SaveTransactionMetadata\(ctx context.Context, parameters Parameters\[SaveTransactionMetadata\]\) error](<#DefaultController.SaveTransactionMetadata>)
+- [type DefaultMachineAdapter](<#DefaultMachineAdapter>)
+ - [func NewDefaultMachine\(p program.Program\) \*DefaultMachineAdapter](<#NewDefaultMachine>)
+ - [func \(d \*DefaultMachineAdapter\) Execute\(ctx context.Context, store vm.Store, vars map\[string\]string\) \(\*MachineResult, error\)](<#DefaultMachineAdapter.Execute>)
+- [type DefaultMachineFactory](<#DefaultMachineFactory>)
+ - [func NewDefaultMachineFactory\(compiler Compiler\) \*DefaultMachineFactory](<#NewDefaultMachineFactory>)
+ - [func \(d \*DefaultMachineFactory\) Make\(script string\) \(Machine, error\)](<#DefaultMachineFactory.Make>)
+- [type DeleteAccountMetadata](<#DeleteAccountMetadata>)
+- [type DeleteTransactionMetadata](<#DeleteTransactionMetadata>)
+- [type ErrAlreadyReverted](<#ErrAlreadyReverted>)
+ - [func \(e ErrAlreadyReverted\) Error\(\) string](<#ErrAlreadyReverted.Error>)
+ - [func \(e ErrAlreadyReverted\) Is\(err error\) bool](<#ErrAlreadyReverted.Is>)
+- [type ErrCompilationFailed](<#ErrCompilationFailed>)
+ - [func \(e ErrCompilationFailed\) Error\(\) string](<#ErrCompilationFailed.Error>)
+ - [func \(e ErrCompilationFailed\) Is\(err error\) bool](<#ErrCompilationFailed.Is>)
+- [type ErrIdempotencyKeyConflict](<#ErrIdempotencyKeyConflict>)
+ - [func NewErrIdempotencyKeyConflict\(ik string\) ErrIdempotencyKeyConflict](<#NewErrIdempotencyKeyConflict>)
+ - [func \(e ErrIdempotencyKeyConflict\) Error\(\) string](<#ErrIdempotencyKeyConflict.Error>)
+ - [func \(e ErrIdempotencyKeyConflict\) Is\(err error\) bool](<#ErrIdempotencyKeyConflict.Is>)
+- [type ErrImport](<#ErrImport>)
+ - [func \(i ErrImport\) Error\(\) string](<#ErrImport.Error>)
+ - [func \(i ErrImport\) Is\(err error\) bool](<#ErrImport.Is>)
+- [type ErrInsufficientFunds](<#ErrInsufficientFunds>)
+- [type ErrInvalidHash](<#ErrInvalidHash>)
+ - [func \(i ErrInvalidHash\) Error\(\) string](<#ErrInvalidHash.Error>)
+- [type ErrInvalidIdempotencyInput](<#ErrInvalidIdempotencyInput>)
+ - [func \(e ErrInvalidIdempotencyInput\) Error\(\) string](<#ErrInvalidIdempotencyInput.Error>)
+ - [func \(e ErrInvalidIdempotencyInput\) Is\(err error\) bool](<#ErrInvalidIdempotencyInput.Is>)
+- [type ErrInvalidQuery](<#ErrInvalidQuery>)
+ - [func NewErrInvalidQuery\(msg string, args ...any\) ErrInvalidQuery](<#NewErrInvalidQuery>)
+ - [func \(e ErrInvalidQuery\) Error\(\) string](<#ErrInvalidQuery.Error>)
+ - [func \(e ErrInvalidQuery\) Is\(err error\) bool](<#ErrInvalidQuery.Is>)
+- [type ErrInvalidVars](<#ErrInvalidVars>)
+- [type ErrMetadataOverride](<#ErrMetadataOverride>)
+ - [func \(e \*ErrMetadataOverride\) Error\(\) string](<#ErrMetadataOverride.Error>)
+ - [func \(e \*ErrMetadataOverride\) Is\(err error\) bool](<#ErrMetadataOverride.Is>)
+- [type ErrMissingFeature](<#ErrMissingFeature>)
+ - [func NewErrMissingFeature\(feature string\) ErrMissingFeature](<#NewErrMissingFeature>)
+ - [func \(e ErrMissingFeature\) Error\(\) string](<#ErrMissingFeature.Error>)
+ - [func \(e ErrMissingFeature\) Is\(err error\) bool](<#ErrMissingFeature.Is>)
+- [type ErrTransactionReferenceConflict](<#ErrTransactionReferenceConflict>)
+ - [func NewErrTransactionReferenceConflict\(reference string\) ErrTransactionReferenceConflict](<#NewErrTransactionReferenceConflict>)
+ - [func \(e ErrTransactionReferenceConflict\) Error\(\) string](<#ErrTransactionReferenceConflict.Error>)
+ - [func \(e ErrTransactionReferenceConflict\) Is\(err error\) bool](<#ErrTransactionReferenceConflict.Is>)
+- [type ExportWriter](<#ExportWriter>)
+- [type ExportWriterFn](<#ExportWriterFn>)
+ - [func \(fn ExportWriterFn\) Write\(ctx context.Context, log ledger.Log\) error](<#ExportWriterFn.Write>)
+- [type FiltersForVolumes](<#FiltersForVolumes>)
+- [type GetAccountQuery](<#GetAccountQuery>)
+ - [func NewGetAccountQuery\(addr string\) GetAccountQuery](<#NewGetAccountQuery>)
+ - [func \(q GetAccountQuery\) WithExpandEffectiveVolumes\(\) GetAccountQuery](<#GetAccountQuery.WithExpandEffectiveVolumes>)
+ - [func \(q GetAccountQuery\) WithExpandVolumes\(\) GetAccountQuery](<#GetAccountQuery.WithExpandVolumes>)
+ - [func \(q GetAccountQuery\) WithPIT\(pit time.Time\) GetAccountQuery](<#GetAccountQuery.WithPIT>)
+- [type GetAggregatedBalanceQuery](<#GetAggregatedBalanceQuery>)
+ - [func NewGetAggregatedBalancesQuery\(filter PITFilter, qb query.Builder, useInsertionDate bool\) GetAggregatedBalanceQuery](<#NewGetAggregatedBalancesQuery>)
+- [type GetLogsQuery](<#GetLogsQuery>)
+ - [func NewListLogsQuery\(options PaginatedQueryOptions\[any\]\) GetLogsQuery](<#NewListLogsQuery>)
+ - [func \(q GetLogsQuery\) WithOrder\(order bunpaginate.Order\) GetLogsQuery](<#GetLogsQuery.WithOrder>)
+- [type GetTransactionQuery](<#GetTransactionQuery>)
+ - [func NewGetTransactionQuery\(id int\) GetTransactionQuery](<#NewGetTransactionQuery>)
+ - [func \(q GetTransactionQuery\) WithExpandEffectiveVolumes\(\) GetTransactionQuery](<#GetTransactionQuery.WithExpandEffectiveVolumes>)
+ - [func \(q GetTransactionQuery\) WithExpandVolumes\(\) GetTransactionQuery](<#GetTransactionQuery.WithExpandVolumes>)
+- [type GetVolumesWithBalancesQuery](<#GetVolumesWithBalancesQuery>)
+ - [func NewGetVolumesWithBalancesQuery\(opts PaginatedQueryOptions\[FiltersForVolumes\]\) GetVolumesWithBalancesQuery](<#NewGetVolumesWithBalancesQuery>)
+- [type ListAccountsQuery](<#ListAccountsQuery>)
+ - [func NewListAccountsQuery\(opts PaginatedQueryOptions\[PITFilterWithVolumes\]\) ListAccountsQuery](<#NewListAccountsQuery>)
+ - [func \(q ListAccountsQuery\) WithExpandEffectiveVolumes\(\) ListAccountsQuery](<#ListAccountsQuery.WithExpandEffectiveVolumes>)
+ - [func \(q ListAccountsQuery\) WithExpandVolumes\(\) ListAccountsQuery](<#ListAccountsQuery.WithExpandVolumes>)
+- [type ListLedgersQuery](<#ListLedgersQuery>)
+ - [func NewListLedgersQuery\(pageSize uint64\) ListLedgersQuery](<#NewListLedgersQuery>)
+- [type ListTransactionsQuery](<#ListTransactionsQuery>)
+ - [func NewListTransactionsQuery\(options PaginatedQueryOptions\[PITFilterWithVolumes\]\) ListTransactionsQuery](<#NewListTransactionsQuery>)
+ - [func \(q ListTransactionsQuery\) WithColumn\(column string\) ListTransactionsQuery](<#ListTransactionsQuery.WithColumn>)
+- [type Listener](<#Listener>)
+- [type Machine](<#Machine>)
+- [type MachineFactory](<#MachineFactory>)
+- [type MachineResult](<#MachineResult>)
+- [type PITFilter](<#PITFilter>)
+- [type PITFilterWithVolumes](<#PITFilterWithVolumes>)
+- [type PaginatedQueryOptions](<#PaginatedQueryOptions>)
+ - [func NewPaginatedQueryOptions\[T any\]\(options T\) PaginatedQueryOptions\[T\]](<#NewPaginatedQueryOptions>)
+ - [func \(opts \*PaginatedQueryOptions\[T\]\) UnmarshalJSON\(data \[\]byte\) error](<#PaginatedQueryOptions[T].UnmarshalJSON>)
+ - [func \(opts PaginatedQueryOptions\[T\]\) WithPageSize\(pageSize uint64\) PaginatedQueryOptions\[T\]](<#PaginatedQueryOptions[T].WithPageSize>)
+ - [func \(opts PaginatedQueryOptions\[T\]\) WithQueryBuilder\(qb query.Builder\) PaginatedQueryOptions\[T\]](<#PaginatedQueryOptions[T].WithQueryBuilder>)
+- [type Parameters](<#Parameters>)
+- [type RevertTransaction](<#RevertTransaction>)
+- [type RunScript](<#RunScript>)
+- [type SaveAccountMetadata](<#SaveAccountMetadata>)
+- [type SaveTransactionMetadata](<#SaveTransactionMetadata>)
+- [type Script](<#Script>)
+- [type ScriptV1](<#ScriptV1>)
+- [type State](<#State>)
+- [type StateRegistry](<#StateRegistry>)
+ - [func NewStateRegistry\(\) \*StateRegistry](<#NewStateRegistry>)
+ - [func \(r \*StateRegistry\) IsUpToDate\(name string\) bool](<#StateRegistry.IsUpToDate>)
+ - [func \(r \*StateRegistry\) SetUpToDate\(name string\)](<#StateRegistry.SetUpToDate>)
+ - [func \(r \*StateRegistry\) Upsert\(l ledger.Ledger\) bool](<#StateRegistry.Upsert>)
+- [type Stats](<#Stats>)
+- [type Store](<#Store>)
+- [type TX](<#TX>)
+
+
+## Variables
+
+
+
+```go
+var ErrNoPostings = errors.New("numscript execution returned no postings")
+```
+
+
+
+```go
+var ErrNotFound = postgres.ErrNotFound
+```
+
+
+## type [Balance]()
+
+
+
+```go
+type Balance struct {
+ Asset string
+ Balance *big.Int
+}
+```
+
+
+## type [BalanceQuery]()
+
+
+
+```go
+type BalanceQuery = vm.BalanceQuery
+```
+
+
+## type [Balances]()
+
+
+
+```go
+type Balances = vm.Balances
+```
+
+
+## type [CacheConfiguration]()
+
+
+
+```go
+type CacheConfiguration struct {
+ MaxCount uint
+}
+```
+
+
+## type [CachedCompiler]()
+
+
+
+```go
+type CachedCompiler struct {
+ // contains filtered or unexported fields
+}
+```
+
+
+### func [NewCachedCompiler]()
+
+```go
+func NewCachedCompiler(compiler Compiler, configuration CacheConfiguration) *CachedCompiler
+```
+
+
+
+
+### func \(\*CachedCompiler\) [Compile]()
+
+```go
+func (c *CachedCompiler) Compile(script string) (*program.Program, error)
+```
+
+
+
+
+## type [Compiler]()
+
+Compiler can return following errors:
+
+- ErrCompilationFailed
+
+```go
+type Compiler interface {
+ Compile(script string) (*program.Program, error)
+}
+```
+
+
+## type [CompilerFn]()
+
+
+
+```go
+type CompilerFn func(script string) (*program.Program, error)
+```
+
+
+### func [NewDefaultCompiler]()
+
+```go
+func NewDefaultCompiler() CompilerFn
+```
+
+
+
+
+### func \(CompilerFn\) [Compile]()
+
+```go
+func (fn CompilerFn) Compile(script string) (*program.Program, error)
+```
+
+
+
+
+## type [Controller]()
+
+
+
+```go
+type Controller interface {
+ // IsDatabaseUpToDate check if the ledger store is up to date, including the bucket and the ledger specifics
+ // It returns true if up to date
+ IsDatabaseUpToDate(ctx context.Context) (bool, error)
+ GetMigrationsInfo(ctx context.Context) ([]migrations.Info, error)
+ GetStats(ctx context.Context) (Stats, error)
+
+ GetAccount(ctx context.Context, query GetAccountQuery) (*ledger.Account, error)
+ ListAccounts(ctx context.Context, query ListAccountsQuery) (*bunpaginate.Cursor[ledger.Account], error)
+ CountAccounts(ctx context.Context, query ListAccountsQuery) (int, error)
+ ListLogs(ctx context.Context, query GetLogsQuery) (*bunpaginate.Cursor[ledger.Log], error)
+ CountTransactions(ctx context.Context, query ListTransactionsQuery) (int, error)
+ ListTransactions(ctx context.Context, query ListTransactionsQuery) (*bunpaginate.Cursor[ledger.Transaction], error)
+ GetTransaction(ctx context.Context, query GetTransactionQuery) (*ledger.Transaction, error)
+ GetVolumesWithBalances(ctx context.Context, q GetVolumesWithBalancesQuery) (*bunpaginate.Cursor[ledger.VolumesWithBalanceByAssetByAccount], error)
+ GetAggregatedBalances(ctx context.Context, q GetAggregatedBalanceQuery) (ledger.BalancesByAssets, error)
+
+ // CreateTransaction accept a numscript script and returns a transaction
+ // It can return following errors:
+ // * ErrCompilationFailed
+ // * ErrMetadataOverride
+ // * ErrInvalidVars
+ // * ErrTransactionReferenceConflict
+ // * ErrIdempotencyKeyConflict
+ // * ErrInsufficientFunds
+ CreateTransaction(ctx context.Context, parameters Parameters[RunScript]) (*ledger.CreatedTransaction, error)
+ // RevertTransaction allow to revert a transaction.
+ // It can return following errors:
+ // * ErrInsufficientFunds
+ // * ErrAlreadyReverted
+ // * ErrNotFound
+ // Parameter force indicate we want to force revert the transaction even if the accounts does not have funds
+ // Parameter atEffectiveDate indicate we want to set the timestamp of the newly created transaction on the timestamp of the reverted transaction
+ RevertTransaction(ctx context.Context, parameters Parameters[RevertTransaction]) (*ledger.RevertedTransaction, error)
+ // SaveTransactionMetadata allow to add metadata to an existing transaction
+ // It can return following errors:
+ // * ErrNotFound
+ SaveTransactionMetadata(ctx context.Context, parameters Parameters[SaveTransactionMetadata]) error
+ // SaveAccountMetadata allow to add metadata to an account
+ // If the account does not exist, it is created
+ SaveAccountMetadata(ctx context.Context, parameters Parameters[SaveAccountMetadata]) error
+ // DeleteTransactionMetadata allow to remove metadata of a transaction
+ // It can return following errors:
+ // * ErrNotFound : indicate the transaction was not found OR the metadata does not exist on the transaction
+ DeleteTransactionMetadata(ctx context.Context, parameters Parameters[DeleteTransactionMetadata]) error
+ // DeleteAccountMetadata allow to remove metadata of an account
+ // It can return following errors:
+ // * ErrNotFound : indicate the account was not found OR the metadata does not exist on the account
+ DeleteAccountMetadata(ctx context.Context, parameters Parameters[DeleteAccountMetadata]) error
+ // Import allow to import the logs of an existing ledger
+ // It can return following errors:
+ // * ErrImport
+ // Logs hash must be valid and the ledger.Ledger must be in 'initializing' state
+ Import(ctx context.Context, stream chan ledger.Log) error
+ // Export allow to export the logs of a ledger
+ Export(ctx context.Context, w ExportWriter) error
+}
+```
+
+
+## type [ControllerWithCache]()
+
+
+
+```go
+type ControllerWithCache struct {
+ Controller
+ // contains filtered or unexported fields
+}
+```
+
+
+### func [NewControllerWithCache]()
+
+```go
+func NewControllerWithCache(ledger ledger.Ledger, underlying Controller, registry *StateRegistry) *ControllerWithCache
+```
+
+
+
+
+### func \(\*ControllerWithCache\) [IsDatabaseUpToDate]()
+
+```go
+func (c *ControllerWithCache) IsDatabaseUpToDate(ctx context.Context) (bool, error)
+```
+
+
+
+
+## type [ControllerWithEvents]()
+
+
+
+```go
+type ControllerWithEvents struct {
+ Controller
+ // contains filtered or unexported fields
+}
+```
+
+
+### func [NewControllerWithEvents]()
+
+```go
+func NewControllerWithEvents(ledger ledger.Ledger, underlying Controller, listener Listener) *ControllerWithEvents
+```
+
+
+
+
+### func \(\*ControllerWithEvents\) [CreateTransaction]()
+
+```go
+func (ctrl *ControllerWithEvents) CreateTransaction(ctx context.Context, parameters Parameters[RunScript]) (*ledger.CreatedTransaction, error)
+```
+
+
+
+
+### func \(\*ControllerWithEvents\) [DeleteAccountMetadata]()
+
+```go
+func (ctrl *ControllerWithEvents) DeleteAccountMetadata(ctx context.Context, parameters Parameters[DeleteAccountMetadata]) error
+```
+
+
+
+
+### func \(\*ControllerWithEvents\) [DeleteTransactionMetadata]()
+
+```go
+func (ctrl *ControllerWithEvents) DeleteTransactionMetadata(ctx context.Context, parameters Parameters[DeleteTransactionMetadata]) error
+```
+
+
+
+
+### func \(\*ControllerWithEvents\) [RevertTransaction]()
+
+```go
+func (ctrl *ControllerWithEvents) RevertTransaction(ctx context.Context, parameters Parameters[RevertTransaction]) (*ledger.RevertedTransaction, error)
+```
+
+
+
+
+### func \(\*ControllerWithEvents\) [SaveAccountMetadata]()
+
+```go
+func (ctrl *ControllerWithEvents) SaveAccountMetadata(ctx context.Context, parameters Parameters[SaveAccountMetadata]) error
+```
+
+
+
+
+### func \(\*ControllerWithEvents\) [SaveTransactionMetadata]()
+
+```go
+func (ctrl *ControllerWithEvents) SaveTransactionMetadata(ctx context.Context, parameters Parameters[SaveTransactionMetadata]) error
+```
+
+
+
+
+## type [ControllerWithTraces]()
+
+
+
+```go
+type ControllerWithTraces struct {
+ // contains filtered or unexported fields
+}
+```
+
+
+### func [NewControllerWithTraces]()
+
+```go
+func NewControllerWithTraces(underlying Controller) *ControllerWithTraces
+```
+
+
+
+
+### func \(\*ControllerWithTraces\) [CountAccounts]()
+
+```go
+func (ctrl *ControllerWithTraces) CountAccounts(ctx context.Context, a ListAccountsQuery) (int, error)
+```
+
+
+
+
+### func \(\*ControllerWithTraces\) [CountTransactions]()
+
+```go
+func (ctrl *ControllerWithTraces) CountTransactions(ctx context.Context, q ListTransactionsQuery) (int, error)
+```
+
+
+
+
+### func \(\*ControllerWithTraces\) [CreateTransaction]()
+
+```go
+func (ctrl *ControllerWithTraces) CreateTransaction(ctx context.Context, parameters Parameters[RunScript]) (*ledger.CreatedTransaction, error)
+```
+
+
+
+
+### func \(\*ControllerWithTraces\) [DeleteAccountMetadata]()
+
+```go
+func (ctrl *ControllerWithTraces) DeleteAccountMetadata(ctx context.Context, parameters Parameters[DeleteAccountMetadata]) error
+```
+
+
+
+
+### func \(\*ControllerWithTraces\) [DeleteTransactionMetadata]()
+
+```go
+func (ctrl *ControllerWithTraces) DeleteTransactionMetadata(ctx context.Context, parameters Parameters[DeleteTransactionMetadata]) error
+```
+
+
+
+
+### func \(\*ControllerWithTraces\) [Export]()
+
+```go
+func (ctrl *ControllerWithTraces) Export(ctx context.Context, w ExportWriter) error
+```
+
+
+
+
+### func \(\*ControllerWithTraces\) [GetAccount]()
+
+```go
+func (ctrl *ControllerWithTraces) GetAccount(ctx context.Context, q GetAccountQuery) (*ledger.Account, error)
+```
+
+
+
+
+### func \(\*ControllerWithTraces\) [GetAggregatedBalances]()
+
+```go
+func (ctrl *ControllerWithTraces) GetAggregatedBalances(ctx context.Context, q GetAggregatedBalanceQuery) (ledger.BalancesByAssets, error)
+```
+
+
+
+
+### func \(\*ControllerWithTraces\) [GetMigrationsInfo]()
+
+```go
+func (ctrl *ControllerWithTraces) GetMigrationsInfo(ctx context.Context) ([]migrations.Info, error)
+```
+
+
+
+
+### func \(\*ControllerWithTraces\) [GetStats]()
+
+```go
+func (ctrl *ControllerWithTraces) GetStats(ctx context.Context) (Stats, error)
+```
+
+
+
+
+### func \(\*ControllerWithTraces\) [GetTransaction]()
+
+```go
+func (ctrl *ControllerWithTraces) GetTransaction(ctx context.Context, query GetTransactionQuery) (*ledger.Transaction, error)
+```
+
+
+
+
+### func \(\*ControllerWithTraces\) [GetVolumesWithBalances]()
+
+```go
+func (ctrl *ControllerWithTraces) GetVolumesWithBalances(ctx context.Context, q GetVolumesWithBalancesQuery) (*bunpaginate.Cursor[ledger.VolumesWithBalanceByAssetByAccount], error)
+```
+
+
+
+
+### func \(\*ControllerWithTraces\) [Import]()
+
+```go
+func (ctrl *ControllerWithTraces) Import(ctx context.Context, stream chan ledger.Log) error
+```
+
+
+
+
+### func \(\*ControllerWithTraces\) [IsDatabaseUpToDate]()
+
+```go
+func (ctrl *ControllerWithTraces) IsDatabaseUpToDate(ctx context.Context) (bool, error)
+```
+
+
+
+
+### func \(\*ControllerWithTraces\) [ListAccounts]()
+
+```go
+func (ctrl *ControllerWithTraces) ListAccounts(ctx context.Context, a ListAccountsQuery) (*bunpaginate.Cursor[ledger.Account], error)
+```
+
+
+
+
+### func \(\*ControllerWithTraces\) [ListLogs]()
+
+```go
+func (ctrl *ControllerWithTraces) ListLogs(ctx context.Context, q GetLogsQuery) (*bunpaginate.Cursor[ledger.Log], error)
+```
+
+
+
+
+### func \(\*ControllerWithTraces\) [ListTransactions]()
+
+```go
+func (ctrl *ControllerWithTraces) ListTransactions(ctx context.Context, q ListTransactionsQuery) (*bunpaginate.Cursor[ledger.Transaction], error)
+```
+
+
+
+
+### func \(\*ControllerWithTraces\) [RevertTransaction]()
+
+```go
+func (ctrl *ControllerWithTraces) RevertTransaction(ctx context.Context, parameters Parameters[RevertTransaction]) (*ledger.RevertedTransaction, error)
+```
+
+
+
+
+### func \(\*ControllerWithTraces\) [SaveAccountMetadata]()
+
+```go
+func (ctrl *ControllerWithTraces) SaveAccountMetadata(ctx context.Context, parameters Parameters[SaveAccountMetadata]) error
+```
+
+
+
+
+### func \(\*ControllerWithTraces\) [SaveTransactionMetadata]()
+
+```go
+func (ctrl *ControllerWithTraces) SaveTransactionMetadata(ctx context.Context, parameters Parameters[SaveTransactionMetadata]) error
+```
+
+
+
+
+## type [DefaultController]()
+
+
+
+```go
+type DefaultController struct {
+ // contains filtered or unexported fields
+}
+```
+
+
+### func [NewDefaultController]()
+
+```go
+func NewDefaultController(ledger ledger.Ledger, store Store, machineFactory MachineFactory) *DefaultController
+```
+
+
+
+
+### func \(\*DefaultController\) [CountAccounts]()
+
+```go
+func (ctrl *DefaultController) CountAccounts(ctx context.Context, a ListAccountsQuery) (int, error)
+```
+
+
+
+
+### func \(\*DefaultController\) [CountTransactions]()
+
+```go
+func (ctrl *DefaultController) CountTransactions(ctx context.Context, q ListTransactionsQuery) (int, error)
+```
+
+
+
+
+### func \(\*DefaultController\) [CreateTransaction]()
+
+```go
+func (ctrl *DefaultController) CreateTransaction(ctx context.Context, parameters Parameters[RunScript]) (*ledger.CreatedTransaction, error)
+```
+
+
+
+
+### func \(\*DefaultController\) [DeleteAccountMetadata]()
+
+```go
+func (ctrl *DefaultController) DeleteAccountMetadata(ctx context.Context, parameters Parameters[DeleteAccountMetadata]) error
+```
+
+
+
+
+### func \(\*DefaultController\) [DeleteTransactionMetadata]()
+
+```go
+func (ctrl *DefaultController) DeleteTransactionMetadata(ctx context.Context, parameters Parameters[DeleteTransactionMetadata]) error
+```
+
+
+
+
+### func \(\*DefaultController\) [Export]()
+
+```go
+func (ctrl *DefaultController) Export(ctx context.Context, w ExportWriter) error
+```
+
+
+
+
+### func \(\*DefaultController\) [GetAccount]()
+
+```go
+func (ctrl *DefaultController) GetAccount(ctx context.Context, q GetAccountQuery) (*ledger.Account, error)
+```
+
+
+
+
+### func \(\*DefaultController\) [GetAggregatedBalances]()
+
+```go
+func (ctrl *DefaultController) GetAggregatedBalances(ctx context.Context, q GetAggregatedBalanceQuery) (ledger.BalancesByAssets, error)
+```
+
+
+
+
+### func \(\*DefaultController\) [GetMigrationsInfo]()
+
+```go
+func (ctrl *DefaultController) GetMigrationsInfo(ctx context.Context) ([]migrations.Info, error)
+```
+
+
+
+
+### func \(\*DefaultController\) [GetStats]()
+
+```go
+func (ctrl *DefaultController) GetStats(ctx context.Context) (Stats, error)
+```
+
+
+
+
+### func \(\*DefaultController\) [GetTransaction]()
+
+```go
+func (ctrl *DefaultController) GetTransaction(ctx context.Context, query GetTransactionQuery) (*ledger.Transaction, error)
+```
+
+
+
+
+### func \(\*DefaultController\) [GetVolumesWithBalances]()
+
+```go
+func (ctrl *DefaultController) GetVolumesWithBalances(ctx context.Context, q GetVolumesWithBalancesQuery) (*bunpaginate.Cursor[ledger.VolumesWithBalanceByAssetByAccount], error)
+```
+
+
+
+
+### func \(\*DefaultController\) [Import]()
+
+```go
+func (ctrl *DefaultController) Import(ctx context.Context, stream chan ledger.Log) error
+```
+
+
+
+
+### func \(\*DefaultController\) [IsDatabaseUpToDate]()
+
+```go
+func (ctrl *DefaultController) IsDatabaseUpToDate(ctx context.Context) (bool, error)
+```
+
+
+
+
+### func \(\*DefaultController\) [ListAccounts]()
+
+```go
+func (ctrl *DefaultController) ListAccounts(ctx context.Context, a ListAccountsQuery) (*bunpaginate.Cursor[ledger.Account], error)
+```
+
+
+
+
+### func \(\*DefaultController\) [ListLogs]()
+
+```go
+func (ctrl *DefaultController) ListLogs(ctx context.Context, q GetLogsQuery) (*bunpaginate.Cursor[ledger.Log], error)
+```
+
+
+
+
+### func \(\*DefaultController\) [ListTransactions]()
+
+```go
+func (ctrl *DefaultController) ListTransactions(ctx context.Context, q ListTransactionsQuery) (*bunpaginate.Cursor[ledger.Transaction], error)
+```
+
+
+
+
+### func \(\*DefaultController\) [RevertTransaction]()
+
+```go
+func (ctrl *DefaultController) RevertTransaction(ctx context.Context, parameters Parameters[RevertTransaction]) (*ledger.RevertedTransaction, error)
+```
+
+
+
+
+### func \(\*DefaultController\) [SaveAccountMetadata]()
+
+```go
+func (ctrl *DefaultController) SaveAccountMetadata(ctx context.Context, parameters Parameters[SaveAccountMetadata]) error
+```
+
+
+
+
+### func \(\*DefaultController\) [SaveTransactionMetadata]()
+
+```go
+func (ctrl *DefaultController) SaveTransactionMetadata(ctx context.Context, parameters Parameters[SaveTransactionMetadata]) error
+```
+
+
+
+
+## type [DefaultMachineAdapter]()
+
+
+
+```go
+type DefaultMachineAdapter struct {
+ // contains filtered or unexported fields
+}
+```
+
+
+### func [NewDefaultMachine]()
+
+```go
+func NewDefaultMachine(p program.Program) *DefaultMachineAdapter
+```
+
+
+
+
+### func \(\*DefaultMachineAdapter\) [Execute]()
+
+```go
+func (d *DefaultMachineAdapter) Execute(ctx context.Context, store vm.Store, vars map[string]string) (*MachineResult, error)
+```
+
+
+
+
+## type [DefaultMachineFactory]()
+
+
+
+```go
+type DefaultMachineFactory struct {
+ // contains filtered or unexported fields
+}
+```
+
+
+### func [NewDefaultMachineFactory]()
+
+```go
+func NewDefaultMachineFactory(compiler Compiler) *DefaultMachineFactory
+```
+
+
+
+
+### func \(\*DefaultMachineFactory\) [Make]()
+
+```go
+func (d *DefaultMachineFactory) Make(script string) (Machine, error)
+```
+
+
+
+
+## type [DeleteAccountMetadata]()
+
+
+
+```go
+type DeleteAccountMetadata struct {
+ Address string
+ Key string
+}
+```
+
+
+## type [DeleteTransactionMetadata]()
+
+
+
+```go
+type DeleteTransactionMetadata struct {
+ TransactionID int
+ Key string
+}
+```
+
+
+## type [ErrAlreadyReverted]()
+
+
+
+```go
+type ErrAlreadyReverted struct {
+ // contains filtered or unexported fields
+}
+```
+
+
+### func \(ErrAlreadyReverted\) [Error]()
+
+```go
+func (e ErrAlreadyReverted) Error() string
+```
+
+
+
+
+### func \(ErrAlreadyReverted\) [Is]()
+
+```go
+func (e ErrAlreadyReverted) Is(err error) bool
+```
+
+
+
+
+## type [ErrCompilationFailed]()
+
+ErrCompilationFailed is used for any errors returned by the numscript interpreter
+
+```go
+type ErrCompilationFailed struct {
+ // contains filtered or unexported fields
+}
+```
+
+
+### func \(ErrCompilationFailed\) [Error]()
+
+```go
+func (e ErrCompilationFailed) Error() string
+```
+
+
+
+
+### func \(ErrCompilationFailed\) [Is]()
+
+```go
+func (e ErrCompilationFailed) Is(err error) bool
+```
+
+
+
+
+## type [ErrIdempotencyKeyConflict]()
+
+
+
+```go
+type ErrIdempotencyKeyConflict struct {
+ // contains filtered or unexported fields
+}
+```
+
+
+### func [NewErrIdempotencyKeyConflict]()
+
+```go
+func NewErrIdempotencyKeyConflict(ik string) ErrIdempotencyKeyConflict
+```
+
+
+
+
+### func \(ErrIdempotencyKeyConflict\) [Error]()
+
+```go
+func (e ErrIdempotencyKeyConflict) Error() string
+```
+
+
+
+
+### func \(ErrIdempotencyKeyConflict\) [Is]()
+
+```go
+func (e ErrIdempotencyKeyConflict) Is(err error) bool
+```
+
+
+
+
+## type [ErrImport]()
+
+
+
+```go
+type ErrImport struct {
+ // contains filtered or unexported fields
+}
+```
+
+
+### func \(ErrImport\) [Error]()
+
+```go
+func (i ErrImport) Error() string
+```
+
+
+
+
+### func \(ErrImport\) [Is]()
+
+```go
+func (i ErrImport) Is(err error) bool
+```
+
+
+
+
+## type [ErrInsufficientFunds]()
+
+todo\(waiting\): need a more precise underlying error notes\(gfyrag\): Waiting new interpreter
+
+```go
+type ErrInsufficientFunds = machine.ErrInsufficientFund
+```
+
+
+## type [ErrInvalidHash]()
+
+
+
+```go
+type ErrInvalidHash struct {
+ // contains filtered or unexported fields
+}
+```
+
+
+### func \(ErrInvalidHash\) [Error]()
+
+```go
+func (i ErrInvalidHash) Error() string
+```
+
+
+
+
+## type [ErrInvalidIdempotencyInput]()
+
+ErrInvalidIdempotencyInput is used when a IK is used with an inputs different from the original one. For example, try to use the same IK with a different numscript script will result with that error.
+
+```go
+type ErrInvalidIdempotencyInput struct {
+ // contains filtered or unexported fields
+}
+```
+
+
+### func \(ErrInvalidIdempotencyInput\) [Error]()
+
+```go
+func (e ErrInvalidIdempotencyInput) Error() string
+```
+
+
+
+
+### func \(ErrInvalidIdempotencyInput\) [Is]()
+
+```go
+func (e ErrInvalidIdempotencyInput) Is(err error) bool
+```
+
+
+
+
+## type [ErrInvalidQuery]()
+
+
+
+```go
+type ErrInvalidQuery struct {
+ // contains filtered or unexported fields
+}
+```
+
+
+### func [NewErrInvalidQuery]()
+
+```go
+func NewErrInvalidQuery(msg string, args ...any) ErrInvalidQuery
+```
+
+
+
+
+### func \(ErrInvalidQuery\) [Error]()
+
+```go
+func (e ErrInvalidQuery) Error() string
+```
+
+
+
+
+### func \(ErrInvalidQuery\) [Is]()
+
+```go
+func (e ErrInvalidQuery) Is(err error) bool
+```
+
+
+
+
+## type [ErrInvalidVars]()
+
+
+
+```go
+type ErrInvalidVars = machine.ErrInvalidVars
+```
+
+
+## type [ErrMetadataOverride]()
+
+ErrMetadataOverride is used when a metadata is defined at numscript level AND at the input level
+
+```go
+type ErrMetadataOverride struct {
+ // contains filtered or unexported fields
+}
+```
+
+
+### func \(\*ErrMetadataOverride\) [Error]()
+
+```go
+func (e *ErrMetadataOverride) Error() string
+```
+
+
+
+
+### func \(\*ErrMetadataOverride\) [Is]()
+
+```go
+func (e *ErrMetadataOverride) Is(err error) bool
+```
+
+
+
+
+## type [ErrMissingFeature]()
+
+
+
+```go
+type ErrMissingFeature struct {
+ // contains filtered or unexported fields
+}
+```
+
+
+### func [NewErrMissingFeature]()
+
+```go
+func NewErrMissingFeature(feature string) ErrMissingFeature
+```
+
+
+
+
+### func \(ErrMissingFeature\) [Error]()
+
+```go
+func (e ErrMissingFeature) Error() string
+```
+
+
+
+
+### func \(ErrMissingFeature\) [Is]()
+
+```go
+func (e ErrMissingFeature) Is(err error) bool
+```
+
+
+
+
+## type [ErrTransactionReferenceConflict]()
+
+
+
+```go
+type ErrTransactionReferenceConflict struct {
+ // contains filtered or unexported fields
+}
+```
+
+
+### func [NewErrTransactionReferenceConflict]()
+
+```go
+func NewErrTransactionReferenceConflict(reference string) ErrTransactionReferenceConflict
+```
+
+
+
+
+### func \(ErrTransactionReferenceConflict\) [Error]()
+
+```go
+func (e ErrTransactionReferenceConflict) Error() string
+```
+
+
+
+
+### func \(ErrTransactionReferenceConflict\) [Is]()
+
+```go
+func (e ErrTransactionReferenceConflict) Is(err error) bool
+```
+
+
+
+
+## type [ExportWriter]()
+
+
+
+```go
+type ExportWriter interface {
+ Write(ctx context.Context, log ledger.Log) error
+}
+```
+
+
+## type [ExportWriterFn]()
+
+
+
+```go
+type ExportWriterFn func(ctx context.Context, log ledger.Log) error
+```
+
+
+### func \(ExportWriterFn\) [Write]()
+
+```go
+func (fn ExportWriterFn) Write(ctx context.Context, log ledger.Log) error
+```
+
+
+
+
+## type [FiltersForVolumes]()
+
+
+
+```go
+type FiltersForVolumes struct {
+ PITFilter
+ UseInsertionDate bool
+ GroupLvl int
+}
+```
+
+
+## type [GetAccountQuery]()
+
+
+
+```go
+type GetAccountQuery struct {
+ PITFilterWithVolumes
+ Addr string
+}
+```
+
+
+### func [NewGetAccountQuery]()
+
+```go
+func NewGetAccountQuery(addr string) GetAccountQuery
+```
+
+
+
+
+### func \(GetAccountQuery\) [WithExpandEffectiveVolumes]()
+
+```go
+func (q GetAccountQuery) WithExpandEffectiveVolumes() GetAccountQuery
+```
+
+
+
+
+### func \(GetAccountQuery\) [WithExpandVolumes]()
+
+```go
+func (q GetAccountQuery) WithExpandVolumes() GetAccountQuery
+```
+
+
+
+
+### func \(GetAccountQuery\) [WithPIT]()
+
+```go
+func (q GetAccountQuery) WithPIT(pit time.Time) GetAccountQuery
+```
+
+
+
+
+## type [GetAggregatedBalanceQuery]()
+
+
+
+```go
+type GetAggregatedBalanceQuery struct {
+ PITFilter
+ QueryBuilder query.Builder
+ UseInsertionDate bool
+}
+```
+
+
+### func [NewGetAggregatedBalancesQuery]()
+
+```go
+func NewGetAggregatedBalancesQuery(filter PITFilter, qb query.Builder, useInsertionDate bool) GetAggregatedBalanceQuery
+```
+
+
+
+
+## type [GetLogsQuery]()
+
+
+
+```go
+type GetLogsQuery bunpaginate.ColumnPaginatedQuery[PaginatedQueryOptions[any]]
+```
+
+
+### func [NewListLogsQuery]()
+
+```go
+func NewListLogsQuery(options PaginatedQueryOptions[any]) GetLogsQuery
+```
+
+
+
+
+### func \(GetLogsQuery\) [WithOrder]()
+
+```go
+func (q GetLogsQuery) WithOrder(order bunpaginate.Order) GetLogsQuery
+```
+
+
+
+
+## type [GetTransactionQuery]()
+
+
+
+```go
+type GetTransactionQuery struct {
+ PITFilterWithVolumes
+ ID int
+}
+```
+
+
+### func [NewGetTransactionQuery]()
+
+```go
+func NewGetTransactionQuery(id int) GetTransactionQuery
+```
+
+
+
+
+### func \(GetTransactionQuery\) [WithExpandEffectiveVolumes]()
+
+```go
+func (q GetTransactionQuery) WithExpandEffectiveVolumes() GetTransactionQuery
+```
+
+
+
+
+### func \(GetTransactionQuery\) [WithExpandVolumes]()
+
+```go
+func (q GetTransactionQuery) WithExpandVolumes() GetTransactionQuery
+```
+
+
+
+
+## type [GetVolumesWithBalancesQuery]()
+
+
+
+```go
+type GetVolumesWithBalancesQuery bunpaginate.OffsetPaginatedQuery[PaginatedQueryOptions[FiltersForVolumes]]
+```
+
+
+### func [NewGetVolumesWithBalancesQuery]()
+
+```go
+func NewGetVolumesWithBalancesQuery(opts PaginatedQueryOptions[FiltersForVolumes]) GetVolumesWithBalancesQuery
+```
+
+
+
+
+## type [ListAccountsQuery]()
+
+
+
+```go
+type ListAccountsQuery bunpaginate.OffsetPaginatedQuery[PaginatedQueryOptions[PITFilterWithVolumes]]
+```
+
+
+### func [NewListAccountsQuery]()
+
+```go
+func NewListAccountsQuery(opts PaginatedQueryOptions[PITFilterWithVolumes]) ListAccountsQuery
+```
+
+
+
+
+### func \(ListAccountsQuery\) [WithExpandEffectiveVolumes]()
+
+```go
+func (q ListAccountsQuery) WithExpandEffectiveVolumes() ListAccountsQuery
+```
+
+
+
+
+### func \(ListAccountsQuery\) [WithExpandVolumes]()
+
+```go
+func (q ListAccountsQuery) WithExpandVolumes() ListAccountsQuery
+```
+
+
+
+
+## type [ListLedgersQuery]()
+
+
+
+```go
+type ListLedgersQuery bunpaginate.OffsetPaginatedQuery[PaginatedQueryOptions[struct{}]]
+```
+
+
+### func [NewListLedgersQuery]()
+
+```go
+func NewListLedgersQuery(pageSize uint64) ListLedgersQuery
+```
+
+
+
+
+## type [ListTransactionsQuery]()
+
+
+
+```go
+type ListTransactionsQuery bunpaginate.ColumnPaginatedQuery[PaginatedQueryOptions[PITFilterWithVolumes]]
+```
+
+
+### func [NewListTransactionsQuery]()
+
+```go
+func NewListTransactionsQuery(options PaginatedQueryOptions[PITFilterWithVolumes]) ListTransactionsQuery
+```
+
+
+
+
+### func \(ListTransactionsQuery\) [WithColumn]()
+
+```go
+func (q ListTransactionsQuery) WithColumn(column string) ListTransactionsQuery
+```
+
+
+
+
+## type [Listener]()
+
+
+
+```go
+type Listener interface {
+ CommittedTransactions(ctx context.Context, ledger string, res ledger.Transaction, accountMetadata ledger.AccountMetadata)
+ SavedMetadata(ctx context.Context, ledger string, targetType, id string, metadata metadata.Metadata)
+ RevertedTransaction(ctx context.Context, ledger string, reverted, revert ledger.Transaction)
+ DeletedMetadata(ctx context.Context, ledger string, targetType string, targetID any, key string)
+}
+```
+
+
+## type [Machine]()
+
+
+
+```go
+type Machine interface {
+ Execute(context.Context, vm.Store, map[string]string) (*MachineResult, error)
+}
+```
+
+
+## type [MachineFactory]()
+
+
+
+```go
+type MachineFactory interface {
+ // Make can return following errors:
+ // * ErrCompilationFailed
+ Make(script string) (Machine, error)
+}
+```
+
+
+## type [MachineResult]()
+
+
+
+```go
+type MachineResult struct {
+ Postings ledger.Postings `json:"postings"`
+ Metadata metadata.Metadata `json:"metadata"`
+ AccountMetadata map[string]metadata.Metadata
+}
+```
+
+
+## type [PITFilter]()
+
+
+
+```go
+type PITFilter struct {
+ PIT *time.Time `json:"pit"`
+ OOT *time.Time `json:"oot"`
+}
+```
+
+
+## type [PITFilterWithVolumes]()
+
+
+
+```go
+type PITFilterWithVolumes struct {
+ PITFilter
+ ExpandVolumes bool `json:"volumes"`
+ ExpandEffectiveVolumes bool `json:"effectiveVolumes"`
+}
+```
+
+
+## type [PaginatedQueryOptions]()
+
+
+
+```go
+type PaginatedQueryOptions[T any] struct {
+ QueryBuilder query.Builder `json:"qb"`
+ PageSize uint64 `json:"pageSize"`
+ Options T `json:"options"`
+}
+```
+
+
+### func [NewPaginatedQueryOptions]()
+
+```go
+func NewPaginatedQueryOptions[T any](options T) PaginatedQueryOptions[T]
+```
+
+
+
+
+### func \(\*PaginatedQueryOptions\[T\]\) [UnmarshalJSON]()
+
+```go
+func (opts *PaginatedQueryOptions[T]) UnmarshalJSON(data []byte) error
+```
+
+
+
+
+### func \(PaginatedQueryOptions\[T\]\) [WithPageSize]()
+
+```go
+func (opts PaginatedQueryOptions[T]) WithPageSize(pageSize uint64) PaginatedQueryOptions[T]
+```
+
+
+
+
+### func \(PaginatedQueryOptions\[T\]\) [WithQueryBuilder]()
+
+```go
+func (opts PaginatedQueryOptions[T]) WithQueryBuilder(qb query.Builder) PaginatedQueryOptions[T]
+```
+
+
+
+
+## type [Parameters]()
+
+
+
+```go
+type Parameters[INPUT any] struct {
+ DryRun bool
+ IdempotencyKey string
+ Input INPUT
+}
+```
+
+
+## type [RevertTransaction]()
+
+
+
+```go
+type RevertTransaction struct {
+ Force bool
+ AtEffectiveDate bool
+ TransactionID int
+}
+```
+
+
+## type [RunScript]()
+
+
+
+```go
+type RunScript = vm.RunScript
+```
+
+
+## type [SaveAccountMetadata]()
+
+
+
+```go
+type SaveAccountMetadata struct {
+ Address string
+ Metadata metadata.Metadata
+}
+```
+
+
+## type [SaveTransactionMetadata]()
+
+
+
+```go
+type SaveTransactionMetadata struct {
+ TransactionID int
+ Metadata metadata.Metadata
+}
+```
+
+
+## type [Script]()
+
+
+
+```go
+type Script = vm.Script
+```
+
+
+## type [ScriptV1]()
+
+
+
+```go
+type ScriptV1 = vm.ScriptV1
+```
+
+
+## type [State]()
+
+
+
+```go
+type State struct {
+ // contains filtered or unexported fields
+}
+```
+
+
+## type [StateRegistry]()
+
+
+
+```go
+type StateRegistry struct {
+ // contains filtered or unexported fields
+}
+```
+
+
+### func [NewStateRegistry]()
+
+```go
+func NewStateRegistry() *StateRegistry
+```
+
+
+
+
+### func \(\*StateRegistry\) [IsUpToDate]()
+
+```go
+func (r *StateRegistry) IsUpToDate(name string) bool
+```
+
+
+
+
+### func \(\*StateRegistry\) [SetUpToDate]()
+
+```go
+func (r *StateRegistry) SetUpToDate(name string)
+```
+
+
+
+
+### func \(\*StateRegistry\) [Upsert]()
+
+```go
+func (r *StateRegistry) Upsert(l ledger.Ledger) bool
+```
+
+
+
+
+## type [Stats]()
+
+
+
+```go
+type Stats struct {
+ Transactions int `json:"transactions"`
+ Accounts int `json:"accounts"`
+}
+```
+
+
+## type [Store]()
+
+
+
+```go
+type Store interface {
+ WithTX(context.Context, *sql.TxOptions, func(TX) (bool, error)) error
+ GetDB() bun.IDB
+ ListLogs(ctx context.Context, q GetLogsQuery) (*bunpaginate.Cursor[ledger.Log], error)
+ ReadLogWithIdempotencyKey(ctx context.Context, ik string) (*ledger.Log, error)
+
+ ListTransactions(ctx context.Context, q ListTransactionsQuery) (*bunpaginate.Cursor[ledger.Transaction], error)
+ CountTransactions(ctx context.Context, q ListTransactionsQuery) (int, error)
+ GetTransaction(ctx context.Context, query GetTransactionQuery) (*ledger.Transaction, error)
+ CountAccounts(ctx context.Context, a ListAccountsQuery) (int, error)
+ ListAccounts(ctx context.Context, a ListAccountsQuery) (*bunpaginate.Cursor[ledger.Account], error)
+ GetAccount(ctx context.Context, q GetAccountQuery) (*ledger.Account, error)
+ GetAggregatedBalances(ctx context.Context, q GetAggregatedBalanceQuery) (ledger.BalancesByAssets, error)
+ GetVolumesWithBalances(ctx context.Context, q GetVolumesWithBalancesQuery) (*bunpaginate.Cursor[ledger.VolumesWithBalanceByAssetByAccount], error)
+ IsUpToDate(ctx context.Context) (bool, error)
+ GetMigrationsInfo(ctx context.Context) ([]migrations.Info, error)
+}
+```
+
+
+## type [TX]()
+
+
+
+```go
+type TX interface {
+ GetAccount(ctx context.Context, query GetAccountQuery) (*ledger.Account, error)
+ // GetBalances must returns balance and lock account until the end of the TX
+ GetBalances(ctx context.Context, query BalanceQuery) (Balances, error)
+ CommitTransaction(ctx context.Context, transaction *ledger.Transaction) error
+ // RevertTransaction revert the transaction with identifier id
+ // It returns :
+ // * the reverted transaction
+ // * a boolean indicating if the transaction has been reverted. false indicates an already reverted transaction (unless error != nil)
+ // * an error
+ RevertTransaction(ctx context.Context, id int) (*ledger.Transaction, bool, error)
+ UpdateTransactionMetadata(ctx context.Context, transactionID int, m metadata.Metadata) (*ledger.Transaction, bool, error)
+ DeleteTransactionMetadata(ctx context.Context, transactionID int, key string) (*ledger.Transaction, bool, error)
+ UpdateAccountsMetadata(ctx context.Context, m map[string]metadata.Metadata) error
+ // UpsertAccount returns a boolean indicating if the account was upserted
+ UpsertAccount(ctx context.Context, account *ledger.Account) (bool, error)
+ DeleteAccountMetadata(ctx context.Context, address, key string) error
+ InsertLog(ctx context.Context, log *ledger.Log) error
+
+ LockLedger(ctx context.Context) error
+ ListLogs(ctx context.Context, q GetLogsQuery) (*bunpaginate.Cursor[ledger.Log], error)
+}
+```
+
+Generated by [gomarkdoc]()
diff --git a/internal/controller/ledger/compiler.go b/internal/controller/ledger/compiler.go
index e7017ba38..cb63d1e09 100644
--- a/internal/controller/ledger/compiler.go
+++ b/internal/controller/ledger/compiler.go
@@ -9,7 +9,7 @@ import (
"github.com/formancehq/ledger/internal/machine/vm/program"
)
-//go:generate mockgen -source compiler.go -destination compiler_generated.go -package ledger . Compiler
+//go:generate mockgen -write_source_comment=false -write_package_comment=false -source compiler.go -destination compiler_generated_test.go -package ledger . Compiler
// Compiler can return following errors:
// - ErrCompilationFailed
diff --git a/internal/controller/ledger/compiler_generated.go b/internal/controller/ledger/compiler_generated_test.go
similarity index 89%
rename from internal/controller/ledger/compiler_generated.go
rename to internal/controller/ledger/compiler_generated_test.go
index 51e80ae55..a6632141e 100644
--- a/internal/controller/ledger/compiler_generated.go
+++ b/internal/controller/ledger/compiler_generated_test.go
@@ -1,12 +1,8 @@
// Code generated by MockGen. DO NOT EDIT.
-// Source: compiler.go
//
// Generated by this command:
//
-// mockgen -source compiler.go -destination compiler_generated.go -package ledger . Compiler
-//
-
-// Package ledger is a generated GoMock package.
+// mockgen -write_source_comment=false -write_package_comment=false -source compiler.go -destination compiler_generated_test.go -package ledger . Compiler
package ledger
import (
diff --git a/internal/controller/ledger/controller.go b/internal/controller/ledger/controller.go
index fa9c01394..8a47fe1dc 100644
--- a/internal/controller/ledger/controller.go
+++ b/internal/controller/ledger/controller.go
@@ -10,7 +10,7 @@ import (
ledger "github.com/formancehq/ledger/internal"
)
-//go:generate mockgen -source controller.go -destination controller_generated.go -package ledger . Controller
+//go:generate mockgen -write_source_comment=false -write_package_comment=false -source controller.go -destination controller_generated_test.go -package ledger . Controller
type Controller interface {
// IsDatabaseUpToDate check if the ledger store is up to date, including the bucket and the ledger specifics
diff --git a/internal/controller/ledger/controller_generated.go b/internal/controller/ledger/controller_generated_test.go
similarity index 98%
rename from internal/controller/ledger/controller_generated.go
rename to internal/controller/ledger/controller_generated_test.go
index 2d65fe40e..ac1887402 100644
--- a/internal/controller/ledger/controller_generated.go
+++ b/internal/controller/ledger/controller_generated_test.go
@@ -1,12 +1,8 @@
// Code generated by MockGen. DO NOT EDIT.
-// Source: controller.go
//
// Generated by this command:
//
-// mockgen -source controller.go -destination controller_generated.go -package ledger . Controller
-//
-
-// Package ledger is a generated GoMock package.
+// mockgen -write_source_comment=false -write_package_comment=false -source controller.go -destination controller_generated_test.go -package ledger . Controller
package ledger
import (
diff --git a/internal/controller/ledger/doc.go b/internal/controller/ledger/doc.go
new file mode 100644
index 000000000..9d3de4247
--- /dev/null
+++ b/internal/controller/ledger/doc.go
@@ -0,0 +1,3 @@
+// Controller doc
+//go:generate gomarkdoc --output README.md .
+package ledger
diff --git a/internal/controller/ledger/listener.go b/internal/controller/ledger/listener.go
index baf94d9be..486c55c3f 100644
--- a/internal/controller/ledger/listener.go
+++ b/internal/controller/ledger/listener.go
@@ -7,7 +7,7 @@ import (
ledger "github.com/formancehq/ledger/internal"
)
-//go:generate mockgen -source listener.go -destination listener_generated.go -package ledger . Listener
+//go:generate mockgen -write_source_comment=false -write_package_comment=false -source listener.go -destination listener_generated_test.go -package ledger . Listener
type Listener interface {
CommittedTransactions(ctx context.Context, ledger string, res ledger.Transaction, accountMetadata ledger.AccountMetadata)
SavedMetadata(ctx context.Context, ledger string, targetType, id string, metadata metadata.Metadata)
diff --git a/internal/controller/ledger/listener_generated.go b/internal/controller/ledger/listener_generated_test.go
similarity index 95%
rename from internal/controller/ledger/listener_generated.go
rename to internal/controller/ledger/listener_generated_test.go
index 6fe3a016c..9f90ebe5f 100644
--- a/internal/controller/ledger/listener_generated.go
+++ b/internal/controller/ledger/listener_generated_test.go
@@ -1,12 +1,8 @@
// Code generated by MockGen. DO NOT EDIT.
-// Source: listener.go
//
// Generated by this command:
//
-// mockgen -source listener.go -destination listener_generated.go -package ledger . Listener
-//
-
-// Package ledger is a generated GoMock package.
+// mockgen -write_source_comment=false -write_package_comment=false -source listener.go -destination listener_generated_test.go -package ledger . Listener
package ledger
import (
diff --git a/internal/controller/ledger/machine.go b/internal/controller/ledger/machine.go
index 2ab94daa1..163e3ff9d 100644
--- a/internal/controller/ledger/machine.go
+++ b/internal/controller/ledger/machine.go
@@ -20,7 +20,7 @@ type MachineResult struct {
AccountMetadata map[string]metadata.Metadata
}
-//go:generate mockgen -source machine.go -destination machine_generated.go -package ledger . Machine
+//go:generate mockgen -write_source_comment=false -write_package_comment=false -source machine.go -destination machine_generated_test.go -package ledger . Machine
type Machine interface {
Execute(context.Context, vm.Store, map[string]string) (*MachineResult, error)
}
diff --git a/internal/controller/ledger/machine_factory.go b/internal/controller/ledger/machine_factory.go
index ce62fe90c..cc2729016 100644
--- a/internal/controller/ledger/machine_factory.go
+++ b/internal/controller/ledger/machine_factory.go
@@ -1,6 +1,6 @@
package ledger
-//go:generate mockgen -source machine_factory.go -destination machine_factory_generated.go -package ledger . MachineFactory
+//go:generate mockgen -write_source_comment=false -write_package_comment=false -source machine_factory.go -destination machine_factory_generated_test.go -package ledger . MachineFactory
type MachineFactory interface {
// Make can return following errors:
diff --git a/internal/controller/ledger/machine_factory_generated.go b/internal/controller/ledger/machine_factory_generated_test.go
similarity index 87%
rename from internal/controller/ledger/machine_factory_generated.go
rename to internal/controller/ledger/machine_factory_generated_test.go
index 5e305e6c9..e08fd528e 100644
--- a/internal/controller/ledger/machine_factory_generated.go
+++ b/internal/controller/ledger/machine_factory_generated_test.go
@@ -1,12 +1,8 @@
// Code generated by MockGen. DO NOT EDIT.
-// Source: machine_factory.go
//
// Generated by this command:
//
-// mockgen -source machine_factory.go -destination machine_factory_generated.go -package ledger . MachineFactory
-//
-
-// Package ledger is a generated GoMock package.
+// mockgen -write_source_comment=false -write_package_comment=false -source machine_factory.go -destination machine_factory_generated_test.go -package ledger . MachineFactory
package ledger
import (
diff --git a/internal/controller/ledger/machine_generated.go b/internal/controller/ledger/machine_generated_test.go
similarity index 89%
rename from internal/controller/ledger/machine_generated.go
rename to internal/controller/ledger/machine_generated_test.go
index 13985c051..f7fcee03f 100644
--- a/internal/controller/ledger/machine_generated.go
+++ b/internal/controller/ledger/machine_generated_test.go
@@ -1,12 +1,8 @@
// Code generated by MockGen. DO NOT EDIT.
-// Source: machine.go
//
// Generated by this command:
//
-// mockgen -source machine.go -destination machine_generated.go -package ledger . Machine
-//
-
-// Package ledger is a generated GoMock package.
+// mockgen -write_source_comment=false -write_package_comment=false -source machine.go -destination machine_generated_test.go -package ledger . Machine
package ledger
import (
diff --git a/internal/controller/ledger/store.go b/internal/controller/ledger/store.go
index a862e83a2..6cc53cb29 100644
--- a/internal/controller/ledger/store.go
+++ b/internal/controller/ledger/store.go
@@ -26,7 +26,7 @@ type Balance struct {
type BalanceQuery = vm.BalanceQuery
type Balances = vm.Balances
-//go:generate mockgen -source store.go -destination store_generated.go -package ledger . TX
+//go:generate mockgen -write_source_comment=false -write_package_comment=false -source store.go -destination store_generated_test.go -package ledger . TX
type TX interface {
GetAccount(ctx context.Context, query GetAccountQuery) (*ledger.Account, error)
// GetBalances must returns balance and lock account until the end of the TX
diff --git a/internal/controller/ledger/store_generated.go b/internal/controller/ledger/store_generated_test.go
similarity index 99%
rename from internal/controller/ledger/store_generated.go
rename to internal/controller/ledger/store_generated_test.go
index f69d92883..b2cbd0c18 100644
--- a/internal/controller/ledger/store_generated.go
+++ b/internal/controller/ledger/store_generated_test.go
@@ -1,12 +1,8 @@
// Code generated by MockGen. DO NOT EDIT.
-// Source: store.go
//
// Generated by this command:
//
-// mockgen -source store.go -destination store_generated.go -package ledger . TX
-//
-
-// Package ledger is a generated GoMock package.
+// mockgen -write_source_comment=false -write_package_comment=false -source store.go -destination store_generated_test.go -package ledger . TX
package ledger
import (
diff --git a/internal/controller/system/controller.go b/internal/controller/system/controller.go
index 543d44e6b..ef11366f9 100644
--- a/internal/controller/system/controller.go
+++ b/internal/controller/system/controller.go
@@ -10,8 +10,6 @@ import (
ledgercontroller "github.com/formancehq/ledger/internal/controller/ledger"
)
-//go:generate mockgen -source controller.go -destination controller_generated.go -package system . Controller
-
type Controller interface {
GetLedgerController(ctx context.Context, name string) (ledgercontroller.Controller, error)
GetLedger(ctx context.Context, name string) (*ledger.Ledger, error)