You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/**
* common helper options for generated helper functions.
* For getting signingClient;
* Or using chainName for getting signingClient.
*/
class HelperOptions {
signingClient?: SigningClient;
chainName?: string;
}
hook(generated):
// generated react hook helper function for sending tokens
const useSend = (options: HelperOptions) => {
// getting signingClient from chainName
const { signingClient } = useChain(options.chainName ?? '');
let client = options.signingClient ?? signingClient;
if (!client) {
return null;
}
// register all related encoders and converters
// at this case, we only need MsgSend
signingClient?.addEncoders(toEncoders(MsgSend));
signingClient?.addConverters(toConverters(MsgSend));
// return the actual send function
return async (
signerAddress: string,
message: MsgSend,
fee: StdFee | 'auto' = 'auto',
memo: string = ''
): Promise<DeliverTxResponse> => {
const data = [
{
typeUrl: MsgSend.typeUrl,
value: message,
},
];
return signingClient.signAndBroadcast!(signerAddress, data, fee, memo);
};
};
leaner helper functions need to generate for smaller bundle size.
cca poc:
https://github.com/cosmology-tech/create-cosmos-app/blob/feat/helpers-poc/examples/interchainjs/pages/helpers.tsx
util:
hook(generated):
usage:
The text was updated successfully, but these errors were encountered: