Closed pyramation closed 1 year ago
other examples that have simple flow https://gist.github.com/fadeev/a4981eff1cf3a805ef10e25313d5f2b7
Here is the original index that impelled us to customize the signing client:
const { config } = require('./config/config.js');
const { generateSignerWallet } = require('./signer.js');
const {
osmosis,
ibc,
cosmos,
getSigningOsmosisClient,
signAndBroadcast,
FEE_VALUES
} = require('osmojs');
const { coin, coins } = require('@cosmjs/amino');
const {
multiSend,
send
} = cosmos.bank.v1beta1.MessageComposer.fromPartial;
/* TEST */
const amount = coins(1, 'uosmo');
const fee = FEE_VALUES.osmosis.swapExactAmountIn;
(async () => {
const signer = await generateSignerWallet("osmosis", config.mnemonic).then((signer) => { return signer; });
const address = await signer.getAccounts().then((accounts) => { return accounts[0].address; });
const rpcEndpoint = config.rpcEndpoint;
const client = await getSigningOsmosisClient({ rpcEndpoint, signer });
const msg = send({
fromAddress: address,
toAddress: "osmo1REDACTED",
amount: amount
});
console.dir(msg, { depth: null });
/*
prints the following:
{
typeUrl: '/cosmos.bank.v1beta1.MsgSend',
value: {
fromAddress: 'osmo1REDACTED',
toAddress: 'osmo1osmo1REDACTED',
amount: [ { denom: 'uosmo', amount: '1' } ]
}
}
*/
const res = await signAndBroadcast({
client,
chainId: 'osmosis-1',
address: address,
msgs: [msg],
fee,
memo: config.default_memo
});
/*
nodejs crashes with error:
C:\dev\user\test\node_modules\@cosmjs\stargate\build\aminotypes.js:21
throw new Error(`Type URL '${typeUrl}' does not exist in the Amino message type register. ` +
^
Error: Type URL '/cosmos.bank.v1beta1.MsgSend' does not exist in the Amino message type register. If you need support for this message type, you can pass in additional entries to the AminoTypes constructor. If you think this message type should be included by default, please open an issue at https://github.com/cosmos/cosmjs/issues.
at AminoTypes.toAmino (C:\dev\user\test\node_modules\@cosmjs\stargate\build\aminotypes.js:21:19)
at C:\dev\user\test\node_modules\@cosmjs\stargate\build\signingstargateclient.js:207:60
at Array.map (<anonymous>)
at SigningStargateClient.signAmino (C:\dev\user\test\node_modules\@cosmjs\stargate\build\signingstargateclient.js:207:31)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
*/
console.log(res);
})();
I'm actually proposing we make multi-send only allow one sender haha: https://github.com/cosmos/cosmos-sdk/issues/12601
we may also need to do something special with the signingCosmosClient to make this easier:
an example from the community: