Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions docs/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,12 @@ Idempotency-Key: string

<h3 id="add-metadata-to-an-account-responseschema">Response Schema</h3>

### Response Headers

|Status|Header|Type|Format|Description|
|---|---|---|---|---|
|204|Idempotency-Hit|string||Indicates that the request was processed using an idempotency key that was already used|

<aside class="warning">
To perform this operation, you must be authenticated by means of one of the following methods:
Authorization ( Scopes: ledger:write )
Expand Down Expand Up @@ -1025,6 +1031,12 @@ Delete metadata by key

<h3 id="delete-metadata-by-key-responseschema">Response Schema</h3>

### Response Headers

|Status|Header|Type|Format|Description|
|---|---|---|---|---|
|204|Idempotency-Hit|string||Indicates that the request was processed using an idempotency key that was already used|

<aside class="warning">
To perform this operation, you must be authenticated by means of one of the following methods:
Authorization ( Scopes: ledger:write )
Expand Down Expand Up @@ -1476,6 +1488,12 @@ Idempotency-Key: string
|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|OK|[V2CreateTransactionResponse](#schemav2createtransactionresponse)|
|default|Default|Error|[V2ErrorResponse](#schemav2errorresponse)|

### Response Headers

|Status|Header|Type|Format|Description|
|---|---|---|---|---|
|200|Idempotency-Hit|string||Indicates that the request was processed using an idempotency key that was already used|

<aside class="warning">
To perform this operation, you must be authenticated by means of one of the following methods:
Authorization ( Scopes: ledger:write )
Expand Down Expand Up @@ -1666,6 +1684,12 @@ Idempotency-Key: string

<h3 id="set-the-metadata-of-a-transaction-by-its-id-responseschema">Response Schema</h3>

### Response Headers

|Status|Header|Type|Format|Description|
|---|---|---|---|---|
|204|Idempotency-Hit|string||Indicates that the request was processed using an idempotency key that was already used|

<aside class="warning">
To perform this operation, you must be authenticated by means of one of the following methods:
Authorization ( Scopes: ledger:write )
Expand All @@ -1682,6 +1706,7 @@ POST http://localhost:8080/v2/{ledger}/transactions/{id}/revert HTTP/1.1
Host: localhost:8080
Content-Type: application/json
Accept: application/json
Idempotency-Key: string

```

Expand All @@ -1707,6 +1732,7 @@ Accept: application/json
|force|query|boolean|false|Force revert|
|atEffectiveDate|query|boolean|false|Revert transaction at effective date of the original tx|
|dryRun|query|boolean|false|Set the dryRun mode. dry run mode doesn't add the logs to the database or publish a message to the message broker.|
|Idempotency-Key|header|string|false|Use an idempotency key|
|body|body|[V2RevertTransactionRequest](#schemav2reverttransactionrequest)|false|none|

> Example responses
Expand Down Expand Up @@ -1809,6 +1835,12 @@ Accept: application/json
|201|[Created](https://tools.ietf.org/html/rfc7231#section-6.3.2)|OK|[V2CreateTransactionResponse](#schemav2createtransactionresponse)|
|default|Default|Error|[V2ErrorResponse](#schemav2errorresponse)|

### Response Headers

|Status|Header|Type|Format|Description|
|---|---|---|---|---|
|201|Idempotency-Hit|string||Indicates that the request was processed using an idempotency key that was already used|

<aside class="warning">
To perform this operation, you must be authenticated by means of one of the following methods:
Authorization ( Scopes: ledger:write )
Expand Down
2 changes: 1 addition & 1 deletion internal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ type Log struct {
Date time.Time `json:"date" bun:"date,type:timestamptz,nullzero"`
IdempotencyKey string `json:"idempotencyKey" bun:"idempotency_key,type:varchar(256),unique,nullzero"`
// IdempotencyHash is a signature used when using IdempotencyKey.
// It allows to check if the usage of IdempotencyKey match inputs given on the first idempotency key usage.
// It allows checking if the usage of IdempotencyKey matches inputs given on the first idempotency key usage.
IdempotencyHash string `json:"idempotencyHash" bun:"idempotency_hash,unique,nullzero"`
ID *uint64 `json:"id" bun:"id,unique,type:numeric"`
Hash []byte `json:"hash" bun:"hash,type:bytea"`
Expand Down
12 changes: 6 additions & 6 deletions internal/api/bulking/bulker.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func (b *Bulker) processElement(ctx context.Context, ctrl ledgercontroller.Contr
return nil, 0, fmt.Errorf("error parsing element: %s", err)
}

log, createTransactionResult, err := ctrl.CreateTransaction(ctx, ledgercontroller.Parameters[ledgercontroller.CreateTransaction]{
log, createTransactionResult, _, err := ctrl.CreateTransaction(ctx, ledgercontroller.Parameters[ledgercontroller.CreateTransaction]{
DryRun: false,
IdempotencyKey: data.IdempotencyKey,
Input: *rs,
Expand All @@ -164,7 +164,7 @@ func (b *Bulker) processElement(ctx context.Context, ctrl ledgercontroller.Contr
if err := json.Unmarshal(req.TargetID, &address); err != nil {
return nil, 0, err
}
log, err = ctrl.SaveAccountMetadata(ctx, ledgercontroller.Parameters[ledgercontroller.SaveAccountMetadata]{
log, _, err = ctrl.SaveAccountMetadata(ctx, ledgercontroller.Parameters[ledgercontroller.SaveAccountMetadata]{
DryRun: false,
IdempotencyKey: data.IdempotencyKey,
Input: ledgercontroller.SaveAccountMetadata{
Expand All @@ -177,7 +177,7 @@ func (b *Bulker) processElement(ctx context.Context, ctrl ledgercontroller.Contr
if err := json.Unmarshal(req.TargetID, &transactionID); err != nil {
return nil, 0, err
}
log, err = ctrl.SaveTransactionMetadata(ctx, ledgercontroller.Parameters[ledgercontroller.SaveTransactionMetadata]{
log, _, err = ctrl.SaveTransactionMetadata(ctx, ledgercontroller.Parameters[ledgercontroller.SaveTransactionMetadata]{
DryRun: false,
IdempotencyKey: data.IdempotencyKey,
Input: ledgercontroller.SaveTransactionMetadata{
Expand All @@ -196,7 +196,7 @@ func (b *Bulker) processElement(ctx context.Context, ctrl ledgercontroller.Contr
case ActionRevertTransaction:
req := data.Data.(RevertTransactionRequest)

log, revertTransactionResult, err := ctrl.RevertTransaction(ctx, ledgercontroller.Parameters[ledgercontroller.RevertTransaction]{
log, revertTransactionResult, _, err := ctrl.RevertTransaction(ctx, ledgercontroller.Parameters[ledgercontroller.RevertTransaction]{
DryRun: false,
IdempotencyKey: data.IdempotencyKey,
Input: ledgercontroller.RevertTransaction{
Expand Down Expand Up @@ -225,7 +225,7 @@ func (b *Bulker) processElement(ctx context.Context, ctrl ledgercontroller.Contr
return nil, 0, err
}

log, err = ctrl.DeleteAccountMetadata(ctx, ledgercontroller.Parameters[ledgercontroller.DeleteAccountMetadata]{
log, _, err = ctrl.DeleteAccountMetadata(ctx, ledgercontroller.Parameters[ledgercontroller.DeleteAccountMetadata]{
DryRun: false,
IdempotencyKey: data.IdempotencyKey,
Input: ledgercontroller.DeleteAccountMetadata{
Expand All @@ -239,7 +239,7 @@ func (b *Bulker) processElement(ctx context.Context, ctrl ledgercontroller.Contr
return nil, 0, err
}

log, err = ctrl.DeleteTransactionMetadata(ctx, ledgercontroller.Parameters[ledgercontroller.DeleteTransactionMetadata]{
log, _, err = ctrl.DeleteTransactionMetadata(ctx, ledgercontroller.Parameters[ledgercontroller.DeleteTransactionMetadata]{
DryRun: false,
IdempotencyKey: data.IdempotencyKey,
Input: ledgercontroller.DeleteTransactionMetadata{
Expand Down
26 changes: 13 additions & 13 deletions internal/api/bulking/bulker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func TestBulk(t *testing.T) {
Timestamp: now,
},
},
}, nil)
}, false, nil)
},
expectResults: []BulkElementResult{{
Data: ledger.Transaction{
Expand Down Expand Up @@ -112,7 +112,7 @@ func TestBulk(t *testing.T) {
}).
Return(&ledger.Log{
ID: pointer.For(uint64(1)),
}, nil)
}, false, nil)
},
expectResults: []BulkElementResult{{}},
},
Expand Down Expand Up @@ -140,7 +140,7 @@ func TestBulk(t *testing.T) {
}).
Return(&ledger.Log{
ID: pointer.For(uint64(1)),
}, nil)
}, false, nil)
},
expectResults: []BulkElementResult{{}},
},
Expand All @@ -161,7 +161,7 @@ func TestBulk(t *testing.T) {
}).
Return(&ledger.Log{
ID: pointer.For(uint64(1)),
}, &ledger.RevertedTransaction{}, nil)
}, &ledger.RevertedTransaction{}, false, nil)
},
expectResults: []BulkElementResult{{
Data: ledger.Transaction{},
Expand All @@ -187,7 +187,7 @@ func TestBulk(t *testing.T) {
}).
Return(&ledger.Log{
ID: pointer.For(uint64(1)),
}, nil)
}, false, nil)
},
expectResults: []BulkElementResult{{}},
},
Expand All @@ -211,7 +211,7 @@ func TestBulk(t *testing.T) {
}).
Return(&ledger.Log{
ID: pointer.For(uint64(1)),
}, nil)
}, false, nil)
},
expectResults: []BulkElementResult{{}},
},
Expand Down Expand Up @@ -257,7 +257,7 @@ func TestBulk(t *testing.T) {
}).
Return(&ledger.Log{
ID: pointer.For(uint64(1)),
}, nil)
}, false, nil)
mockLedger.EXPECT().
SaveAccountMetadata(gomock.Any(), ledgercontroller.Parameters[ledgercontroller.SaveAccountMetadata]{
Input: ledgercontroller.SaveAccountMetadata{
Expand All @@ -267,7 +267,7 @@ func TestBulk(t *testing.T) {
},
},
}).
Return(nil, errors.New("unexpected error"))
Return(nil, false, errors.New("unexpected error"))
},
expectResults: []BulkElementResult{{}, {
Error: errors.New("unexpected error"),
Expand Down Expand Up @@ -319,7 +319,7 @@ func TestBulk(t *testing.T) {
}).
Return(&ledger.Log{
ID: pointer.For(uint64(1)),
}, nil)
}, false, nil)
mockLedger.EXPECT().
SaveAccountMetadata(gomock.Any(), ledgercontroller.Parameters[ledgercontroller.SaveAccountMetadata]{
Input: ledgercontroller.SaveAccountMetadata{
Expand All @@ -329,7 +329,7 @@ func TestBulk(t *testing.T) {
},
},
}).
Return(nil, errors.New("unexpected error"))
Return(nil, false, errors.New("unexpected error"))
mockLedger.EXPECT().
SaveAccountMetadata(gomock.Any(), ledgercontroller.Parameters[ledgercontroller.SaveAccountMetadata]{
Input: ledgercontroller.SaveAccountMetadata{
Expand All @@ -341,7 +341,7 @@ func TestBulk(t *testing.T) {
}).
Return(&ledger.Log{
ID: pointer.For(uint64(1)),
}, nil)
}, false, nil)
},
expectResults: []BulkElementResult{{}, {
Error: errors.New("unexpected error"),
Expand Down Expand Up @@ -388,7 +388,7 @@ func TestBulk(t *testing.T) {
}).
Return(&ledger.Log{
ID: pointer.For(uint64(1)),
}, nil)
}, false, nil)

mockLedger.EXPECT().
SaveAccountMetadata(gomock.Any(), ledgercontroller.Parameters[ledgercontroller.SaveAccountMetadata]{
Expand All @@ -401,7 +401,7 @@ func TestBulk(t *testing.T) {
}).
Return(&ledger.Log{
ID: pointer.For(uint64(1)),
}, nil)
}, false, nil)

mockLedger.EXPECT().
Commit(gomock.Any()).
Expand Down
2 changes: 1 addition & 1 deletion internal/api/bulking/mocks.go
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
//go:generate mockgen -write_source_comment=false -write_package_comment=false -source ../../controller/ledger/controller.go -destination mocks_ledger_controller_test.go -package bulking --mock_names Controller=LedgerController . Controller
//go:generate mockgen -write_source_comment=false -write_package_comment=false -source ../../controller/ledger/controller.go -destination mocks_ledger_controller_test.go -typed -package bulking --mock_names Controller=LedgerController . Controller
package bulking
Loading
Loading