Skip to content

Commit

Permalink
feat: add gas property to contract transaction (#309)
Browse files Browse the repository at this point in the history
* add gas to contract transaction

* update docs for gas on contract transaction

* changeset

* fix type for gas

* Update src/utils/getTransactionContext.ts

* Update .changeset/gold-books-kiss.md

* Update site/pages/reference/frog-transaction-response.mdx

* Update src/types/transaction.ts

* chore: format

---------

Co-authored-by: wigga <[email protected]>
  • Loading branch information
tmm and pahhh-blo authored May 9, 2024
1 parent faae81e commit 7fedd5a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/gold-books-kiss.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"frog": patch
---

Added gas limit for contract transactions
9 changes: 5 additions & 4 deletions site/pages/reference/frog-transaction-response.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -290,12 +290,13 @@ import { Frog, parseEther } from 'frog'

export const app = new Frog()

app.transaction('/send-ether', (c) => {
return c.send({
app.transaction('/mint', (c) => {
return c.contract({
abi,
chainId: 'eip155:10',
gas: 100_000n, // [!code focus]
to: '0xd2135CfB216b74109775236E36d4b433F1DF507B',
value: parseEther('1'),
functionName: 'mint',
to: '0xd2135CfB216b74109775236E36d4b433F1DF507B',
})
})
```
Expand Down
2 changes: 1 addition & 1 deletion src/types/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export type ContractTransactionParameters<
///
allFunctionNames = ContractFunctionName<abi, 'nonpayable' | 'payable'>,
allArgs = ContractFunctionArgs<abi, 'nonpayable' | 'payable', functionName>,
> = Pick<SendTransactionParameters, 'chainId' | 'to'> & {
> = Pick<SendTransactionParameters, 'chainId' | 'gas' | 'to'> & {
/** Contract ABI. */
abi: abi
/** Contract function arguments. */
Expand Down
13 changes: 11 additions & 2 deletions src/utils/getTransactionContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,16 @@ export function getTransactionContext<
buttonIndex: frameData?.buttonIndex,
buttonValue,
contract(parameters) {
const { abi, chainId, functionName, to, args, attribution, value } =
parameters
const {
abi,
chainId,
functionName,
gas,
to,
args,
attribution,
value,
} = parameters

const abiItem = getAbiItem({
abi: abi,
Expand All @@ -89,6 +97,7 @@ export function getTransactionContext<
args,
functionName,
} as EncodeFunctionDataParameters),
gas,
to,
value,
})
Expand Down

0 comments on commit 7fedd5a

Please sign in to comment.