diff --git a/docs/reference/types/tokentransfer.md b/docs/reference/types/tokentransfer.md index d97c4bbbce..0079b82724 100644 --- a/docs/reference/types/tokentransfer.md +++ b/docs/reference/types/tokentransfer.md @@ -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 diff --git a/docs/swagger/swagger.yaml b/docs/swagger/swagger.yaml index 7d735d2e0d..dfde6b7e21 100644 --- a/docs/swagger/swagger.yaml +++ b/docs/swagger/swagger.yaml @@ -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' @@ -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": @@ -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 @@ -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": @@ -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' @@ -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": diff --git a/internal/coremsgs/en_struct_descriptions.go b/internal/coremsgs/en_struct_descriptions.go index c36d73c923..ef7b0332b1 100644 --- a/internal/coremsgs/en_struct_descriptions.go +++ b/internal/coremsgs/en_struct_descriptions.go @@ -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") diff --git a/internal/tokens/fftokens/fftokens.go b/internal/tokens/fftokens/fftokens.go index af43872f34..f24a879372 100644 --- a/internal/tokens/fftokens/fftokens.go +++ b/internal/tokens/fftokens/fftokens.go @@ -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 { @@ -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") @@ -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") @@ -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") diff --git a/internal/tokens/fftokens/fftokens_test.go b/internal/tokens/fftokens/fftokens_test.go index 0b478a5d57..1e64af5754 100644 --- a/internal/tokens/fftokens/fftokens_test.go +++ b/internal/tokens/fftokens/fftokens_test.go @@ -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() @@ -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{ @@ -638,6 +646,9 @@ func TestBurnTokens(t *testing.T) { ID: fftypes.NewUUID(), Type: fftypes.TransactionTypeTokenTransfer, }, + Config: fftypes.JSONObject{ + "foo": "bar", + }, } opID := fftypes.NewUUID() @@ -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(), @@ -701,6 +715,9 @@ func TestTransferTokens(t *testing.T) { ID: fftypes.NewUUID(), Type: fftypes.TransactionTypeTokenTransfer, }, + Config: fftypes.JSONObject{ + "foo": "bar", + }, } opID := fftypes.NewUUID() @@ -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(), diff --git a/pkg/fftypes/tokentransfer.go b/pkg/fftypes/tokentransfer.go index 821a342508..a955c85c88 100644 --- a/pkg/fftypes/tokentransfer.go +++ b/pkg/fftypes/tokentransfer.go @@ -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"` @@ -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 {