Skip to content

Commit fce446c

Browse files
committed
chore: tweaks
1 parent 8c1d4eb commit fce446c

File tree

4 files changed

+8
-133
lines changed

4 files changed

+8
-133
lines changed

src/tempo/Formatters.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -125,21 +125,9 @@ export function formatTransactionRequest(
125125
account && 'accessKeyAddress' in account
126126
? account.accessKeyAddress
127127
: undefined
128-
const keyAuthorization = rpc.keyAuthorization
129-
? {
130-
...rpc.keyAuthorization,
131-
// FIXME(ox): remove once https://github.com/tempoxyz/tempo/pull/1683 is deployed.
132-
chainId:
133-
rpc.keyAuthorization.chainId === '0x' ||
134-
rpc.keyAuthorization.chainId === '0x0'
135-
? 0
136-
: parseInt(rpc.keyAuthorization.chainId || '0x0', 16),
137-
}
138-
: undefined
139128

140129
return {
141130
...rpc,
142-
...(keyAuthorization ? { keyAuthorization } : {}),
143131
...(keyData ? { keyData } : {}),
144132
...(keyId ? { keyId } : {}),
145133
...(keyType ? { keyType } : {}),

src/tempo/actions/nonce.test.ts

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -81,31 +81,6 @@ describe('getNonce', () => {
8181
})
8282
})
8383

84-
describe('getNonceKeyCount', () => {
85-
test('default', async () => {
86-
// Get active nonce key count for a fresh account
87-
const count = await actions.nonce.getNonceKeyCount(client, {
88-
account: accounts.at(10)!.address,
89-
})
90-
91-
// Fresh account should have 0 active nonce keys
92-
expect(count).toBe(0n)
93-
})
94-
95-
test('behavior: different accounts are independent', async () => {
96-
const count1 = await actions.nonce.getNonceKeyCount(client, {
97-
account: accounts.at(10)!.address,
98-
})
99-
const count2 = await actions.nonce.getNonceKeyCount(client, {
100-
account: accounts.at(11)!.address,
101-
})
102-
103-
// Both should be 0 for fresh accounts
104-
expect(count1).toBe(0n)
105-
expect(count2).toBe(0n)
106-
})
107-
})
108-
10984
describe('watchNonceIncremented', () => {
11085
test('default', async () => {
11186
const events: Array<{
@@ -153,52 +128,3 @@ describe('watchNonceIncremented', () => {
153128
}
154129
})
155130
})
156-
157-
describe('watchActiveKeyCountChanged', () => {
158-
test('default', async () => {
159-
const events: Array<{
160-
args: actions.nonce.watchActiveKeyCountChanged.Args
161-
log: actions.nonce.watchActiveKeyCountChanged.Log
162-
}> = []
163-
164-
const unwatch = actions.nonce.watchActiveKeyCountChanged(client, {
165-
onActiveKeyCountChanged: (args, log) => {
166-
events.push({ args, log })
167-
},
168-
})
169-
170-
const priorKeyCount = await actions.nonce.getNonceKeyCount(client, {
171-
account: account.address,
172-
})
173-
174-
try {
175-
// First use of nonceKey 10 should increment active key count
176-
await actions.token.transferSync(client, {
177-
to: account2.address,
178-
amount: 1n,
179-
token: 1n,
180-
nonceKey: 10n,
181-
nonce: 0,
182-
})
183-
184-
// First use of nonceKey 11 should increment again
185-
await actions.token.transferSync(client, {
186-
to: account2.address,
187-
amount: 1n,
188-
token: 1n,
189-
nonceKey: 11n,
190-
nonce: 0,
191-
})
192-
193-
await setTimeout(1000)
194-
195-
expect(events).toHaveLength(2)
196-
expect(events[0]!.args.account).toBe(account.address)
197-
// Assert the number of new active keys
198-
expect(events[0]!.args.newCount - priorKeyCount).toBe(1n)
199-
expect(events[1]!.args.newCount - priorKeyCount).toBe(2n)
200-
} finally {
201-
unwatch()
202-
}
203-
})
204-
})

src/tempo/actions/nonce.ts

Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -111,27 +111,7 @@ export namespace getNonce {
111111
}
112112

113113
/**
114-
* Gets the number of active nonce keys for an account.
115-
*
116-
* @example
117-
* ```ts
118-
* import { createClient, http } from 'viem'
119-
* import { tempo } from 'tempo.ts/chains'
120-
* import { Actions } from 'tempo.ts/viem'
121-
*
122-
* const client = createClient({
123-
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' }),
124-
* transport: http(),
125-
* })
126-
*
127-
* const count = await Actions.nonce.getNonceKeyCount(client, {
128-
* account: '0x...',
129-
* })
130-
* ```
131-
*
132-
* @param client - Client.
133-
* @param parameters - Parameters.
134-
* @returns The number of active nonce keys.
114+
* @deprecated This function has been deprecated post-AllegroModerato. It will be removed in a future version.
135115
*/
136116
export async function getNonceKeyCount<
137117
chain extends Chain | undefined,
@@ -203,29 +183,7 @@ export namespace getNonceKeyCount {
203183
}
204184

205185
/**
206-
* Watches for nonce incremented events.
207-
*
208-
* @example
209-
* ```ts
210-
* import { createClient, http } from 'viem'
211-
* import { tempo } from 'tempo.ts/chains'
212-
* import { Actions } from 'tempo.ts/viem'
213-
*
214-
* const client = createClient({
215-
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' }),
216-
* transport: http(),
217-
* })
218-
*
219-
* const unwatch = Actions.nonce.watchNonceIncremented(client, {
220-
* onNonceIncremented: (args, log) => {
221-
* console.log('Nonce incremented:', args)
222-
* },
223-
* })
224-
* ```
225-
*
226-
* @param client - Client.
227-
* @param parameters - Parameters.
228-
* @returns A function to unsubscribe from the event.
186+
* @deprecated This function has been deprecated post-AllegroModerato. It will be removed in a future version.
229187
*/
230188
export function watchNonceIncremented<
231189
chain extends Chain | undefined,

src/tempo/chainConfig.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,17 @@ export const chainConfig = {
4141
}
4242

4343
if (phase === 'afterFillParameters') {
44-
// TODO: remove once https://github.com/tempoxyz/tempo/pull/1684 is deployed.
4544
if (typeof request.nonceKey === 'bigint' && request.nonceKey > 0n)
46-
request.gas = (request.gas ?? 0n) + 30_000n
45+
request.gas = (request.gas ?? 0n) + 40_000n
4746
return request as unknown as typeof r
4847
}
4948

5049
request.nonceKey = (() => {
51-
if (typeof request.nonceKey !== 'undefined') return request.nonceKey
50+
if (
51+
typeof request.nonceKey !== 'undefined' &&
52+
request.nonceKey !== 'random'
53+
)
54+
return request.nonceKey
5255

5356
const address = request.account?.address ?? request.from
5457
if (!address) return undefined

0 commit comments

Comments
 (0)