Skip to content

Commit

Permalink
Drop prepaid option in useSendMessage hook (#1445)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitayutanov authored Nov 1, 2023
1 parent 0bb61de commit 3390569
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion utils/gear-hooks/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gear-js/react-hooks",
"version": "0.9.1",
"version": "0.9.2",
"description": "React hooks used across Gear applications",
"author": "Gear Technologies",
"license": "GPL-3.0",
Expand Down
8 changes: 3 additions & 5 deletions utils/gear-hooks/src/hooks/api/useSendMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type SendMessageOptions = {
onError?: () => void;
};

type VaraSendMessageOptions = Omit<SendMessageOptions, 'keepAlive' | 'withVoucher'> & { prepaid?: boolean };
type VaraSendMessageOptions = Omit<SendMessageOptions, 'keepAlive'>;

function useSendMessage(
destination: HexString,
Expand Down Expand Up @@ -107,7 +107,7 @@ function useSendMessage(

const alertId = disableAlerts ? '' : alert.loading('Sign In', { title });

const { payload, gasLimit, value = 0, onSuccess, onInBlock, onError } = args;
const { payload, gasLimit, value = 0, withVoucher = false, onSuccess, onInBlock, onError } = args;
const { address, decodedAddress, meta } = account;
const { source } = meta;

Expand All @@ -116,8 +116,7 @@ function useSendMessage(
let message: IMessageSendOptions | VaraMessageSendOptions;

if (isVaraVersion) {
const prepaid = 'prepaid' in args ? args.prepaid : false;
message = { ...baseMessage, prepaid, account: prepaid ? decodedAddress : undefined };
message = { ...baseMessage, prepaid: withVoucher, account: withVoucher ? decodedAddress : undefined };
} else {
const keepAlive = 'keepAlive' in args ? args.keepAlive : false;
message = { ...baseMessage, keepAlive };
Expand All @@ -131,7 +130,6 @@ function useSendMessage(
extrinsic = sendExtrinsic;
} else {
// TODO: voucher call into standalone hook?
const withVoucher = 'withVoucher' in args ? args.withVoucher : false;
extrinsic = withVoucher ? api.voucher.call({ SendMessage: sendExtrinsic }) : sendExtrinsic;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function useSendMessageHandler(
const calculateGas = useHandleCalculateGas(destination, metadata);
const sendMessage = useSendMessage(destination, metadata, options);

return (args: Omit<SendMessageOptions | VaraSendMessageOptions, 'gasLimit'>) => {
return (args: Omit<SendMessageOptions, 'gasLimit'> | Omit<VaraSendMessageOptions, 'gasLimit'>) => {
if (!isApiReady) throw new Error('API is not initialized');

const { payload, value } = args;
Expand Down

0 comments on commit 3390569

Please sign in to comment.