Skip to content

Commit

Permalink
Merge branch 'main' of github.com:hyperledger/firefly into balances
Browse files Browse the repository at this point in the history
  • Loading branch information
awrichar committed Nov 4, 2021
2 parents 6f98c40 + 16dcab6 commit 3089b5f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
12 changes: 12 additions & 0 deletions internal/tokens/fftokens/fftokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ type createPool struct {
Type fftypes.TokenType `json:"type"`
RequestID string `json:"requestId"`
TrackingID string `json:"trackingId"`
Operator string `json:"operator"`
Config fftypes.JSONObject `json:"config"`
}

Expand All @@ -69,6 +70,8 @@ type mintTokens struct {
Amount string `json:"amount"`
RequestID string `json:"requestId,omitempty"`
TrackingID string `json:"trackingId"`
Operator string `json:"operator"`
Data string `json:"data,omitempty"`
}

type burnTokens struct {
Expand All @@ -78,6 +81,8 @@ type burnTokens struct {
Amount string `json:"amount"`
RequestID string `json:"requestId,omitempty"`
TrackingID string `json:"trackingId"`
Operator string `json:"operator"`
Data string `json:"data,omitempty"`
}

type transferTokens struct {
Expand All @@ -88,6 +93,7 @@ type transferTokens struct {
Amount string `json:"amount"`
RequestID string `json:"requestId,omitempty"`
TrackingID string `json:"trackingId"`
Operator string `json:"operator"`
Data string `json:"data,omitempty"`
}

Expand Down Expand Up @@ -329,6 +335,7 @@ func (ft *FFTokens) CreateTokenPool(ctx context.Context, operationID *fftypes.UU
Type: pool.Type,
RequestID: operationID.String(),
TrackingID: pool.TX.ID.String(),
Operator: pool.Key,
Config: pool.Config,
}).
Post("/api/v1/pool")
Expand All @@ -346,6 +353,8 @@ func (ft *FFTokens) MintTokens(ctx context.Context, operationID *fftypes.UUID, p
Amount: mint.Amount.Int().String(),
RequestID: operationID.String(),
TrackingID: mint.TX.ID.String(),
Operator: mint.Key,
Data: mint.MessageHash.String(),
}).
Post("/api/v1/mint")
if err != nil || !res.IsSuccess() {
Expand All @@ -363,6 +372,8 @@ func (ft *FFTokens) BurnTokens(ctx context.Context, operationID *fftypes.UUID, p
Amount: burn.Amount.Int().String(),
RequestID: operationID.String(),
TrackingID: burn.TX.ID.String(),
Operator: burn.Key,
Data: burn.MessageHash.String(),
}).
Post("/api/v1/burn")
if err != nil || !res.IsSuccess() {
Expand All @@ -381,6 +392,7 @@ func (ft *FFTokens) TransferTokens(ctx context.Context, operationID *fftypes.UUI
Amount: transfer.Amount.Int().String(),
RequestID: operationID.String(),
TrackingID: transfer.TX.ID.String(),
Operator: transfer.Key,
Data: transfer.MessageHash.String(),
}).
Post("/api/v1/transfer")
Expand Down
14 changes: 11 additions & 3 deletions internal/tokens/fftokens/fftokens_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ func TestCreateTokenPool(t *testing.T) {
Namespace: "ns1",
Name: "new-pool",
Type: "fungible",
Key: "0x123",
Config: fftypes.JSONObject{
"foo": "bar",
},
Expand All @@ -122,6 +123,7 @@ func TestCreateTokenPool(t *testing.T) {
assert.Equal(t, fftypes.JSONObject{
"requestId": opID.String(),
"trackingId": pool.TX.ID.String(),
"operator": "0x123",
"type": "fungible",
"config": map[string]interface{}{
"foo": "bar",
Expand Down Expand Up @@ -168,12 +170,13 @@ func TestMintTokens(t *testing.T) {
mint := &fftypes.TokenTransfer{
LocalID: fftypes.NewUUID(),
To: "user1",
Key: "0x123",
Amount: *fftypes.NewBigInt(10),
TX: fftypes.TransactionRef{
ID: fftypes.NewUUID(),
Type: fftypes.TransactionTypeTokenTransfer,
},
}
mint.Amount.Int().SetInt64(10)
opID := fftypes.NewUUID()

httpmock.RegisterResponder("POST", fmt.Sprintf("%s/api/v1/mint", httpURL),
Expand All @@ -185,6 +188,7 @@ func TestMintTokens(t *testing.T) {
"poolId": "123",
"to": "user1",
"amount": "10",
"operator": "0x123",
"requestId": opID.String(),
"trackingId": mint.TX.ID.String(),
}, body)
Expand Down Expand Up @@ -224,12 +228,13 @@ func TestBurnTokens(t *testing.T) {
LocalID: fftypes.NewUUID(),
TokenIndex: "1",
From: "user1",
Key: "0x123",
Amount: *fftypes.NewBigInt(10),
TX: fftypes.TransactionRef{
ID: fftypes.NewUUID(),
Type: fftypes.TransactionTypeTokenTransfer,
},
}
burn.Amount.Int().SetInt64(10)
opID := fftypes.NewUUID()

httpmock.RegisterResponder("POST", fmt.Sprintf("%s/api/v1/burn", httpURL),
Expand All @@ -242,6 +247,7 @@ func TestBurnTokens(t *testing.T) {
"tokenIndex": "1",
"from": "user1",
"amount": "10",
"operator": "0x123",
"requestId": opID.String(),
"trackingId": burn.TX.ID.String(),
}, body)
Expand Down Expand Up @@ -282,12 +288,13 @@ func TestTransferTokens(t *testing.T) {
TokenIndex: "1",
From: "user1",
To: "user2",
Key: "0x123",
Amount: *fftypes.NewBigInt(10),
TX: fftypes.TransactionRef{
ID: fftypes.NewUUID(),
Type: fftypes.TransactionTypeTokenTransfer,
},
}
transfer.Amount.Int().SetInt64(10)
opID := fftypes.NewUUID()

httpmock.RegisterResponder("POST", fmt.Sprintf("%s/api/v1/transfer", httpURL),
Expand All @@ -301,6 +308,7 @@ func TestTransferTokens(t *testing.T) {
"from": "user1",
"to": "user2",
"amount": "10",
"operator": "0x123",
"requestId": opID.String(),
"trackingId": transfer.TX.ID.String(),
}, body)
Expand Down
4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"tokens-erc1155": {
"image": "ghcr.io/hyperledger/firefly-tokens-erc1155",
"tag": "v0.9.0-20211026-1",
"sha": "3c39154af3d19a2a863add518c3be2b77765b6410e6483987ae571fd4c966189"
"tag": "v0.9.0-20211028-01",
"sha": "88d8f01e2c07dcdfd2706b51c7f591dba7072e72e168cec037549529355fdbbd"
}
}

0 comments on commit 3089b5f

Please sign in to comment.