Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: custom get signers #16340

Merged
merged 34 commits into from
Jun 6, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
b20a1df
feat: get signers extension interface
aaronc May 16, 2023
badd826
WIP on defining custom get signers
aaronc May 16, 2023
00eefcf
add DefineCustomGetSigners
aaronc May 16, 2023
d8290fe
make vulncheck fix
kocubinski May 30, 2023
7a6bc71
add a custom signers test
kocubinski May 30, 2023
a275687
Merge branch 'main' of github.com:cosmos/cosmos-sdk into kocubinski/1…
kocubinski May 31, 2023
eefa8ae
Merge branch 'main' of github.com:cosmos/cosmos-sdk into kocubinski/1…
kocubinski May 31, 2023
ccdb3c0
remove replace
kocubinski May 31, 2023
bbfe4aa
still need replace for new annotation
kocubinski May 31, 2023
d8022de
no custom signers annotation
kocubinski May 31, 2023
a44534a
Merge branch 'main' of github.com:cosmos/cosmos-sdk into kocubinski/1…
kocubinski May 31, 2023
a1db0df
go mod tidy
kocubinski May 31, 2023
3cac445
rm unused import
kocubinski May 31, 2023
c088db2
specify CustomGetSignersFuncs as inputs
kocubinski May 31, 2023
ee6fa69
fix x/tx test
kocubinski May 31, 2023
ea17470
need x/tx replace in x/nft/go.mod
kocubinski May 31, 2023
5dce52b
works, but not how I want it to
kocubinski Jun 1, 2023
49a9013
simplify and use invoker
kocubinski Jun 1, 2023
2f4772e
remove signingContext validation from ProvideApp
kocubinski Jun 1, 2023
c6af01c
Merge branch 'main' into kocubinski/16112-custom-signers
kocubinski Jun 1, 2023
b01d359
changelog
kocubinski Jun 1, 2023
49d6ccd
Merge branch 'kocubinski/16112-custom-signers' of github.com:cosmos/c…
kocubinski Jun 1, 2023
66aedff
lint fixg
kocubinski Jun 1, 2023
9e7a2bb
seems better
kocubinski Jun 1, 2023
de3816c
add comments
kocubinski Jun 2, 2023
eb72031
refactor moving files
kocubinski Jun 2, 2023
9138f2c
adjust depinject test to fail during startup
kocubinski Jun 2, 2023
410935f
fix comment
kocubinski Jun 2, 2023
bdbace3
Merge branch 'main' of github.com:cosmos/cosmos-sdk into kocubinski/1…
kocubinski Jun 5, 2023
0d6f08f
disallow custom signer with proto annotation in Validate
kocubinski Jun 5, 2023
6955df2
Merge branch 'main' of github.com:cosmos/cosmos-sdk into kocubinski/1…
kocubinski Jun 5, 2023
5445754
fix validate logic
kocubinski Jun 5, 2023
e3dd1c3
linting fix
kocubinski Jun 5, 2023
3947ced
Merge branch 'main' of github.com:cosmos/cosmos-sdk into kocubinski/1…
kocubinski Jun 5, 2023
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
Prev Previous commit
Next Next commit
adjust depinject test to fail during startup
  • Loading branch information
kocubinski committed Jun 2, 2023
commit 9138f2c88ddd39ebcf10d14f6f49197ed8c6911f
23 changes: 11 additions & 12 deletions tests/integration/tx/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@ package tx
import (
"testing"

bankv1beta1 "cosmossdk.io/api/cosmos/bank/v1beta1"
"cosmossdk.io/depinject"
"cosmossdk.io/log"
"cosmossdk.io/x/tx/signing"
"github.com/stretchr/testify/require"
"google.golang.org/protobuf/proto"

codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/tests/integration/tx/internal/pulsar/testpb"
"github.com/cosmos/cosmos-sdk/testutil/configurator"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
)

func ProvideCustomGetSigners() signing.CustomGetSigner {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, it will be useful if this could be displayed in the docs ref: #16294

return signing.CustomGetSigner{
MsgType: proto.MessageName(&bankv1beta1.SendAuthorization{}),
MsgType: proto.MessageName(&testpb.TestRepeatedFields{}),
Fn: func(msg proto.Message) ([][]byte, error) {
sendAuth := msg.(*bankv1beta1.SendAuthorization)
testMsg := msg.(*testpb.TestRepeatedFields)
// arbitrary logic
signer := sendAuth.AllowList[1]
signer := testMsg.NullableDontOmitempty[1].Value
return [][]byte{[]byte(signer)}, nil
},
}
Expand All @@ -46,14 +46,17 @@ func TestDefineCustomGetSigners(t *testing.T) {
require.NoError(t, err)
require.NotNil(t, interfaceRegistry)

sendAuth := &bankv1beta1.SendAuthorization{
AllowList: []string{"foo", "bar"},
msg := &testpb.TestRepeatedFields{
NullableDontOmitempty: []*testpb.Streng{
{Value: "foo"},
{Value: "bar"},
},
}
signers, err := interfaceRegistry.SigningContext().GetSigners(sendAuth)
signers, err := interfaceRegistry.SigningContext().GetSigners(msg)
require.NoError(t, err)
require.Equal(t, [][]byte{[]byte("bar")}, signers)

// reset without invoker, no custom signer.
// reset providing CustomGetSigners. validation will fail and depinject will return an error
_, err = simtestutil.SetupAtGenesis(
depinject.Configs(
configurator.NewAppConfig(
Expand All @@ -67,9 +70,5 @@ func TestDefineCustomGetSigners(t *testing.T) {
),
&interfaceRegistry,
)
require.NoError(t, err)
require.NotNil(t, interfaceRegistry)

_, err = interfaceRegistry.SigningContext().GetSigners(sendAuth)
require.ErrorContains(t, err, "use DefineCustomGetSigners")
}
Loading