Skip to content

Commit dbf451b

Browse files
Update gas station contract addresses and modify intent builder types for consistency
1 parent 82e242d commit dbf451b

File tree

4 files changed

+31
-54
lines changed

4 files changed

+31
-54
lines changed

packages/gas-station/src/abi/gas-station.ts

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,15 @@ export const gasStationAbi = [
88
},
99
{ inputs: [], name: "ExecutionFailed", type: "error" },
1010
{ inputs: [], name: "InvalidFunctionSelector", type: "error" },
11-
{ inputs: [], name: "NoEthAllowed", type: "error" },
1211
{ inputs: [], name: "NotDelegated", type: "error" },
1312
{ stateMutability: "nonpayable", type: "fallback" },
13+
{
14+
inputs: [],
15+
name: "TK_GAS_DELEGATE",
16+
outputs: [{ internalType: "address", name: "", type: "address" }],
17+
stateMutability: "view",
18+
type: "function",
19+
},
1420
{
1521
inputs: [
1622
{ internalType: "address", name: "_target", type: "address" },
@@ -152,26 +158,6 @@ export const gasStationAbi = [
152158
stateMutability: "view",
153159
type: "function",
154160
},
155-
{
156-
inputs: [
157-
{ internalType: "address", name: "_targetEoA", type: "address" },
158-
{ internalType: "uint128", name: "_nonce", type: "uint128" },
159-
{
160-
components: [
161-
{ internalType: "address", name: "to", type: "address" },
162-
{ internalType: "uint256", name: "value", type: "uint256" },
163-
{ internalType: "bytes", name: "data", type: "bytes" },
164-
],
165-
internalType: "struct IBatchExecution.Call[]",
166-
name: "_calls",
167-
type: "tuple[]",
168-
},
169-
],
170-
name: "hashBatchExecution",
171-
outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
172-
stateMutability: "view",
173-
type: "function",
174-
},
175161
{
176162
inputs: [
177163
{ internalType: "address", name: "_targetEoA", type: "address" },
@@ -207,7 +193,6 @@ export const gasStationAbi = [
207193
inputs: [
208194
{ internalType: "address", name: "_targetEoA", type: "address" },
209195
{ internalType: "uint128", name: "_counter", type: "uint128" },
210-
{ internalType: "address", name: "_sender", type: "address" },
211196
],
212197
name: "hashBurnSessionCounter",
213198
outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
@@ -248,13 +233,6 @@ export const gasStationAbi = [
248233
stateMutability: "view",
249234
type: "function",
250235
},
251-
{
252-
inputs: [],
253-
name: "tkGasDelegate",
254-
outputs: [{ internalType: "address", name: "", type: "address" }],
255-
stateMutability: "view",
256-
type: "function",
257-
},
258236
{
259237
inputs: [
260238
{ internalType: "address", name: "_targetEoA", type: "address" },
@@ -266,5 +244,4 @@ export const gasStationAbi = [
266244
stateMutability: "view",
267245
type: "function",
268246
},
269-
{ stateMutability: "payable", type: "receive" },
270247
] as const;

packages/gas-station/src/config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import { base, mainnet, sepolia } from "viem/chains";
44

55
// Default contract addresses (deterministically deployed across all chains)
66
export const DEFAULT_DELEGATE_CONTRACT: Hex =
7-
"0xC2a37Ee08cAc3778d9d05FF0a93FD5B553C77E3a";
7+
"0x000066a00056CD44008768E2aF00696e19A30084";
88
export const DEFAULT_EXECUTION_CONTRACT: Hex =
9-
"0x4ece92b06C7d2d99d87f052E0Fca47Fb180c3348";
9+
"0x00000000008c57a1CE37836a5e9d36759D070d8c";
1010

1111
// Type definitions
1212
export interface GasStationConfig {

packages/gas-station/src/intentBuilder.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -145,23 +145,23 @@ export class IntentBuilder {
145145
verifyingContract: this.config.eoaAddress,
146146
};
147147

148-
// Original: keccak256("Execution(uint128 nonce,uint32 deadline,address outputContract,uint256 ethAmount,bytes arguments)")
148+
// keccak256("Execution(uint128 nonce,uint32 deadline,address to,uint256 value,bytes data)")
149149
const types = {
150150
Execution: [
151151
{ name: "nonce", type: "uint128" },
152152
{ name: "deadline", type: "uint32" },
153-
{ name: "outputContract", type: "address" },
154-
{ name: "ethAmount", type: "uint256" },
155-
{ name: "arguments", type: "bytes" },
153+
{ name: "to", type: "address" },
154+
{ name: "value", type: "uint256" },
155+
{ name: "data", type: "bytes" },
156156
],
157157
};
158158

159159
const message = {
160160
nonce,
161161
deadline,
162-
outputContract: this.outputContract,
163-
ethAmount: this.ethAmount,
164-
arguments: this.callData,
162+
to: this.outputContract,
163+
value: this.ethAmount,
164+
data: this.callData,
165165
};
166166

167167
const signature = await this.config.eoaWalletClient.signTypedData({
@@ -213,17 +213,17 @@ export class IntentBuilder {
213213
};
214214

215215
// Based on hashApproveThenExecute from the contract
216-
// keccak256("ApproveThenExecute(uint128 nonce,uint32 deadline,address erc20Contract,address spender,uint256 approveAmount,address outputContract,uint256 ethAmount,bytes arguments)")
216+
// keccak256("ApproveThenExecute(uint128 nonce,uint32 deadline,address erc20Contract,address spender,uint256 approveAmount,address to,uint256 value,bytes data)")
217217
const types = {
218218
ApproveThenExecute: [
219219
{ name: "nonce", type: "uint128" },
220220
{ name: "deadline", type: "uint32" },
221221
{ name: "erc20Contract", type: "address" },
222222
{ name: "spender", type: "address" },
223223
{ name: "approveAmount", type: "uint256" },
224-
{ name: "outputContract", type: "address" },
225-
{ name: "ethAmount", type: "uint256" },
226-
{ name: "arguments", type: "bytes" },
224+
{ name: "to", type: "address" },
225+
{ name: "value", type: "uint256" },
226+
{ name: "data", type: "bytes" },
227227
],
228228
};
229229

@@ -233,9 +233,9 @@ export class IntentBuilder {
233233
erc20Contract: erc20Address,
234234
spender,
235235
approveAmount,
236-
outputContract: this.outputContract,
237-
ethAmount: this.ethAmount,
238-
arguments: this.callData,
236+
to: this.outputContract,
237+
value: this.ethAmount,
238+
data: this.callData,
239239
};
240240

241241
const signature = await this.config.eoaWalletClient.signTypedData({

packages/gas-station/src/policyUtils.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import type { Hex } from "viem";
1515
* @param config.customConsensus - Optional custom consensus expression (overrides eoaUserId and additionalApprovers)
1616
* @param config.restrictions - Signing restrictions
1717
* @param config.restrictions.allowedContracts - Whitelist of contract addresses EOA can sign intents for
18-
* @param config.restrictions.disallowEthTransfer - Whether to disallow ETH transfers (if true, ethAmount must be 0)
18+
* @param config.restrictions.disallowEthTransfer - Whether to disallow ETH transfers (if true, value must be 0)
1919
* @param config.policyName - Optional policy name
2020
* @returns Policy object ready to submit to Turnkey createPolicy API
2121
*
@@ -39,9 +39,9 @@ import type { Hex } from "viem";
3939
* consensus: "approvers.any(user, user.id == 'user-456')",
4040
* condition: "activity.resource == 'PRIVATE_KEY' && activity.action == 'SIGN' && " +
4141
* "eth.eip_712.primary_type == 'Execution' && " +
42-
* "(eth.eip_712.message['outputContract'] == '0x833...usdc' || " +
43-
* "eth.eip_712.message['outputContract'] == '0x6b1...dai') && " +
44-
* "eth.eip_712.message['ethAmount'] == '0'",
42+
* "(eth.eip_712.message['to'] == '0x833...usdc' || " +
43+
* "eth.eip_712.message['to'] == '0x6b1...dai') && " +
44+
* "eth.eip_712.message['value'] == '0'",
4545
* notes: "Restricts which EIP-712 intents the EOA can sign for gas station execution"
4646
* }
4747
*
@@ -66,8 +66,8 @@ import type { Hex } from "viem";
6666
* "approvers.any(user, user.id == 'backup-user-789')",
6767
* condition: "activity.resource == 'PRIVATE_KEY' && activity.action == 'SIGN' && " +
6868
* "eth.eip_712.primary_type == 'Execution' && " +
69-
* "(eth.eip_712.message['outputContract'] == '0x833...usdc') && " +
70-
* "eth.eip_712.message['ethAmount'] == '0'",
69+
* "(eth.eip_712.message['to'] == '0x833...usdc') && " +
70+
* "eth.eip_712.message['value'] == '0'",
7171
* notes: "Restricts which EIP-712 intents the EOA can sign for gas station execution"
7272
* }
7373
*
@@ -109,14 +109,14 @@ export function buildIntentSigningPolicy(config: {
109109
// Convert to lowercase for case-insensitive comparison
110110
const contractConditions = config.restrictions.allowedContracts
111111
.map(
112-
(c) => `eth.eip_712.message['outputContract'] == '${c.toLowerCase()}'`,
112+
(c) => `eth.eip_712.message['to'] == '${c.toLowerCase()}'`,
113113
)
114114
.join(" || ");
115115
conditions.push(`(${contractConditions})`);
116116
}
117117

118118
if (!!config.restrictions?.disallowEthTransfer) {
119-
conditions.push(`eth.eip_712.message['ethAmount'] == '0'`);
119+
conditions.push(`eth.eip_712.message['value'] == '0'`);
120120
}
121121

122122
// Build consensus expression

0 commit comments

Comments
 (0)