Skip to content
Merged
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
1 change: 1 addition & 0 deletions docs/reference/types/tokentransfer.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ nav_order: 11
| `created` | The creation time of the transfer | [`FFTime`](simpletypes#fftime) |
| `tx` | If submitted via FireFly, this will reference the UUID of the FireFly transaction (if the token connector in use supports attaching data) | [`TransactionRef`](#transactionref) |
| `blockchainEvent` | The UUID of the blockchain event | [`UUID`](simpletypes#uuid) |
| `config` | Input only field, with token connector specific configuration of the transfer. See your chosen token connector documentation for details | [`JSONObject`](simpletypes#jsonobject) |

## TransactionRef

Expand Down
36 changes: 36 additions & 0 deletions docs/swagger/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10785,6 +10785,15 @@ paths:
For example, with 18 decimals a fractional balance of 10.234 will
be specified as 10,234,000,000,000,000,000
type: string
config:
additionalProperties:
description: Input only field, with token connector specific configuration
of the transfer. See your chosen token connector documentation
for details
description: Input only field, with token connector specific configuration
of the transfer. See your chosen token connector documentation
for details
type: object
from:
description: The source account for the transfer. On input defaults
to the value of 'key'
Expand Down Expand Up @@ -10937,6 +10946,9 @@ paths:
description: The index of the token within the pool that this transfer
applies to
type: string
uri:
description: The URI of the token this transfer applies to
type: string
type: object
responses:
"200":
Expand Down Expand Up @@ -11204,6 +11216,15 @@ paths:
For example, with 18 decimals a fractional balance of 10.234 will
be specified as 10,234,000,000,000,000,000
type: string
config:
additionalProperties:
description: Input only field, with token connector specific configuration
of the transfer. See your chosen token connector documentation
for details
description: Input only field, with token connector specific configuration
of the transfer. See your chosen token connector documentation
for details
type: object
key:
description: The blockchain signing key for the transfer. On input
defaults to the first signing key of the organization that operates
Expand Down Expand Up @@ -11356,6 +11377,9 @@ paths:
description: The index of the token within the pool that this transfer
applies to
type: string
uri:
description: The URI of the token this transfer applies to
type: string
type: object
responses:
"200":
Expand Down Expand Up @@ -12405,6 +12429,15 @@ paths:
For example, with 18 decimals a fractional balance of 10.234 will
be specified as 10,234,000,000,000,000,000
type: string
config:
additionalProperties:
description: Input only field, with token connector specific configuration
of the transfer. See your chosen token connector documentation
for details
description: Input only field, with token connector specific configuration
of the transfer. See your chosen token connector documentation
for details
type: object
from:
description: The source account for the transfer. On input defaults
to the value of 'key'
Expand Down Expand Up @@ -12561,6 +12594,9 @@ paths:
description: The index of the token within the pool that this transfer
applies to
type: string
uri:
description: The URI of the token this transfer applies to
type: string
type: object
responses:
"200":
Expand Down
1 change: 1 addition & 0 deletions internal/coremsgs/en_struct_descriptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@ var (
TokenTransferCreated = ffm("TokenTransfer.created", "The creation time of the transfer")
TokenTransferTX = ffm("TokenTransfer.tx", "If submitted via FireFly, this will reference the UUID of the FireFly transaction (if the token connector in use supports attaching data)")
TokenTransferBlockchainEvent = ffm("TokenTransfer.blockchainEvent", "The UUID of the blockchain event")
TokenTransferConfig = ffm("TokenTransfer.config", "Input only field, with token connector specific configuration of the transfer. See your chosen token connector documentation for details")

// TokenTransferInput field descriptions
TokenTransferInputMessage = ffm("TokenTransferInput.message", "You can specify a message to correlate with the transfer, which can be of type broadcast or private. Your chosen token connector and on-chain smart contract must support on-chain/off-chain correlation by taking a `data` input on the transfer")
Expand Down
52 changes: 30 additions & 22 deletions internal/tokens/fftokens/fftokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,34 +82,38 @@ type activatePool struct {
}

type mintTokens struct {
PoolLocator string `json:"poolLocator"`
TokenIndex string `json:"tokenIndex,omitempty"`
To string `json:"to"`
Amount string `json:"amount"`
RequestID string `json:"requestId,omitempty"`
Signer string `json:"signer"`
Data string `json:"data,omitempty"`
PoolLocator string `json:"poolLocator"`
TokenIndex string `json:"tokenIndex,omitempty"`
To string `json:"to"`
Amount string `json:"amount"`
RequestID string `json:"requestId,omitempty"`
Signer string `json:"signer"`
Data string `json:"data,omitempty"`
URI string `json:"uri,omitempty"`
Config fftypes.JSONObject `json:"config"`
}

type burnTokens struct {
PoolLocator string `json:"poolLocator"`
TokenIndex string `json:"tokenIndex,omitempty"`
From string `json:"from"`
Amount string `json:"amount"`
RequestID string `json:"requestId,omitempty"`
Signer string `json:"signer"`
Data string `json:"data,omitempty"`
PoolLocator string `json:"poolLocator"`
TokenIndex string `json:"tokenIndex,omitempty"`
From string `json:"from"`
Amount string `json:"amount"`
RequestID string `json:"requestId,omitempty"`
Signer string `json:"signer"`
Data string `json:"data,omitempty"`
Config fftypes.JSONObject `json:"config"`
}

type transferTokens struct {
PoolLocator string `json:"poolLocator"`
TokenIndex string `json:"tokenIndex,omitempty"`
From string `json:"from"`
To string `json:"to"`
Amount string `json:"amount"`
RequestID string `json:"requestId,omitempty"`
Signer string `json:"signer"`
Data string `json:"data,omitempty"`
PoolLocator string `json:"poolLocator"`
TokenIndex string `json:"tokenIndex,omitempty"`
From string `json:"from"`
To string `json:"to"`
Amount string `json:"amount"`
RequestID string `json:"requestId,omitempty"`
Signer string `json:"signer"`
Data string `json:"data,omitempty"`
Config fftypes.JSONObject `json:"config"`
}

type tokenApproval struct {
Expand Down Expand Up @@ -576,6 +580,8 @@ func (ft *FFTokens) MintTokens(ctx context.Context, opID *fftypes.UUID, poolLoca
RequestID: opID.String(),
Signer: mint.Key,
Data: string(data),
URI: mint.URI,
Config: mint.Config,
}).
SetError(&errRes).
Post("/api/v1/mint")
Expand All @@ -602,6 +608,7 @@ func (ft *FFTokens) BurnTokens(ctx context.Context, opID *fftypes.UUID, poolLoca
RequestID: opID.String(),
Signer: burn.Key,
Data: string(data),
Config: burn.Config,
}).
SetError(&errRes).
Post("/api/v1/burn")
Expand Down Expand Up @@ -629,6 +636,7 @@ func (ft *FFTokens) TransferTokens(ctx context.Context, opID *fftypes.UUID, pool
RequestID: opID.String(),
Signer: transfer.Key,
Data: string(data),
Config: transfer.Config,
}).
SetError(&errRes).
Post("/api/v1/transfer")
Expand Down
20 changes: 20 additions & 0 deletions internal/tokens/fftokens/fftokens_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,10 @@ func TestMintTokens(t *testing.T) {
ID: fftypes.NewUUID(),
Type: fftypes.TransactionTypeTokenTransfer,
},
URI: "FLAPFLIP",
Config: fftypes.JSONObject{
"foo": "bar",
},
}
opID := fftypes.NewUUID()

Expand All @@ -525,10 +529,14 @@ func TestMintTokens(t *testing.T) {
"amount": "10",
"signer": "0x123",
"requestId": opID.String(),
"config": map[string]interface{}{
"foo": "bar",
},
"data": fftypes.JSONObject{
"tx": mint.TX.ID.String(),
"txtype": fftypes.TransactionTypeTokenTransfer.String(),
}.String(),
"uri": "FLAPFLIP",
}, body)

res := &http.Response{
Expand Down Expand Up @@ -638,6 +646,9 @@ func TestBurnTokens(t *testing.T) {
ID: fftypes.NewUUID(),
Type: fftypes.TransactionTypeTokenTransfer,
},
Config: fftypes.JSONObject{
"foo": "bar",
},
}
opID := fftypes.NewUUID()

Expand All @@ -653,6 +664,9 @@ func TestBurnTokens(t *testing.T) {
"amount": "10",
"signer": "0x123",
"requestId": opID.String(),
"config": map[string]interface{}{
"foo": "bar",
},
"data": fftypes.JSONObject{
"tx": burn.TX.ID.String(),
"txtype": fftypes.TransactionTypeTokenTransfer.String(),
Expand Down Expand Up @@ -701,6 +715,9 @@ func TestTransferTokens(t *testing.T) {
ID: fftypes.NewUUID(),
Type: fftypes.TransactionTypeTokenTransfer,
},
Config: fftypes.JSONObject{
"foo": "bar",
},
}
opID := fftypes.NewUUID()

Expand All @@ -717,6 +734,9 @@ func TestTransferTokens(t *testing.T) {
"amount": "10",
"signer": "0x123",
"requestId": opID.String(),
"config": map[string]interface{}{
"foo": "bar",
},
"data": fftypes.JSONObject{
"tx": transfer.TX.ID.String(),
"txtype": fftypes.TransactionTypeTokenTransfer.String(),
Expand Down
3 changes: 2 additions & 1 deletion pkg/fftypes/tokentransfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type TokenTransfer struct {
LocalID *UUID `ffstruct:"TokenTransfer" json:"localId,omitempty" ffexcludeinput:"true"`
Pool *UUID `ffstruct:"TokenTransfer" json:"pool,omitempty"`
TokenIndex string `ffstruct:"TokenTransfer" json:"tokenIndex,omitempty"`
URI string `ffstruct:"TokenTransfer" json:"uri,omitempty" ffexcludeinput:"true"`
URI string `ffstruct:"TokenTransfer" json:"uri,omitempty"`
Connector string `ffstruct:"TokenTransfer" json:"connector,omitempty" ffexcludeinput:"true"`
Namespace string `ffstruct:"TokenTransfer" json:"namespace,omitempty" ffexcludeinput:"true"`
Key string `ffstruct:"TokenTransfer" json:"key,omitempty"`
Expand All @@ -42,6 +42,7 @@ type TokenTransfer struct {
Created *FFTime `ffstruct:"TokenTransfer" json:"created,omitempty" ffexcludeinput:"true"`
TX TransactionRef `ffstruct:"TokenTransfer" json:"tx" ffexcludeinput:"true"`
BlockchainEvent *UUID `ffstruct:"TokenTransfer" json:"blockchainEvent,omitempty" ffexcludeinput:"true"`
Config JSONObject `ffstruct:"TokenTransfer" json:"config,omitempty" ffexcludeoutput:"true"` // for REST calls only (not stored)
}

type TokenTransferInput struct {
Expand Down