Skip to content

Commit 7c5d0de

Browse files
authored
Merge pull request #885 from kaleido-io/backport-uri
back port of custom URI support for non-fungible tokens
2 parents 522007c + 9983ce2 commit 7c5d0de

File tree

6 files changed

+90
-23
lines changed

6 files changed

+90
-23
lines changed

docs/reference/types/tokentransfer.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ nav_order: 11
6666
| `created` | The creation time of the transfer | [`FFTime`](simpletypes#fftime) |
6767
| `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) |
6868
| `blockchainEvent` | The UUID of the blockchain event | [`UUID`](simpletypes#uuid) |
69+
| `config` | Input only field, with token connector specific configuration of the transfer. See your chosen token connector documentation for details | [`JSONObject`](simpletypes#jsonobject) |
6970

7071
## TransactionRef
7172

docs/swagger/swagger.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10785,6 +10785,15 @@ paths:
1078510785
For example, with 18 decimals a fractional balance of 10.234 will
1078610786
be specified as 10,234,000,000,000,000,000
1078710787
type: string
10788+
config:
10789+
additionalProperties:
10790+
description: Input only field, with token connector specific configuration
10791+
of the transfer. See your chosen token connector documentation
10792+
for details
10793+
description: Input only field, with token connector specific configuration
10794+
of the transfer. See your chosen token connector documentation
10795+
for details
10796+
type: object
1078810797
from:
1078910798
description: The source account for the transfer. On input defaults
1079010799
to the value of 'key'
@@ -10937,6 +10946,9 @@ paths:
1093710946
description: The index of the token within the pool that this transfer
1093810947
applies to
1093910948
type: string
10949+
uri:
10950+
description: The URI of the token this transfer applies to
10951+
type: string
1094010952
type: object
1094110953
responses:
1094210954
"200":
@@ -11204,6 +11216,15 @@ paths:
1120411216
For example, with 18 decimals a fractional balance of 10.234 will
1120511217
be specified as 10,234,000,000,000,000,000
1120611218
type: string
11219+
config:
11220+
additionalProperties:
11221+
description: Input only field, with token connector specific configuration
11222+
of the transfer. See your chosen token connector documentation
11223+
for details
11224+
description: Input only field, with token connector specific configuration
11225+
of the transfer. See your chosen token connector documentation
11226+
for details
11227+
type: object
1120711228
key:
1120811229
description: The blockchain signing key for the transfer. On input
1120911230
defaults to the first signing key of the organization that operates
@@ -11356,6 +11377,9 @@ paths:
1135611377
description: The index of the token within the pool that this transfer
1135711378
applies to
1135811379
type: string
11380+
uri:
11381+
description: The URI of the token this transfer applies to
11382+
type: string
1135911383
type: object
1136011384
responses:
1136111385
"200":
@@ -12405,6 +12429,15 @@ paths:
1240512429
For example, with 18 decimals a fractional balance of 10.234 will
1240612430
be specified as 10,234,000,000,000,000,000
1240712431
type: string
12432+
config:
12433+
additionalProperties:
12434+
description: Input only field, with token connector specific configuration
12435+
of the transfer. See your chosen token connector documentation
12436+
for details
12437+
description: Input only field, with token connector specific configuration
12438+
of the transfer. See your chosen token connector documentation
12439+
for details
12440+
type: object
1240812441
from:
1240912442
description: The source account for the transfer. On input defaults
1241012443
to the value of 'key'
@@ -12561,6 +12594,9 @@ paths:
1256112594
description: The index of the token within the pool that this transfer
1256212595
applies to
1256312596
type: string
12597+
uri:
12598+
description: The URI of the token this transfer applies to
12599+
type: string
1256412600
type: object
1256512601
responses:
1256612602
"200":

internal/coremsgs/en_struct_descriptions.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,7 @@ var (
542542
TokenTransferCreated = ffm("TokenTransfer.created", "The creation time of the transfer")
543543
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)")
544544
TokenTransferBlockchainEvent = ffm("TokenTransfer.blockchainEvent", "The UUID of the blockchain event")
545+
TokenTransferConfig = ffm("TokenTransfer.config", "Input only field, with token connector specific configuration of the transfer. See your chosen token connector documentation for details")
545546

546547
// TokenTransferInput field descriptions
547548
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")

internal/tokens/fftokens/fftokens.go

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -82,34 +82,38 @@ type activatePool struct {
8282
}
8383

8484
type mintTokens struct {
85-
PoolLocator string `json:"poolLocator"`
86-
TokenIndex string `json:"tokenIndex,omitempty"`
87-
To string `json:"to"`
88-
Amount string `json:"amount"`
89-
RequestID string `json:"requestId,omitempty"`
90-
Signer string `json:"signer"`
91-
Data string `json:"data,omitempty"`
85+
PoolLocator string `json:"poolLocator"`
86+
TokenIndex string `json:"tokenIndex,omitempty"`
87+
To string `json:"to"`
88+
Amount string `json:"amount"`
89+
RequestID string `json:"requestId,omitempty"`
90+
Signer string `json:"signer"`
91+
Data string `json:"data,omitempty"`
92+
URI string `json:"uri,omitempty"`
93+
Config fftypes.JSONObject `json:"config"`
9294
}
9395

9496
type burnTokens struct {
95-
PoolLocator string `json:"poolLocator"`
96-
TokenIndex string `json:"tokenIndex,omitempty"`
97-
From string `json:"from"`
98-
Amount string `json:"amount"`
99-
RequestID string `json:"requestId,omitempty"`
100-
Signer string `json:"signer"`
101-
Data string `json:"data,omitempty"`
97+
PoolLocator string `json:"poolLocator"`
98+
TokenIndex string `json:"tokenIndex,omitempty"`
99+
From string `json:"from"`
100+
Amount string `json:"amount"`
101+
RequestID string `json:"requestId,omitempty"`
102+
Signer string `json:"signer"`
103+
Data string `json:"data,omitempty"`
104+
Config fftypes.JSONObject `json:"config"`
102105
}
103106

104107
type transferTokens struct {
105-
PoolLocator string `json:"poolLocator"`
106-
TokenIndex string `json:"tokenIndex,omitempty"`
107-
From string `json:"from"`
108-
To string `json:"to"`
109-
Amount string `json:"amount"`
110-
RequestID string `json:"requestId,omitempty"`
111-
Signer string `json:"signer"`
112-
Data string `json:"data,omitempty"`
108+
PoolLocator string `json:"poolLocator"`
109+
TokenIndex string `json:"tokenIndex,omitempty"`
110+
From string `json:"from"`
111+
To string `json:"to"`
112+
Amount string `json:"amount"`
113+
RequestID string `json:"requestId,omitempty"`
114+
Signer string `json:"signer"`
115+
Data string `json:"data,omitempty"`
116+
Config fftypes.JSONObject `json:"config"`
113117
}
114118

115119
type tokenApproval struct {
@@ -576,6 +580,8 @@ func (ft *FFTokens) MintTokens(ctx context.Context, opID *fftypes.UUID, poolLoca
576580
RequestID: opID.String(),
577581
Signer: mint.Key,
578582
Data: string(data),
583+
URI: mint.URI,
584+
Config: mint.Config,
579585
}).
580586
SetError(&errRes).
581587
Post("/api/v1/mint")
@@ -602,6 +608,7 @@ func (ft *FFTokens) BurnTokens(ctx context.Context, opID *fftypes.UUID, poolLoca
602608
RequestID: opID.String(),
603609
Signer: burn.Key,
604610
Data: string(data),
611+
Config: burn.Config,
605612
}).
606613
SetError(&errRes).
607614
Post("/api/v1/burn")
@@ -629,6 +636,7 @@ func (ft *FFTokens) TransferTokens(ctx context.Context, opID *fftypes.UUID, pool
629636
RequestID: opID.String(),
630637
Signer: transfer.Key,
631638
Data: string(data),
639+
Config: transfer.Config,
632640
}).
633641
SetError(&errRes).
634642
Post("/api/v1/transfer")

internal/tokens/fftokens/fftokens_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,10 @@ func TestMintTokens(t *testing.T) {
511511
ID: fftypes.NewUUID(),
512512
Type: fftypes.TransactionTypeTokenTransfer,
513513
},
514+
URI: "FLAPFLIP",
515+
Config: fftypes.JSONObject{
516+
"foo": "bar",
517+
},
514518
}
515519
opID := fftypes.NewUUID()
516520

@@ -525,10 +529,14 @@ func TestMintTokens(t *testing.T) {
525529
"amount": "10",
526530
"signer": "0x123",
527531
"requestId": opID.String(),
532+
"config": map[string]interface{}{
533+
"foo": "bar",
534+
},
528535
"data": fftypes.JSONObject{
529536
"tx": mint.TX.ID.String(),
530537
"txtype": fftypes.TransactionTypeTokenTransfer.String(),
531538
}.String(),
539+
"uri": "FLAPFLIP",
532540
}, body)
533541

534542
res := &http.Response{
@@ -638,6 +646,9 @@ func TestBurnTokens(t *testing.T) {
638646
ID: fftypes.NewUUID(),
639647
Type: fftypes.TransactionTypeTokenTransfer,
640648
},
649+
Config: fftypes.JSONObject{
650+
"foo": "bar",
651+
},
641652
}
642653
opID := fftypes.NewUUID()
643654

@@ -653,6 +664,9 @@ func TestBurnTokens(t *testing.T) {
653664
"amount": "10",
654665
"signer": "0x123",
655666
"requestId": opID.String(),
667+
"config": map[string]interface{}{
668+
"foo": "bar",
669+
},
656670
"data": fftypes.JSONObject{
657671
"tx": burn.TX.ID.String(),
658672
"txtype": fftypes.TransactionTypeTokenTransfer.String(),
@@ -701,6 +715,9 @@ func TestTransferTokens(t *testing.T) {
701715
ID: fftypes.NewUUID(),
702716
Type: fftypes.TransactionTypeTokenTransfer,
703717
},
718+
Config: fftypes.JSONObject{
719+
"foo": "bar",
720+
},
704721
}
705722
opID := fftypes.NewUUID()
706723

@@ -717,6 +734,9 @@ func TestTransferTokens(t *testing.T) {
717734
"amount": "10",
718735
"signer": "0x123",
719736
"requestId": opID.String(),
737+
"config": map[string]interface{}{
738+
"foo": "bar",
739+
},
720740
"data": fftypes.JSONObject{
721741
"tx": transfer.TX.ID.String(),
722742
"txtype": fftypes.TransactionTypeTokenTransfer.String(),

pkg/fftypes/tokentransfer.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ type TokenTransfer struct {
2929
LocalID *UUID `ffstruct:"TokenTransfer" json:"localId,omitempty" ffexcludeinput:"true"`
3030
Pool *UUID `ffstruct:"TokenTransfer" json:"pool,omitempty"`
3131
TokenIndex string `ffstruct:"TokenTransfer" json:"tokenIndex,omitempty"`
32-
URI string `ffstruct:"TokenTransfer" json:"uri,omitempty" ffexcludeinput:"true"`
32+
URI string `ffstruct:"TokenTransfer" json:"uri,omitempty"`
3333
Connector string `ffstruct:"TokenTransfer" json:"connector,omitempty" ffexcludeinput:"true"`
3434
Namespace string `ffstruct:"TokenTransfer" json:"namespace,omitempty" ffexcludeinput:"true"`
3535
Key string `ffstruct:"TokenTransfer" json:"key,omitempty"`
@@ -42,6 +42,7 @@ type TokenTransfer struct {
4242
Created *FFTime `ffstruct:"TokenTransfer" json:"created,omitempty" ffexcludeinput:"true"`
4343
TX TransactionRef `ffstruct:"TokenTransfer" json:"tx" ffexcludeinput:"true"`
4444
BlockchainEvent *UUID `ffstruct:"TokenTransfer" json:"blockchainEvent,omitempty" ffexcludeinput:"true"`
45+
Config JSONObject `ffstruct:"TokenTransfer" json:"config,omitempty" ffexcludeoutput:"true"` // for REST calls only (not stored)
4546
}
4647

4748
type TokenTransferInput struct {

0 commit comments

Comments
 (0)