Skip to content

Commit 8183729

Browse files
Merge branch 'main' into unit-test-token-package-1348
2 parents e66649a + c67e21c commit 8183729

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+4321
-534
lines changed

checks.mk

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ checks: licensecheck gofmt goimports govet misspell ineffassign staticcheck
44
.PHONY: licensecheck
55
licensecheck:
66
@echo Running license check
7-
@find . -name '*.go' | xargs addlicense -check || (echo "Missing license headers"; exit 1)
7+
@find . -path './.git' -prune -o -name '*.go' -print | xargs addlicense -check || (echo "Missing license headers"; exit 1)
88

99
.PHONY: gofmt
1010
gofmt:
1111
@echo Running gofmt
1212
@{ \
13-
OUTPUT="$$(gofmt -l -s . || true)"; \
13+
OUTPUT="$$(find . -path './.git' -prune -o -name '*.go' -print | xargs gofmt -l -s || true)"; \
1414
if [ -n "$$OUTPUT" ]; then \
1515
echo "The following gofmt issues were flagged:"; \
1616
echo "$$OUTPUT"; \
@@ -23,7 +23,7 @@ gofmt:
2323
goimports:
2424
@echo Running goimports
2525
@{ \
26-
OUTPUT="$$(goimports -l .)"; \
26+
OUTPUT="$$(find . -path './.git' -prune -o -name '*.go' -print | xargs goimports -l || true)"; \
2727
if [ -n "$$OUTPUT" ]; then \
2828
echo "The following files contain goimports errors"; \
2929
echo "$$OUTPUT"; \
@@ -41,7 +41,7 @@ govet:
4141
misspell:
4242
@echo Running misspell
4343
@{ \
44-
OUTPUT="$$(find . -type f | grep -v '.golangci.yml' | grep -v 'testdata' | xargs misspell || true)"; \
44+
OUTPUT="$$(find . -path './.git' -prune -o -type f -print | grep -v '.golangci.yml' | grep -v 'testdata' | xargs misspell || true)"; \
4545
if [ -n "$$OUTPUT" ]; then \
4646
echo "The following files are have spelling errors:"; \
4747
echo "$$OUTPUT"; \

go.mod

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ require (
1313
github.com/go-co-op/gocron/v2 v2.19.1
1414
github.com/google/pprof v0.0.0-20260402051712-545e8a4df936
1515
github.com/hashicorp/go-uuid v1.0.3
16-
github.com/hyperledger-labs/fabric-smart-client v0.10.0
16+
github.com/hyperledger-labs/fabric-smart-client v0.10.1-0.20260410125500-78ec67a3d795
1717
github.com/hyperledger/fabric-chaincode-go/v2 v2.3.0
1818
github.com/hyperledger/fabric-lib-go v1.1.3-0.20240523144151-25edd1eaf5f5
1919
github.com/hyperledger/fabric-protos-go-apiv2 v0.3.7
@@ -63,6 +63,7 @@ require (
6363
github.com/IBM/idemix/bccsp/schemes/weak-bb v0.0.0-20250313153527-832db18b9478 // indirect
6464
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible // indirect
6565
github.com/Masterminds/semver/v3 v3.4.0 // indirect
66+
github.com/Masterminds/squirrel v1.5.4 // indirect
6667
github.com/Microsoft/go-winio v0.6.2 // indirect
6768
github.com/alecthomas/kingpin/v2 v2.4.0 // indirect
6869
github.com/alecthomas/units v0.0.0-20240927000941-0f3dac36c52b // indirect
@@ -160,6 +161,8 @@ require (
160161
github.com/koron/go-ssdp v0.0.6 // indirect
161162
github.com/kr/pretty v0.3.1 // indirect
162163
github.com/kr/text v0.2.0 // indirect
164+
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect
165+
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect
163166
github.com/leodido/go-urn v1.4.0 // indirect
164167
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
165168
github.com/libp2p/go-cidranger v1.1.0 // indirect

go.sum

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,8 @@ github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible h1
655655
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
656656
github.com/Masterminds/semver/v3 v3.4.0 h1:Zog+i5UMtVoCU8oKka5P7i9q9HgrJeGzI9SA1Xbatp0=
657657
github.com/Masterminds/semver/v3 v3.4.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
658+
github.com/Masterminds/squirrel v1.5.4 h1:uUcX/aBc8O7Fg9kaISIUsHXdKuqehiXAMQTYX8afzqM=
659+
github.com/Masterminds/squirrel v1.5.4/go.mod h1:NNaOrjSoIDfDA40n7sr2tPNZRfjzjA400rg+riTZj10=
658660
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
659661
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
660662
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
@@ -1063,8 +1065,8 @@ github.com/huin/goupnp v1.3.0 h1:UvLUlWDNpoUdYzb2TCn+MuTWtcjXKSza2n6CBdQ0xXc=
10631065
github.com/huin/goupnp v1.3.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFckNX8=
10641066
github.com/hyperledger-labs/SmartBFT v0.0.0-20250503203013-eb005eef8866 h1:Mu/6NJsfl9g3wM15Ue7hqPq4LtgYDoABh8MO4u8aW4g=
10651067
github.com/hyperledger-labs/SmartBFT v0.0.0-20250503203013-eb005eef8866/go.mod h1:9aNHNXsCVy/leGz2gpTC1eOL5QecxbSAGjqsLh4T1LM=
1066-
github.com/hyperledger-labs/fabric-smart-client v0.10.0 h1:cuPgx0+x4rDiGQsZMvmgSLB5dFMLU0TOTUP+hHIe08o=
1067-
github.com/hyperledger-labs/fabric-smart-client v0.10.0/go.mod h1:kywkl6qr9jN3HtHxP9UCHkkGhjTRs+tmutsHgCcac14=
1068+
github.com/hyperledger-labs/fabric-smart-client v0.10.1-0.20260410125500-78ec67a3d795 h1:ZI+b08INc185ctao8i52xmkB3TrLvr0vPMPJHJ/22tg=
1069+
github.com/hyperledger-labs/fabric-smart-client v0.10.1-0.20260410125500-78ec67a3d795/go.mod h1:xK+o8df6gXqw2UkuREEFtrHN3zmUQ+ur8MXUEa+MyuU=
10681070
github.com/hyperledger/aries-bbs-go v0.0.0-20240528084656-761671ea73bc h1:3Ykk6MtyfnlzMOQry9zkxsoLWpCWZwDPqehO/BJwArM=
10691071
github.com/hyperledger/aries-bbs-go v0.0.0-20240528084656-761671ea73bc/go.mod h1:Kofn6A6WWea1ZM8Rys5aBW9dszwJ7Ywa0kyyYL0TPYw=
10701072
github.com/hyperledger/fabric-amcl v0.0.0-20230602173724-9e02669dceb2 h1:B1Nt8hKb//KvgGRprk0h1t4lCnwhE9/ryb1WqfZbV+M=
@@ -1172,6 +1174,10 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
11721174
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
11731175
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
11741176
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
1177+
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 h1:SOEGU9fKiNWd/HOJuq6+3iTQz8KNCLtVX6idSoTLdUw=
1178+
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0/go.mod h1:dXGbAdH5GtBTC4WfIxhKZfyBF/HBFgRZSWwZ9g/He9o=
1179+
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 h1:P6pPBnrTSX3DEVR4fDembhRWSsG5rVo6hYhAB/ADZrk=
1180+
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0/go.mod h1:vmVJ0l/dxyfGW6FmdpVm2joNMFikkuWg0EoCKLGUMNw=
11751181
github.com/leanovate/gopter v0.2.11 h1:vRjThO1EKPb/1NsDXuDrzldR28RLkBflWYcU9CvzWu4=
11761182
github.com/leanovate/gopter v0.2.11/go.mod h1:aK3tzZP/C+p1m3SPRE4SYZFGP7jjkuSI4f7Xvpt0S9c=
11771183
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=

integration/nwo/runner/nwo/user_provider.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func newUserProvider(nw *integration.Infrastructure, metrics *metrics.Metrics, t
3838
for i, replicaName := range selector.Get(username).AllNames() {
3939
client := nw.Client(replicaName)
4040
if client == nil {
41-
return nil, errors2.Errorf("could not find client for %s, only following found: [%v]", replicaName, collections.Keys(nw.Ctx.ViewClients))
41+
return nil, errors2.Errorf("could not find client for %s, only following found: [%v]", replicaName, collections.Keys(nw.NWOCtx.ViewClients))
4242
}
4343
replicas[i] = runner2.NewViewUser(username, auditor, client, nw, metrics, tracerProvider, logger)
4444
}

integration/nwo/token/platform.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func NewPlatform(ctx api2.Context, t api2.Topology, builder api2.Builder) *Platf
9494

9595
// GetPlatform returns the token platform from the passed context bound to the passed id.
9696
// It returns nil, if nothing is found
97-
func GetPlatform(ctx *context.Context, id string) PF {
97+
func GetPlatform(ctx *context.NWOContext, id string) PF {
9898
p := ctx.PlatformByName(id)
9999
if p == nil {
100100
return nil

integration/token/fungible/support.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,7 +1002,7 @@ func CheckPublicParamsMatch(network *integration.Infrastructure, tmsId *token2.T
10021002
}
10031003

10041004
func GetTMSByNetworkName(network *integration.Infrastructure, networkName string) *topology.TMS {
1005-
tp := tplatform.GetPlatform(network.Ctx, "token")
1005+
tp := tplatform.GetPlatform(network.NWOCtx, "token")
10061006
gomega.Expect(tp).NotTo(gomega.BeNil())
10071007
for _, TMS := range tp.GetTopology().TMSs {
10081008
if TMS.Network == networkName {
@@ -1013,7 +1013,7 @@ func GetTMSByNetworkName(network *integration.Infrastructure, networkName string
10131013
}
10141014

10151015
func GetTMSByTMSID(network *integration.Infrastructure, tmsID token2.TMSID) *topology.TMS {
1016-
tp := tplatform.GetPlatform(network.Ctx, "token")
1016+
tp := tplatform.GetPlatform(network.NWOCtx, "token")
10171017
gomega.Expect(tp).NotTo(gomega.BeNil())
10181018
for _, tms := range tp.GetTopology().TMSs {
10191019
if tms.Network == tmsID.Network && tms.Channel == tmsID.Channel && tms.Namespace == tmsID.Namespace {
@@ -1024,7 +1024,7 @@ func GetTMSByTMSID(network *integration.Infrastructure, tmsID token2.TMSID) *top
10241024
}
10251025

10261026
func GetTMSByAlias(network *integration.Infrastructure, alias topology.TMSAlias) *topology.TMS {
1027-
tp := tplatform.GetPlatform(network.Ctx, "token")
1027+
tp := tplatform.GetPlatform(network.NWOCtx, "token")
10281028
gomega.Expect(tp).NotTo(gomega.BeNil())
10291029
for _, TMS := range tp.GetTopology().TMSs {
10301030
if TMS.Alias == alias {
@@ -1035,12 +1035,12 @@ func GetTMSByAlias(network *integration.Infrastructure, alias topology.TMSAlias)
10351035
}
10361036

10371037
func UpdatePublicParams(network *integration.Infrastructure, publicParams []byte, tms *topology.TMS) {
1038-
p := network.Ctx.PlatformsByName["token"]
1038+
p := network.NWOCtx.PlatformsByName["token"]
10391039
p.(*tplatform.Platform).UpdatePublicParams(tms, publicParams)
10401040
}
10411041

10421042
func UpdatePublicParamsAndWait(network *integration.Infrastructure, publicParams []byte, tms *topology.TMS, nodes ...*token3.NodeReference) {
1043-
p := network.Ctx.PlatformsByName["token"]
1043+
p := network.NWOCtx.PlatformsByName["token"]
10441044
p.(*tplatform.Platform).UpdatePublicParams(tms, publicParams)
10451045
for _, node := range nodes {
10461046
if node.Id() == "custodian" {
@@ -1217,15 +1217,15 @@ func Restart(network *integration.Infrastructure, deleteVault bool, onRestart On
12171217
time.Sleep(10 * time.Second)
12181218
if deleteVault {
12191219
for _, id := range ids {
1220-
for name, platform := range network.Ctx.PlatformsByName {
1220+
for name, platform := range network.NWOCtx.PlatformsByName {
12211221
if dv, ok := platform.(deleteVaultPlatform); ok {
12221222
logger.Infof("Platform %d supports delete vault. Deleting...", name)
12231223
dv.DeleteVault(id.Id())
12241224
}
12251225
}
12261226

12271227
// delete token dbs as well
1228-
tokenPlatform := tplatform.GetPlatform(network.Ctx, "token")
1228+
tokenPlatform := tplatform.GetPlatform(network.NWOCtx, "token")
12291229
gomega.Expect(tokenPlatform).ToNot(gomega.BeNil(), "cannot find token platform in context")
12301230
for _, tms := range tokenPlatform.GetTopology().TMSs {
12311231
tokenPlatform.DeleteDBs(tms, id.Id())
@@ -1249,7 +1249,7 @@ func Restart(network *integration.Infrastructure, deleteVault bool, onRestart On
12491249
}
12501250

12511251
func CopyDBsTo(network *integration.Infrastructure, to string, ids ...*token3.NodeReference) {
1252-
tokenPlatform := tplatform.GetPlatform(network.Ctx, "token")
1252+
tokenPlatform := tplatform.GetPlatform(network.NWOCtx, "token")
12531253
gomega.Expect(tokenPlatform).ToNot(gomega.BeNil(), "cannot find token platform in context")
12541254

12551255
for _, id := range ids {
@@ -1265,7 +1265,7 @@ func RegisterIssuerIdentity(network *integration.Infrastructure, id *token3.Node
12651265
Path: walletPath,
12661266
}))
12671267
gomega.Expect(err).NotTo(gomega.HaveOccurred())
1268-
network.Ctx.SetViewClient(walletPath, network.Client(id.ReplicaName()))
1268+
network.NWOCtx.SetViewClient(walletPath, network.Client(id.ReplicaName()))
12691269
}
12701270

12711271
func RegisterOwnerIdentity(ctx context.Context, network *integration.Infrastructure, id *token3.NodeReference, identityConfiguration token2.IdentityConfiguration) {
@@ -1274,7 +1274,7 @@ func RegisterOwnerIdentity(ctx context.Context, network *integration.Infrastruct
12741274
IdentityConfiguration: identityConfiguration,
12751275
}))
12761276
gomega.Expect(err).NotTo(gomega.HaveOccurred(), "cannot register owner identity at replica [%s]", replicaName)
1277-
network.Ctx.SetViewClient(identityConfiguration.ID, network.Client(replicaName))
1277+
network.NWOCtx.SetViewClient(identityConfiguration.ID, network.Client(replicaName))
12781278
}
12791279
}
12801280

@@ -1284,7 +1284,7 @@ func RegisterRecipientData(network *integration.Infrastructure, ref *token3.Node
12841284
RecipientData: *rd,
12851285
}))
12861286
gomega.Expect(err).NotTo(gomega.HaveOccurred())
1287-
network.Ctx.SetViewClient(walletID, network.Client(ref.ReplicaName()))
1287+
network.NWOCtx.SetViewClient(walletID, network.Client(ref.ReplicaName()))
12881288
}
12891289

12901290
func CheckOwnerWalletIDs(network *integration.Infrastructure, owner *token3.NodeReference, ids ...string) {
@@ -1507,7 +1507,7 @@ func PrepareUpdatedPublicParams(network *integration.Infrastructure, auditor str
15071507
auditorId := GetAuditorIdentity(tms, auditor)
15081508
issuerId := GetIssuerIdentity(tms, issuer)
15091509

1510-
tokenPlatform, ok := network.Ctx.PlatformsByName["token"].(*tplatform.Platform)
1510+
tokenPlatform, ok := network.NWOCtx.PlatformsByName["token"].(*tplatform.Platform)
15111511
gomega.Expect(ok).To(gomega.BeTrue(), "failed to get token platform from context")
15121512

15131513
// Deserialize current params
@@ -1563,7 +1563,7 @@ func PreparePublicParamsWithNewIssuer(network *integration.Infrastructure, issue
15631563
wrap, err := identity.WrapWithType(x509.IdentityType, identityDescriptor.Identity)
15641564
gomega.Expect(err).NotTo(gomega.HaveOccurred())
15651565

1566-
tokenPlatform, ok := network.Ctx.PlatformsByName["token"].(*tplatform.Platform)
1566+
tokenPlatform, ok := network.NWOCtx.PlatformsByName["token"].(*tplatform.Platform)
15671567
gomega.Expect(ok).To(gomega.BeTrue(), "failed to get token platform from context")
15681568

15691569
// Deserialize current params

integration/token/fungible/tests.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ func TestAll(network *integration.Infrastructure, auditorId string, onRestart On
355355

356356
// Register a new issuer wallet and issue with that wallet
357357
CheckPublicParams(network, issuer, auditor, alice, bob, charlie, manager)
358-
tokenPlatform := token.GetPlatform(network.Ctx, "token")
358+
tokenPlatform := token.GetPlatform(network.NWOCtx, "token")
359359
gomega.Expect(tokenPlatform).ToNot(gomega.BeNil(), "cannot find token platform in context")
360360
gomega.Expect(tokenPlatform.GetTopology()).ToNot(gomega.BeNil(), "invalid token topology, it is nil")
361361
gomega.Expect(len(tokenPlatform.GetTopology().TMSs)).ToNot(gomega.BeEquivalentTo(0), "no tms defined in token topology")
@@ -921,7 +921,7 @@ func testTwoGeneratedOwnerWalletsSameNode(network *integration.Infrastructure, a
921921
issuer := sel.Get("issuer")
922922
charlie := sel.Get("charlie")
923923

924-
tokenPlatform := token.GetPlatform(network.Ctx, "token")
924+
tokenPlatform := token.GetPlatform(network.NWOCtx, "token")
925925
idConfig1 := tokenPlatform.GenOwnerCryptoMaterial(tokenPlatform.GetTopology().TMSs[0].BackendTopology.Name(), charlie.Id(), "charlie.ExtraId1", false)
926926
RegisterOwnerIdentity(ctx, network, charlie, idConfig1)
927927
idConfig2 := tokenPlatform.GenOwnerCryptoMaterial(tokenPlatform.GetTopology().TMSs[0].BackendTopology.Name(), charlie.Id(), "charlie.ExtraId2", useFabricCA)
@@ -1224,7 +1224,7 @@ func TestTokensUpgrade(network *integration.Infrastructure, auditorId string, on
12241224
manager := sel.Get("manager")
12251225
endorsers := GetEndorsers(network, sel)
12261226
RegisterAuditor(network, auditor)
1227-
tokenPlatform, ok := network.Ctx.PlatformsByName["token"].(*token.Platform)
1227+
tokenPlatform, ok := network.NWOCtx.PlatformsByName["token"].(*token.Platform)
12281228
gomega.Expect(ok).To(gomega.BeTrue())
12291229

12301230
// give some time to the nodes to get the public parameters
@@ -1298,7 +1298,7 @@ func TestLocalTokensUpgrade(network *integration.Infrastructure, auditorId strin
12981298
manager := sel.Get("manager")
12991299
endorsers := GetEndorsers(network, sel)
13001300
RegisterAuditor(network, auditor)
1301-
tokenPlatform, ok := network.Ctx.PlatformsByName["token"].(*token.Platform)
1301+
tokenPlatform, ok := network.NWOCtx.PlatformsByName["token"].(*token.Platform)
13021302
gomega.Expect(ok).To(gomega.BeTrue())
13031303

13041304
// give some time to the nodes to get the public parameters
@@ -1352,7 +1352,7 @@ func TestIdemixIssuerPublicKeyRotation(network *integration.Infrastructure, audi
13521352
manager := sel.Get("manager")
13531353
endorsers := GetEndorsers(network, sel)
13541354
RegisterAuditor(network, auditor)
1355-
tokenPlatform, ok := network.Ctx.PlatformsByName["token"].(*token.Platform)
1355+
tokenPlatform, ok := network.NWOCtx.PlatformsByName["token"].(*token.Platform)
13561356
gomega.Expect(ok).To(gomega.BeTrue())
13571357

13581358
// give some time to the nodes to get the public parameters

integration/token/fungible/wmp.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ type walletManagerLoader struct {
105105
}
106106

107107
func (l *walletManagerLoader) Load(user string) *token.WalletManager {
108-
ctx := l.II.Ctx
108+
ctx := l.II.NWOCtx
109109
tp := ctx.PlatformByName("token").(TMSTopology)
110110
tms := tp.GetTopology().TMSs[0]
111111
ppRaw := tp.PublicParameters(tms)

token/core/fabtoken/v1/actions/transfer.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"github.com/hyperledger-labs/fabric-smart-client/pkg/utils/errors"
1111
"github.com/hyperledger-labs/fabric-smart-client/pkg/utils/proto"
1212
"github.com/hyperledger-labs/fabric-token-sdk/token/core/fabtoken/protos-go/actions"
13-
pp "github.com/hyperledger-labs/fabric-token-sdk/token/core/fabtoken/protos-go/pp"
13+
"github.com/hyperledger-labs/fabric-token-sdk/token/core/fabtoken/protos-go/pp"
1414
"github.com/hyperledger-labs/fabric-token-sdk/token/driver"
1515
"github.com/hyperledger-labs/fabric-token-sdk/token/services/utils/protos"
1616
"github.com/hyperledger-labs/fabric-token-sdk/token/services/utils/slices"
@@ -222,9 +222,11 @@ func (t *TransferAction) Validate() error {
222222
return errors.Errorf("invalid output's quantity at index [%d], output quantity is empty", i)
223223
}
224224
}
225-
if t.IsRedeem() && (t.Issuer == nil) {
226-
return errors.Errorf("Expected Issuer for a Redeem action (to validate)")
227-
}
225+
// The following check must happen only if the public parameters contain issuers.
226+
// The validator enforces the signature of an issuer only in that case.
227+
// if t.IsRedeem() && (t.Issuer == nil) {
228+
// return ErrMissingIssuer
229+
// }
228230

229231
return nil
230232
}

token/core/fabtoken/v1/actions/transfer_test.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -349,12 +349,6 @@ func TestTransferAction_RemainingMethods(t *testing.T) {
349349
assert.Equal(t, map[string][]byte{"foo": []byte("bar")}, action.GetMetadata())
350350
assert.Nil(t, action.ExtraSigners())
351351

352-
// Test Validate with Redeem and nil issuer
353-
action.Issuer = nil
354-
err = action.Validate()
355-
require.Error(t, err)
356-
assert.Contains(t, err.Error(), "Expected Issuer for a Redeem action")
357-
358352
// Test GetSerializedOutputs with nil output
359353
action.Outputs = append(action.Outputs, nil)
360354
_, err = action.GetSerializedOutputs()

0 commit comments

Comments
 (0)