Skip to content

Commit 8cd4fa8

Browse files
authored
fix: snip29 - timeBounds seconds (number), public preparePaymasterTransaction (#1408)
* fix: time bounds are now in seconds * fix: preparePaymasterTransaction is now public * docs: add time bounds comments * fix: bump types-js * fix: executeAfter is optional -> execute immediately
1 parent 9e5c740 commit 8cd4fa8

File tree

6 files changed

+17
-17
lines changed

6 files changed

+17
-17
lines changed

package-lock.json

Lines changed: 4 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
"lossless-json": "^4.0.1",
107107
"pako": "^2.0.4",
108108
"@starknet-io/starknet-types-07": "npm:@starknet-io/types-js@~0.7.10",
109-
"@starknet-io/starknet-types-08": "npm:@starknet-io/types-js@~0.8.3",
109+
"@starknet-io/starknet-types-08": "npm:@starknet-io/types-js@~0.8.4",
110110
"ts-mixer": "^6.0.3"
111111
},
112112
"engines": {

src/account/default.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ export class Account extends Provider implements AccountInterface {
455455
return preparedTransaction.fee;
456456
}
457457

458-
private async preparePaymasterTransaction(
458+
public async preparePaymasterTransaction(
459459
preparedTransaction: PreparedTransaction
460460
): Promise<ExecutableUserTransaction> {
461461
let transaction: ExecutableUserTransaction;

src/account/interface.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,9 @@ export abstract class AccountInterface extends ProviderInterface {
268268
* - calldata - (defaults to []) the calldata
269269
*
270270
* @param paymasterDetails the paymaster details containing:
271-
* - feeMode - the fee mode
271+
* - feeMode - the fee mode (sponsored or default)
272272
* - deploymentData - the deployment data (optional)
273-
* - timeBounds - the time bounds (optional)
273+
* - timeBounds - the time bounds when the transaction is valid (optional) - executeAfter and executeBefore expected to be in seconds (BLOCK_TIMESTAMP)
274274
*
275275
* @param maxFeeInGasToken - the max fee acceptable to pay in gas token (optional)
276276
*

src/paymaster/rpc.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,18 @@ const convertFEE_MODE = (feeMode: PAYMASTER_API.FEE_MODE): FeeMode => {
4545
};
4646

4747
const convertTimeBounds = (timeBounds?: PaymasterTimeBounds): TIME_BOUNDS | undefined =>
48-
timeBounds && timeBounds.executeAfter && timeBounds.executeBefore
48+
timeBounds
4949
? {
50-
execute_after: timeBounds.executeAfter.getTime().toString(),
51-
execute_before: timeBounds.executeBefore.getTime().toString(),
50+
execute_after: timeBounds.executeAfter || 1, // If executeAfter is not provided, set it to 1, meaning the transaction can be executed immediately
51+
execute_before: timeBounds.executeBefore,
5252
}
5353
: undefined;
5454

5555
const convertTIME_BOUNDS = (timeBounds?: TIME_BOUNDS): PaymasterTimeBounds | undefined =>
56-
timeBounds && timeBounds.execute_after && timeBounds.execute_before
56+
timeBounds
5757
? {
58-
executeAfter: new Date(timeBounds.execute_after),
59-
executeBefore: new Date(timeBounds.execute_before),
58+
executeAfter: timeBounds.execute_after,
59+
executeBefore: timeBounds.execute_before,
6060
}
6161
: undefined;
6262

src/types/paymaster/response.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ export type ExecutionParameters = {
9393
timeBounds?: PaymasterTimeBounds;
9494
};
9595

96+
// executeBefore & executeAfter are in seconds, and is compared to the current block timestamp (see https://docs.starknet.io/architecture-and-concepts/network-architecture/block-structure/)
9697
export interface PaymasterTimeBounds {
97-
executeAfter?: Date;
98-
executeBefore?: Date;
98+
executeAfter?: number; // executeAfter is optional, if not provided, it will be set to 1, meaning the transaction can be executed immediately
99+
executeBefore: number; // executeBefore is mandatory if timeBounds is provided
99100
}

0 commit comments

Comments
 (0)