From 8031b7ae67bdf882ab7f4493b9a8208ea1def962 Mon Sep 17 00:00:00 2001 From: Alex Shorsher Date: Fri, 24 Jun 2022 11:02:44 -0400 Subject: [PATCH 1/4] surface URI as parameter for token mint Signed-off-by: Alex Shorsher --- docs/swagger/swagger.yaml | 9 +++++++++ internal/tokens/fftokens/fftokens.go | 2 ++ internal/tokens/fftokens/fftokens_test.go | 2 ++ pkg/fftypes/tokentransfer.go | 2 +- 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/docs/swagger/swagger.yaml b/docs/swagger/swagger.yaml index 7d735d2e0d..47c3d4a980 100644 --- a/docs/swagger/swagger.yaml +++ b/docs/swagger/swagger.yaml @@ -10937,6 +10937,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": @@ -11356,6 +11359,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": @@ -12561,6 +12567,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/tokens/fftokens/fftokens.go b/internal/tokens/fftokens/fftokens.go index af43872f34..7a475e54f0 100644 --- a/internal/tokens/fftokens/fftokens.go +++ b/internal/tokens/fftokens/fftokens.go @@ -89,6 +89,7 @@ type mintTokens struct { RequestID string `json:"requestId,omitempty"` Signer string `json:"signer"` Data string `json:"data,omitempty"` + URI string `json:"uri"` } type burnTokens struct { @@ -576,6 +577,7 @@ func (ft *FFTokens) MintTokens(ctx context.Context, opID *fftypes.UUID, poolLoca RequestID: opID.String(), Signer: mint.Key, Data: string(data), + URI: mint.URI, }). SetError(&errRes). Post("/api/v1/mint") diff --git a/internal/tokens/fftokens/fftokens_test.go b/internal/tokens/fftokens/fftokens_test.go index 0b478a5d57..7b27a6ae98 100644 --- a/internal/tokens/fftokens/fftokens_test.go +++ b/internal/tokens/fftokens/fftokens_test.go @@ -511,6 +511,7 @@ func TestMintTokens(t *testing.T) { ID: fftypes.NewUUID(), Type: fftypes.TransactionTypeTokenTransfer, }, + URI: "FLAPFLIP", } opID := fftypes.NewUUID() @@ -529,6 +530,7 @@ func TestMintTokens(t *testing.T) { "tx": mint.TX.ID.String(), "txtype": fftypes.TransactionTypeTokenTransfer.String(), }.String(), + "uri": "FLAPFLIP", }, body) res := &http.Response{ diff --git a/pkg/fftypes/tokentransfer.go b/pkg/fftypes/tokentransfer.go index 821a342508..e45cc5b809 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"` From 380d977ab7bc9f52c6315b37673dcc562b0d20a0 Mon Sep 17 00:00:00 2001 From: Alex Shorsher Date: Tue, 5 Jul 2022 16:17:45 -0400 Subject: [PATCH 2/4] omit empty `uri` param Signed-off-by: Alex Shorsher --- internal/tokens/fftokens/fftokens.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/tokens/fftokens/fftokens.go b/internal/tokens/fftokens/fftokens.go index 7a475e54f0..9622a4cfcd 100644 --- a/internal/tokens/fftokens/fftokens.go +++ b/internal/tokens/fftokens/fftokens.go @@ -89,7 +89,7 @@ type mintTokens struct { RequestID string `json:"requestId,omitempty"` Signer string `json:"signer"` Data string `json:"data,omitempty"` - URI string `json:"uri"` + URI string `json:"uri,omitempty"` } type burnTokens struct { From 32702c946146859d8261bdbfbbd637bef301d871 Mon Sep 17 00:00:00 2001 From: Alex Shorsher Date: Tue, 5 Jul 2022 17:05:24 -0400 Subject: [PATCH 3/4] add passthrough config to mint/transfer/burn Signed-off-by: Alex Shorsher --- docs/reference/types/tokentransfer.md | 1 + docs/swagger/swagger.yaml | 31 ++++++++++++ internal/coremsgs/en_struct_descriptions.go | 1 + internal/tokens/fftokens/fftokens.go | 52 ++++++++++++--------- internal/tokens/fftokens/fftokens_test.go | 18 +++++++ pkg/fftypes/tokentransfer.go | 1 + 6 files changed, 81 insertions(+), 23 deletions(-) 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 47c3d4a980..aeff4896b2 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' @@ -11207,6 +11216,19 @@ 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' + type: string key: description: The blockchain signing key for the transfer. On input defaults to the first signing key of the organization that operates @@ -12411,6 +12433,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' 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 9622a4cfcd..f24a879372 100644 --- a/internal/tokens/fftokens/fftokens.go +++ b/internal/tokens/fftokens/fftokens.go @@ -82,35 +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"` - URI string `json:"uri,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 { @@ -578,6 +581,7 @@ func (ft *FFTokens) MintTokens(ctx context.Context, opID *fftypes.UUID, poolLoca Signer: mint.Key, Data: string(data), URI: mint.URI, + Config: mint.Config, }). SetError(&errRes). Post("/api/v1/mint") @@ -604,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") @@ -631,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 7b27a6ae98..1e64af5754 100644 --- a/internal/tokens/fftokens/fftokens_test.go +++ b/internal/tokens/fftokens/fftokens_test.go @@ -512,6 +512,9 @@ func TestMintTokens(t *testing.T) { Type: fftypes.TransactionTypeTokenTransfer, }, URI: "FLAPFLIP", + Config: fftypes.JSONObject{ + "foo": "bar", + }, } opID := fftypes.NewUUID() @@ -526,6 +529,9 @@ 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(), @@ -640,6 +646,9 @@ func TestBurnTokens(t *testing.T) { ID: fftypes.NewUUID(), Type: fftypes.TransactionTypeTokenTransfer, }, + Config: fftypes.JSONObject{ + "foo": "bar", + }, } opID := fftypes.NewUUID() @@ -655,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(), @@ -703,6 +715,9 @@ func TestTransferTokens(t *testing.T) { ID: fftypes.NewUUID(), Type: fftypes.TransactionTypeTokenTransfer, }, + Config: fftypes.JSONObject{ + "foo": "bar", + }, } opID := fftypes.NewUUID() @@ -719,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 e45cc5b809..a955c85c88 100644 --- a/pkg/fftypes/tokentransfer.go +++ b/pkg/fftypes/tokentransfer.go @@ -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 { From 9983ce289f5cc7667ff811dc41d33af8d694b44f Mon Sep 17 00:00:00 2001 From: Alex Shorsher Date: Wed, 6 Jul 2022 12:24:39 -0400 Subject: [PATCH 4/4] update swagger Signed-off-by: Alex Shorsher --- docs/swagger/swagger.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/docs/swagger/swagger.yaml b/docs/swagger/swagger.yaml index aeff4896b2..dfde6b7e21 100644 --- a/docs/swagger/swagger.yaml +++ b/docs/swagger/swagger.yaml @@ -11225,10 +11225,6 @@ paths: 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' - type: string key: description: The blockchain signing key for the transfer. On input defaults to the first signing key of the organization that operates