Skip to content

Commit

Permalink
Convert Call[] into permissionless type
Browse files Browse the repository at this point in the history
  • Loading branch information
nickick committed Oct 14, 2024
1 parent d4241ac commit a72862a
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion packages/agw-client/src/actions/sendPrivyTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,25 @@ import type { Call } from '../types/call.js';

const ALLOWED_CHAINS: number[] = [abstractTestnet.id];

interface PermissionlessCall {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
readonly to?: any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
readonly value?: any;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
readonly data?: any;
}

function convertCallsToPermissionlessCalls(
calls?: Call[],
): PermissionlessCall[] {
return (calls || []).map((call) => ({
to: call.target,
value: call.value,
data: call.callData,
}));
}

export async function sendPrivyTransaction<
chain extends ChainEIP712 | undefined = ChainEIP712 | undefined,
account extends Account | undefined = Account | undefined,
Expand Down Expand Up @@ -77,7 +96,11 @@ export async function sendPrivyTransaction<
return client.request(
{
method: 'privy_sendSmartWalletTx',
params: [fromAccount, transaction, calls],
params: [
fromAccount,
transaction,
convertCallsToPermissionlessCalls(calls),
],
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any,
{ retryCount: 0 },
Expand Down

0 comments on commit a72862a

Please sign in to comment.