telescope
telescope copied to clipboard
Create msgGrant have error "tx parse error"
I'm following this doc (https://www.npmjs.com/package/@cosmology/telescope#grpc-gateway-client) to create a multisig msg for typeUrl: "/cosmos.authz.v1beta1.MsgGrant" and we have typeUrl: "/cosmwasm.wasm.v1.ContractExecutionAuthorization", in it. But when I boadcast my transaction, it emits this error: "tx parse error". I'm using your latest version. Where am I wrong here? Can you give me a example for this? Here is the code:
window.keplr.defaultOptions = {
sign: {
preferNoSetMemo: true,
preferNoSetFee: true,
disableBalanceCheck: true,
},
};
const offlineSigner = window.getOfflineSignerOnlyAmino(
chain.chain_id
);
const signAccount = await getSequence(chain.api, multisigID)
const { grant } = cosmos.authz.v1beta1.MessageComposer.withTypeUrl;
const msg = grant({
granter: 'migaloo17gayusvse9e9espd0ym66eju5jymshsz6etlx0',
grantee: 'migaloo1g77s6rh7fgdfcwgcxpwwzr5ujamf302krvua0v',
grant: {
authorization: cosmwasm.wasm.v1.ContractExecutionAuthorization.toAminoMsg({
grants: [
{
contract: 'migaloo14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s58v48z',
limit: cosmwasm.wasm.v1.CombinedLimit.toAminoMsg({
callsRemaining: BigInt("100"),
amounts: [
{
denom: "uwhale",
amount: "250",
}
]
}),
filter: cosmwasm.wasm.v1.AcceptedMessageKeysFilter.toAminoMsg({
keys: ['create_pair']
})
}
]
}),
expiration: new Date(Date.now() + 60 * 60 * 24 * 7)
}
})
console.log(msg);
// const signingClient = await getCustomClient(types, offlineSigner);
const signingClient = await getSigningCosmosClient({
rpcEndpoint: "http://localhost:26657",
signer: offlineSigner
});
const signerData = {
accountNumber: parseInt(signAccount.account_number, 10),
sequence: parseInt(signAccount.sequence, 10),
chainId: chain.chain_id,
};
const { bodyBytes, signatures } = await signingClient.sign(
account.bech32Address,
[msg],
tx.fee,
tx.memo,
signerData
);
const pubkey = JSON.parse(multisig.pubkeyJSON)
const gasLimit = 200000;
const signedTx = makeMultisignedTx(
JSON.parse(pubkey),
parseInt(signAccount.sequence, 10),
{
amount: coins(2000, "uwhale"),
gas: gasLimit.toString(),
},
bodyBytes,
new Map([
[account.bech32Address, signatures[0]]
])
);
const broadcaster = await StargateClient.connect(chain.rpc);
const result = await broadcaster.broadcastTx(
Uint8Array.from(TxRaw.encode(signedTx).finish())
);
console.log(result);
return
Hi, Thank you for the feedback!
We tested Grant and Revoke functions and passed in this test: https://github.com/cosmology-tech/telescope/blob/main/packages/starship/tests/v1/authz.test.ts
The test's using some features that we recently upgraded and we'll update docs very soon: https://github.com/cosmology-tech/telescope/blob/a6f00deb22d3a41a7b8c832b750ec078328014f6/packages/starship/scripts/codegen.js#L104
Hope these make sense, any problem please let me know.
Thank you very much!
Explained new options that matters:
telescope({
options: {
//enable some new misc features
env: 'v-next',
...
interfaces: {
enabled: true,
//enable better handling of polymorphic fields(with accepted_interfaces) like authorization
useGlobalDecoderRegistry: true,
useUnionTypes: true
},
prototypes: {
enabled: true,
//recommended to have those type urls inside codecs
addTypeUrlToObjects: true,
addTypeUrlToDecoders: true,
addAminoTypeToObjects: true,
...
methods: {
encode: true,
decode: true,
fromJSON: true,
toJSON: true,
fromPartial: true,
....
toAmino: true,
fromAmino: true,
toProto: true,
fromProto: true
},
...
typingsFormat: {
...
// will create a type for telescope generated codecs
useTelescopeGeneratedType: true
}
},
...
stargateClients: {
enabled: true,
includeCosmosDefaultTypes: true,
// create tx client for easier sign and broadcast
addGetTxRpc: true
},
...
rpcClients: {
enabled: true,
// for user easier to create query clients and tx clients
extensions: true,
...
// auto decide using tm34 or tm37, etc
useConnectComet: true,
...
// create valid Tx functions
serviceImplement: {
Msg: {
type: 'Tx'
}
},
...
},
aminoEncoding: {
enabled: true
}
}
})
Hi. Thanks for your reply. I can create msgGrant with single signature using proto signing but not multisignature case. And I think that the sdk require direct signing for single signature transaction but amino signing for multi signature transaction. I tried both direct and amino and it fails. So can you have a test for multi signature case?
Hi. Thanks for your reply. I can create msgGrant with single signature using proto signing but not multisignature case. And I think that the sdk require direct signing for single signature transaction but amino signing for multi signature transaction. I tried both direct and amino and it fails. So can you have a test for multi signature case?
Ok, we'll give it a try in these days!
So do you have any news? I think the problem here is how the sub typeurl is encoded in amino-json sign mode and the sdk don't understand it. I try many ways to encode it but nothing work.
So do you have any news? I think the problem here is how the sub typeurl is encoded in amino-json sign mode and the sdk don't understand it. I try many ways to encode it but nothing work.
Thx! recently we've had some clues for this, will try to fix asap!