confio / cosmjs-types

JS and TS types relating to Protocol Buffers used by Cosmos-SDK and other related projects
Apache License 2.0
36 stars 42 forks source link

GrantFee /cosmos.feegrant.v1beta1.MsgGrantAllowance is not executing #46

Closed RuslanGlaznyov closed 2 years ago

RuslanGlaznyov commented 2 years ago

I want to use the grant fee with cosmjs but I get errors

example 1

const grantFeeMsg = {
        typeUrl: '/cosmos.feegrant.v1beta1.MsgGrantAllowance',
        value: {
            granter: accountMain.address,
            /** grantee is the address of the user being granted an allowance of another user's funds. */
            grantee:  accountGrantee.address,
            /** allowance can be any of basic and filtered fee allowance. */
            allowance: BasicAllowance.encode(BasicAllowance.fromPartial({
                spendLimit: [{ denom: 'uatom', amount: '1000' }],
                expiration: Timestamp.fromPartial({
                    seconds: defaultExpiry.unix(),
                    nanos: 0
                })
            })).finish()
            // BasicAllowance.encode()
        }

    }
    const resultExecGrant = await clientMainGrant.signAndBroadcast(accountMain.address, [grantFeeMsg], 'auto');
    console.log(resultExecGrant);

Error: Query failed with (18): unable to resolve type URL : tx parse error: invalid request

example 2

const grantFeeMsg = {
        typeUrl: '/cosmos.feegrant.v1beta1.MsgGrantAllowance',
        value: {
            granter: accountMain.address,
            /** grantee is the address of the user being granted an allowance of another user's funds. */
            grantee:  accountGrantee.address,
            /** allowance can be any of basic and filtered fee allowance. */
        }

    }
    const resultExecGrant = await clientMainGrant.signAndBroadcast(accountMain.address, [grantFeeMsg], 'auto');
    console.log(resultExecGrant);
Error: Query failed with (18): recovered: runtime error: invalid memory address or nil pointer dereference
stack:
goroutine 1716454895 [running]:
runtime/debug.Stack()
        runtime/debug/stack.go:24 +0x65
github.com/cosmos/cosmos-sdk/baseapp.newDefaultRecoveryMiddleware.func1({0x19c2380, 0x3237380})
        github.com/cosmos/cosmos-sdk@v0.45.6/baseapp/recovery.go:71 +0x27
github.com/cosmos/cosmos-sdk/baseapp.newRecoveryMiddleware.func1({0x19c2380?, 0x3237380?})
        github.com/cosmos/cosmos-sdk@v0.45.6/baseapp/recovery.go:39 +0x30
github.com/cosmos/cosmos-sdk/baseapp.processRecovery({0x19c2380, 0x3237380}, 0xc09b9b6240?)
        github.com/cosmos/cosmos-sdk@v0.45.6/baseapp/recovery.go:28 +0x37
github.com/cosmos/cosmos-sdk/baseapp.processRecovery({0x19c2380, 0x3237380}, 0x252a8c0?)
        github.com/cosmos/cosmos-sdk@v0.45.6/baseapp/recovery.go:33 +0x5e
github.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).runTx.func1()
        github.com/cosmos/cosmos-sdk@v0.45.6/baseapp/baseapp.go:608 +0xfd
panic({0x19c2380, 0x3237380})
        runtime/panic.go:838 +0x207
github.com/cosmos/cosmos-sdk/codec/types.(*Any).GetCachedValue(...)
        github.com/cosmos/cosmos-sdk@v0.45.6/codec/types/any.go:113
github.com/cosmos/cosmos-sdk/x/feegrant.MsgGrantAllowance.GetFeeAllowanceI({{0xc0e008d4d0, 0x2d}, {0xc0e008d530, 0x2d}, 0x0})
        github.com/cosmos/cosmos-sdk@v0.45.6/x/feegrant/msgs.go:85 +0x31
github.com/cosmos/cosmos-sdk/x/feegrant.MsgGrantAllowance.ValidateBasic({{0xc0e008d4d0, 0x2d}, {0xc0e008d530, 0x2d}, 0x0})
        github.com/cosmos/cosmos-sdk@v0.45.6/x/feegrant/msgs.go:51 +0x85
github.com/cosmos/cosmos-sdk/baseapp.validateBasicTxMsgs({0xc0ef275290?, 0x1, 0xf0?})
        github.com/cosmos/cosmos-sdk@v0.45.6/baseapp/baseapp.go:527 +0x7a
github.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).runTx(0xc0013b7040, 0x2, {0xc0c00f1860, 0xe8, 0xf0})
        github.com/cosmos/cosmos-sdk@v0.45.6/baseapp/baseapp.go:641 +0x417
github.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).Simulate(0x414307?, {0xc0c00f1860?, 0x1a74040?, 0x1?})
        github.com/cosmos/cosmos-sdk@v0.45.6/baseapp/test_helpers.go:23 +0x2c
github.com/cosmos/cosmos-sdk/x/auth/tx.txServer.Simulate({{{0x0, 0x0, 0x0}, {0x2531e40, 0xc0049c2b80}, {0xc001398cd0, 0xb}, {0x2522288, 0xc0012ceaf0}, {0x252c218, ...}, ...}, ...}, ...)
        github.com/cosmos/cosmos-sdk@v0.45.6/x/auth/tx/service.go:119 +0x129
github.com/cosmos/cosmos-sdk/types/tx._Service_Simulate_Handler({0x1b068c0?, 0xc00343d040}, {0x251e3e8, 0xc06fb75cb0}, 0xc17a0501e0, 0x0)
        github.com/cosmos/cosmos-sdk@v0.45.6/types/tx/service.pb.go:910 +0x170
github.com/cosmos/cosmos-sdk/baseapp.(*GRPCQueryRouter).RegisterService.func1({{0x251e378, 0xc000052060}, {0x252a8c0, 0xc09b8e70c0}, {{0xb, 0x0}, {0xc13ff58460, 0xb}, 0xbe8ab6, {0xea52c4a, ...}, ...}, ...}, ...)
        github.com/cosmos/cosmos-sdk@v0.45.6/baseapp/grpcrouter.go:85 +0x22d
github.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).handleQueryGRPC(0xc0013b7040, 0xc00898bef0, {{0xc08ab22780, 0xeb, 0x1e0}, {0xc0e008c660, 0x23}, 0xbe8ab6, 0x0})
        github.com/cosmos/cosmos-sdk@v0.45.6/baseapp/abci.go:577 +0x1cf
github.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).Query(0xc0013b7040, {{0xc08ab22780, 0xeb, 0x1e0}, {0xc0e008c660, 0x23}, 0xbe8ab6, 0x0})
        github.com/cosmos/cosmos-sdk@v0.45.6/baseapp/abci.go:421 +0x6fd
github.com/tendermint/tendermint/abci/client.(*localClient).QuerySync(0xc001260600, {{0xc08ab22780, 0xeb, 0x1e0}, {0xc0e008c660, 0x23}, 0x0, 0x0})
        github.com/tendermint/tendermint@v0.34.19/abci/client/local_client.go:256 +0x171
github.com/tendermint/tendermint/proxy.(*appConnQuery).QuerySync(0x2?, {{0xc08ab22780, 0xeb, 0x1e0}, {0xc0e008c660, 0x23}, 0x0, 0x0})
        github.com/tendermint/tendermint@v0.34.19/proxy/app_conn.go:159 +0x6e
github.com/tendermint/tendermint/rpc/core.ABCIQuery(0x8?, {0xc0e008c660?, 0xc01aff6600?}, {0xc08ab22780?, 0x4?, 0xc023329650?}, 0x2?, 0x79?)
        github.com/tendermint/tendermint@v0.34.19/rpc/core/abci.go:20 +0xa6
reflect.Value.call({0x19e6320?, 0x22d2010?, 0x80?}, {0x1bf00c4, 0x4}, {0xc09b08b300, 0x5, 0x18?})
        reflect/value.go:556 +0x845
reflect.Value.Call({0x19e6320?, 0x22d2010?, 0x21c?}, {0xc09b08b300, 0x5, 0x5})
        reflect/value.go:339 +0xbf
github.com/tendermint/tendermint/rpc/jsonrpc/server.makeJSONRPCHandler.func1({0x251cd40, 0xc0dcd553b0}, 0xc09a7ae200)
        github.com/tendermint/tendermint@v0.34.19/rpc/jsonrpc/server/http_json_handler.go:96 +0x1075
github.com/tendermint/tendermint/rpc/jsonrpc/server.handleInvalidJSONRPCPaths.func1({0x251cd40?, 0xc0dcd553b0?}, 0x7fd483597288?)
        github.com/tendermint/tendermint@v0.34.19/rpc/jsonrpc/server/http_json_handler.go:122 +0x5d
net/http.HandlerFunc.ServeHTTP(0xc09b895740?, {0x251cd40?, 0xc0dcd553b0?}, 0xc02afb1878?)
        net/http/server.go:2084 +0x2f
net/http.(*ServeMux).ServeHTTP(0x160?, {0x251cd40, 0xc0dcd553b0}, 0xc09a7ae200)
        net/http/server.go:2462 +0x149
github.com/tendermint/tendermint/rpc/jsonrpc/server.maxBytesHandler.ServeHTTP({{0x2507da0?, 0xc01f8f0040?}, 0x414307?}, {0x251cd40?, 0xc0dcd553b0}, 0xc09a7ae200)
        github.com/tendermint/tendermint@v0.34.19/rpc/jsonrpc/server/http_server.go:236 +0x122
github.com/tendermint/tendermint/rpc/jsonrpc/server.RecoverAndLogHandler.func1({0x251d3a0?, 0xc0909d20e0}, 0xc09a7ae200)
        github.com/tendermint/tendermint@v0.34.19/rpc/jsonrpc/server/http_server.go:209 +0x37f
net/http.HandlerFunc.ServeHTTP(0x0?, {0x251d3a0?, 0xc0909d20e0?}, 0x413fa5?)
        net/http/server.go:2084 +0x2f
net/http.serverHandler.ServeHTTP({0x250c5c8?}, {0x251d3a0, 0xc0909d20e0}, 0xc09a7ae200)
        net/http/server.go:2916 +0x43b
net/http.(*conn).serve(0xc138ff4460, {0x251e3e8, 0xc01eb74150})
        net/http/server.go:1966 +0x5d7
created by net/http.(*Server).Serve
        net/http/server.go:3071 +0x4db
: panic: invalid request
    at QueryClient.queryUnverified (/Users/ruslanglaznyov/Documents/test-grant/node_modules/@cosmjs/stargate/build/queryclient/queryclient.js:107:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Object.simulate (/Users/ruslanglaznyov/Documents/test-grant/node_modules/@cosmjs/stargate/build/modules/tx/queries.js:48:34)
    at async SigningStargateClient.simulate (/Users/ruslanglaznyov/Documents/test-grant/node_modules/@cosmjs/stargate/build/signingstargateclient.js:89:29)
    at async SigningStargateClient.signAndBroadcast (/Users/ruslanglaznyov/Documents/test-grant/node_modules/@cosmjs/stargate/build/signingstargateclient.js:160:35)
    at async file:///Users/ruslanglaznyov/Documents/test-grant/index.js:146:29