tempo.ts 0.7.6 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +32 -0
- package/dist/chains.d.ts +6 -20
- package/dist/chains.d.ts.map +1 -1
- package/dist/chains.js +14 -15
- package/dist/chains.js.map +1 -1
- package/dist/ox/KeyAuthorization.d.ts +356 -0
- package/dist/ox/KeyAuthorization.d.ts.map +1 -0
- package/dist/ox/KeyAuthorization.js +360 -0
- package/dist/ox/KeyAuthorization.js.map +1 -0
- package/dist/ox/SignatureEnvelope.d.ts +21 -6
- package/dist/ox/SignatureEnvelope.d.ts.map +1 -1
- package/dist/ox/SignatureEnvelope.js +43 -3
- package/dist/ox/SignatureEnvelope.js.map +1 -1
- package/dist/ox/Transaction.d.ts +5 -1
- package/dist/ox/Transaction.d.ts.map +1 -1
- package/dist/ox/Transaction.js +5 -0
- package/dist/ox/Transaction.js.map +1 -1
- package/dist/ox/TransactionEnvelopeAA.d.ts +9 -0
- package/dist/ox/TransactionEnvelopeAA.d.ts.map +1 -1
- package/dist/ox/TransactionEnvelopeAA.js +17 -4
- package/dist/ox/TransactionEnvelopeAA.js.map +1 -1
- package/dist/ox/TransactionRequest.d.ts +7 -1
- package/dist/ox/TransactionRequest.d.ts.map +1 -1
- package/dist/ox/TransactionRequest.js +12 -0
- package/dist/ox/TransactionRequest.js.map +1 -1
- package/dist/ox/index.d.ts +1 -0
- package/dist/ox/index.d.ts.map +1 -1
- package/dist/ox/index.js +1 -0
- package/dist/ox/index.js.map +1 -1
- package/dist/prool/Instance.js +1 -1
- package/dist/prool/Instance.js.map +1 -1
- package/{src/prool/internal → dist/prool}/chain.json +4 -2
- package/dist/viem/Abis.d.ts +319 -6
- package/dist/viem/Abis.d.ts.map +1 -1
- package/dist/viem/Abis.js +199 -7
- package/dist/viem/Abis.js.map +1 -1
- package/dist/viem/Account.d.ts +103 -14
- package/dist/viem/Account.d.ts.map +1 -1
- package/dist/viem/Account.js +177 -23
- package/dist/viem/Account.js.map +1 -1
- package/dist/viem/Actions/account.d.ts.map +1 -1
- package/dist/viem/Actions/account.js +4 -5
- package/dist/viem/Actions/account.js.map +1 -1
- package/dist/viem/Actions/amm.d.ts +72 -0
- package/dist/viem/Actions/amm.d.ts.map +1 -1
- package/dist/viem/Actions/dex.d.ts +156 -4
- package/dist/viem/Actions/dex.d.ts.map +1 -1
- package/dist/viem/Actions/fee.d.ts +4 -0
- package/dist/viem/Actions/fee.d.ts.map +1 -1
- package/dist/viem/Actions/reward.d.ts +158 -0
- package/dist/viem/Actions/reward.d.ts.map +1 -1
- package/dist/viem/Actions/reward.js +54 -0
- package/dist/viem/Actions/reward.js.map +1 -1
- package/dist/viem/Actions/token.d.ts +585 -0
- package/dist/viem/Actions/token.d.ts.map +1 -1
- package/dist/viem/Actions/token.js +2 -2
- package/dist/viem/Actions/token.js.map +1 -1
- package/dist/viem/Addresses.d.ts +1 -1
- package/dist/viem/Addresses.d.ts.map +1 -1
- package/dist/viem/Addresses.js +1 -1
- package/dist/viem/Addresses.js.map +1 -1
- package/dist/viem/Chain.d.ts +35 -0
- package/dist/viem/Chain.d.ts.map +1 -1
- package/dist/viem/Chain.js +37 -0
- package/dist/viem/Chain.js.map +1 -1
- package/dist/viem/Decorator.d.ts +74 -0
- package/dist/viem/Decorator.d.ts.map +1 -1
- package/dist/viem/Decorator.js +3 -0
- package/dist/viem/Decorator.js.map +1 -1
- package/dist/viem/Formatters.d.ts.map +1 -1
- package/dist/viem/Formatters.js +8 -7
- package/dist/viem/Formatters.js.map +1 -1
- package/dist/viem/Storage.d.ts +1 -0
- package/dist/viem/Storage.d.ts.map +1 -1
- package/dist/viem/Storage.js +21 -0
- package/dist/viem/Storage.js.map +1 -1
- package/dist/viem/TokenIds.d.ts +1 -1
- package/dist/viem/TokenIds.d.ts.map +1 -1
- package/dist/viem/TokenIds.js +1 -1
- package/dist/viem/TokenIds.js.map +1 -1
- package/dist/viem/Transaction.d.ts +9 -1
- package/dist/viem/Transaction.d.ts.map +1 -1
- package/dist/viem/Transaction.js +2 -1
- package/dist/viem/Transaction.js.map +1 -1
- package/dist/viem/WebAuthnP256.d.ts +4 -1
- package/dist/viem/WebAuthnP256.d.ts.map +1 -1
- package/dist/viem/WebAuthnP256.js +3 -1
- package/dist/viem/WebAuthnP256.js.map +1 -1
- package/dist/wagmi/Actions/reward.d.ts +44 -0
- package/dist/wagmi/Actions/reward.d.ts.map +1 -1
- package/dist/wagmi/Actions/reward.js +49 -0
- package/dist/wagmi/Actions/reward.js.map +1 -1
- package/dist/wagmi/Connector.d.ts +25 -8
- package/dist/wagmi/Connector.d.ts.map +1 -1
- package/dist/wagmi/Connector.js +120 -27
- package/dist/wagmi/Connector.js.map +1 -1
- package/dist/wagmi/Hooks/reward.d.ts +32 -0
- package/dist/wagmi/Hooks/reward.d.ts.map +1 -1
- package/dist/wagmi/Hooks/reward.js +39 -0
- package/dist/wagmi/Hooks/reward.js.map +1 -1
- package/package.json +3 -2
- package/src/chains.ts +14 -15
- package/src/ox/KeyAuthorization.test.ts +1332 -0
- package/src/ox/KeyAuthorization.ts +542 -0
- package/src/ox/SignatureEnvelope.test.ts +624 -0
- package/src/ox/SignatureEnvelope.ts +89 -9
- package/src/ox/Transaction.test.ts +214 -0
- package/src/ox/Transaction.ts +13 -1
- package/src/ox/TransactionEnvelopeAA.test.ts +164 -4
- package/src/ox/TransactionEnvelopeAA.ts +36 -3
- package/src/ox/TransactionRequest.ts +22 -1
- package/src/ox/e2e.test.ts +612 -5
- package/src/ox/index.ts +1 -0
- package/src/prool/Instance.ts +1 -1
- package/src/prool/chain.json +238 -0
- package/src/server/Handler.test.ts +20 -36
- package/src/viem/Abis.ts +200 -7
- package/src/viem/Account.test.ts +444 -0
- package/src/viem/Account.ts +355 -42
- package/src/viem/Actions/account.ts +3 -5
- package/src/viem/Actions/amm.test.ts +4 -4
- package/src/viem/Actions/reward.test.ts +84 -0
- package/src/viem/Actions/reward.ts +73 -0
- package/src/viem/Actions/token.test.ts +8 -8
- package/src/viem/Actions/token.ts +2 -2
- package/src/viem/Addresses.ts +1 -1
- package/src/viem/Chain.test.ts +168 -0
- package/src/viem/Chain.ts +37 -1
- package/src/viem/Decorator.ts +84 -0
- package/src/viem/Formatters.ts +8 -7
- package/src/viem/Storage.ts +22 -0
- package/src/viem/TokenIds.ts +1 -1
- package/src/viem/Transaction.ts +14 -2
- package/src/viem/WebAuthnP256.ts +8 -2
- package/src/viem/e2e.test.ts +299 -96
- package/src/wagmi/Actions/amm.test.ts +2 -2
- package/src/wagmi/Actions/reward.test.ts +36 -0
- package/src/wagmi/Actions/reward.ts +91 -0
- package/src/wagmi/Connector.test.ts +1 -1
- package/src/wagmi/Connector.ts +184 -54
- package/src/wagmi/Hooks/amm.test.ts +4 -4
- package/src/wagmi/Hooks/fee.test.ts +10 -4
- package/src/wagmi/Hooks/reward.test.ts +72 -0
- package/src/wagmi/Hooks/reward.ts +68 -0
- package/src/wagmi/Hooks/token.test.ts +0 -488
- package/dist/viem/internal/account.d.ts +0 -21
- package/dist/viem/internal/account.d.ts.map +0 -1
- package/dist/viem/internal/account.js +0 -61
- package/dist/viem/internal/account.js.map +0 -1
- package/src/viem/internal/account.ts +0 -89
|
@@ -205,6 +205,74 @@ export declare namespace useGetTotalPerSecond {
|
|
|
205
205
|
UseQueryReturnType<selectData, Error>
|
|
206
206
|
}
|
|
207
207
|
|
|
208
|
+
/**
|
|
209
|
+
* Hook for getting the reward information for a specific account.
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
* ```tsx
|
|
213
|
+
* import { Hooks } from 'tempo.ts/wagmi'
|
|
214
|
+
*
|
|
215
|
+
* function App() {
|
|
216
|
+
* const { data, isLoading } = Hooks.reward.useUserRewardInfo({
|
|
217
|
+
* token: '0x20c0000000000000000000000000000000000001',
|
|
218
|
+
* account: '0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC',
|
|
219
|
+
* })
|
|
220
|
+
*
|
|
221
|
+
* if (isLoading) return <div>Loading...</div>
|
|
222
|
+
* return (
|
|
223
|
+
* <div>
|
|
224
|
+
* <div>Recipient: {data?.rewardRecipient}</div>
|
|
225
|
+
* <div>Reward per token: {data?.rewardPerToken.toString()}</div>
|
|
226
|
+
* <div>Reward balance: {data?.rewardBalance.toString()}</div>
|
|
227
|
+
* </div>
|
|
228
|
+
* )
|
|
229
|
+
* }
|
|
230
|
+
* ```
|
|
231
|
+
*
|
|
232
|
+
* @param parameters - Parameters.
|
|
233
|
+
* @returns Query result with reward information (recipient, rewardPerToken, rewardBalance).
|
|
234
|
+
*/
|
|
235
|
+
export function useUserRewardInfo<
|
|
236
|
+
config extends Config = ResolvedRegister['config'],
|
|
237
|
+
selectData = Actions.getUserRewardInfo.ReturnValue,
|
|
238
|
+
>(parameters: useUserRewardInfo.Parameters<config, selectData> = {}) {
|
|
239
|
+
const { account, query = {}, token } = parameters
|
|
240
|
+
|
|
241
|
+
const config = useConfig(parameters)
|
|
242
|
+
const chainId = useChainId({ config })
|
|
243
|
+
|
|
244
|
+
const options = Actions.getUserRewardInfo.queryOptions(config, {
|
|
245
|
+
...parameters,
|
|
246
|
+
chainId: parameters.chainId ?? chainId,
|
|
247
|
+
query: undefined,
|
|
248
|
+
} as never)
|
|
249
|
+
const enabled = Boolean(token && account && (query.enabled ?? true))
|
|
250
|
+
|
|
251
|
+
return useQuery({ ...query, ...options, enabled })
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export declare namespace useUserRewardInfo {
|
|
255
|
+
export type Parameters<
|
|
256
|
+
config extends Config = ResolvedRegister['config'],
|
|
257
|
+
selectData = Actions.getUserRewardInfo.ReturnValue,
|
|
258
|
+
> = ConfigParameter<config> &
|
|
259
|
+
QueryParameter<
|
|
260
|
+
Actions.getUserRewardInfo.ReturnValue,
|
|
261
|
+
DefaultError,
|
|
262
|
+
selectData,
|
|
263
|
+
Actions.getUserRewardInfo.QueryKey<config>
|
|
264
|
+
> &
|
|
265
|
+
ExactPartial<
|
|
266
|
+
Omit<
|
|
267
|
+
Actions.getUserRewardInfo.queryOptions.Parameters<config, selectData>,
|
|
268
|
+
'query'
|
|
269
|
+
>
|
|
270
|
+
>
|
|
271
|
+
|
|
272
|
+
export type ReturnValue<selectData = Actions.getUserRewardInfo.ReturnValue> =
|
|
273
|
+
UseQueryReturnType<selectData, Error>
|
|
274
|
+
}
|
|
275
|
+
|
|
208
276
|
/**
|
|
209
277
|
* Hook for setting the reward recipient for a token holder.
|
|
210
278
|
*
|
|
@@ -241,30 +241,6 @@ describe('useHasRole', () => {
|
|
|
241
241
|
})
|
|
242
242
|
})
|
|
243
243
|
|
|
244
|
-
describe('useApprove', () => {
|
|
245
|
-
test('default', async () => {
|
|
246
|
-
const { result } = await renderHook(() => ({
|
|
247
|
-
connect: useConnect(),
|
|
248
|
-
approve: hooks.useApprove(),
|
|
249
|
-
}))
|
|
250
|
-
|
|
251
|
-
await result.current.connect.connectAsync({
|
|
252
|
-
connector: config.connectors[0]!,
|
|
253
|
-
})
|
|
254
|
-
|
|
255
|
-
const hash = await result.current.approve.mutateAsync({
|
|
256
|
-
spender: account2.address,
|
|
257
|
-
amount: parseUnits('100', 6),
|
|
258
|
-
token: addresses.alphaUsd,
|
|
259
|
-
})
|
|
260
|
-
expect(hash).toBeDefined()
|
|
261
|
-
|
|
262
|
-
await vi.waitFor(() =>
|
|
263
|
-
expect(result.current.approve.isSuccess).toBeTruthy(),
|
|
264
|
-
)
|
|
265
|
-
})
|
|
266
|
-
})
|
|
267
|
-
|
|
268
244
|
describe('useApproveSync', () => {
|
|
269
245
|
test('default', async () => {
|
|
270
246
|
const { result } = await renderHook(() => ({
|
|
@@ -290,51 +266,6 @@ describe('useApproveSync', () => {
|
|
|
290
266
|
})
|
|
291
267
|
})
|
|
292
268
|
|
|
293
|
-
describe('useBurn', () => {
|
|
294
|
-
test('default', async () => {
|
|
295
|
-
const { result } = await renderHook(() => ({
|
|
296
|
-
connect: useConnect(),
|
|
297
|
-
createSync: hooks.useCreateSync(),
|
|
298
|
-
grantRolesSync: hooks.useGrantRolesSync(),
|
|
299
|
-
mintSync: hooks.useMintSync(),
|
|
300
|
-
burn: hooks.useBurn(),
|
|
301
|
-
}))
|
|
302
|
-
|
|
303
|
-
await result.current.connect.connectAsync({
|
|
304
|
-
connector: config.connectors[0]!,
|
|
305
|
-
})
|
|
306
|
-
|
|
307
|
-
// Create a new token
|
|
308
|
-
const { token: tokenAddr } = await result.current.createSync.mutateAsync({
|
|
309
|
-
currency: 'USD',
|
|
310
|
-
name: 'Burnable Hook Token',
|
|
311
|
-
symbol: 'BURNHOOK',
|
|
312
|
-
})
|
|
313
|
-
|
|
314
|
-
// Grant issuer role
|
|
315
|
-
await result.current.grantRolesSync.mutateAsync({
|
|
316
|
-
token: tokenAddr,
|
|
317
|
-
roles: ['issuer'],
|
|
318
|
-
to: account.address,
|
|
319
|
-
})
|
|
320
|
-
|
|
321
|
-
// Mint some tokens
|
|
322
|
-
await result.current.mintSync.mutateAsync({
|
|
323
|
-
token: tokenAddr,
|
|
324
|
-
to: account.address,
|
|
325
|
-
amount: parseUnits('1000', 6),
|
|
326
|
-
})
|
|
327
|
-
|
|
328
|
-
const hash = await result.current.burn.mutateAsync({
|
|
329
|
-
token: tokenAddr,
|
|
330
|
-
amount: parseUnits('1', 6),
|
|
331
|
-
})
|
|
332
|
-
expect(hash).toBeDefined()
|
|
333
|
-
|
|
334
|
-
await vi.waitFor(() => expect(result.current.burn.isSuccess).toBeTruthy())
|
|
335
|
-
})
|
|
336
|
-
})
|
|
337
|
-
|
|
338
269
|
describe('useBurnSync', () => {
|
|
339
270
|
test('default', async () => {
|
|
340
271
|
const { result } = await renderHook(() => ({
|
|
@@ -381,37 +312,6 @@ describe('useBurnSync', () => {
|
|
|
381
312
|
})
|
|
382
313
|
})
|
|
383
314
|
|
|
384
|
-
describe('useChangeTransferPolicy', () => {
|
|
385
|
-
test('default', async () => {
|
|
386
|
-
const { result } = await renderHook(() => ({
|
|
387
|
-
connect: useConnect(),
|
|
388
|
-
createSync: hooks.useCreateSync(),
|
|
389
|
-
changeTransferPolicy: hooks.useChangeTransferPolicy(),
|
|
390
|
-
}))
|
|
391
|
-
|
|
392
|
-
await result.current.connect.connectAsync({
|
|
393
|
-
connector: config.connectors[0]!,
|
|
394
|
-
})
|
|
395
|
-
|
|
396
|
-
// Create a new token
|
|
397
|
-
const { token: tokenAddr } = await result.current.createSync.mutateAsync({
|
|
398
|
-
currency: 'USD',
|
|
399
|
-
name: 'Policy Hook Token',
|
|
400
|
-
symbol: 'POLICYHOOK',
|
|
401
|
-
})
|
|
402
|
-
|
|
403
|
-
const hash = await result.current.changeTransferPolicy.mutateAsync({
|
|
404
|
-
token: tokenAddr,
|
|
405
|
-
policyId: 0n,
|
|
406
|
-
})
|
|
407
|
-
expect(hash).toBeDefined()
|
|
408
|
-
|
|
409
|
-
await vi.waitFor(() =>
|
|
410
|
-
expect(result.current.changeTransferPolicy.isSuccess).toBeTruthy(),
|
|
411
|
-
)
|
|
412
|
-
})
|
|
413
|
-
})
|
|
414
|
-
|
|
415
315
|
describe('useChangeTransferPolicySync', () => {
|
|
416
316
|
test('default', async () => {
|
|
417
317
|
const { result } = await renderHook(() => ({
|
|
@@ -444,28 +344,6 @@ describe('useChangeTransferPolicySync', () => {
|
|
|
444
344
|
})
|
|
445
345
|
})
|
|
446
346
|
|
|
447
|
-
describe('useCreate', () => {
|
|
448
|
-
test('default', async () => {
|
|
449
|
-
const { result } = await renderHook(() => ({
|
|
450
|
-
connect: useConnect(),
|
|
451
|
-
create: hooks.useCreate(),
|
|
452
|
-
}))
|
|
453
|
-
|
|
454
|
-
await result.current.connect.connectAsync({
|
|
455
|
-
connector: config.connectors[0]!,
|
|
456
|
-
})
|
|
457
|
-
|
|
458
|
-
const hash = await result.current.create.mutateAsync({
|
|
459
|
-
name: 'Hook Test Token',
|
|
460
|
-
symbol: 'HOOKTEST',
|
|
461
|
-
currency: 'USD',
|
|
462
|
-
})
|
|
463
|
-
expect(hash).toBeDefined()
|
|
464
|
-
|
|
465
|
-
await vi.waitFor(() => expect(result.current.create.isSuccess).toBeTruthy())
|
|
466
|
-
})
|
|
467
|
-
})
|
|
468
|
-
|
|
469
347
|
describe('useCreateSync', () => {
|
|
470
348
|
test('default', async () => {
|
|
471
349
|
const { result } = await renderHook(() => ({
|
|
@@ -491,50 +369,6 @@ describe('useCreateSync', () => {
|
|
|
491
369
|
})
|
|
492
370
|
})
|
|
493
371
|
|
|
494
|
-
describe('useUpdateQuoteToken', () => {
|
|
495
|
-
test('default', async () => {
|
|
496
|
-
const { result } = await renderHook(() => ({
|
|
497
|
-
connect: useConnect(),
|
|
498
|
-
createSync: hooks.useCreateSync(),
|
|
499
|
-
prepareUpdateQuoteTokenSync: hooks.usePrepareUpdateQuoteTokenSync(),
|
|
500
|
-
updateQuoteToken: hooks.useUpdateQuoteToken(),
|
|
501
|
-
}))
|
|
502
|
-
|
|
503
|
-
await result.current.connect.connectAsync({
|
|
504
|
-
connector: config.connectors[0]!,
|
|
505
|
-
})
|
|
506
|
-
|
|
507
|
-
// Create quote token
|
|
508
|
-
const { token: quoteToken } = await result.current.createSync.mutateAsync({
|
|
509
|
-
currency: 'USD',
|
|
510
|
-
name: 'Finalize Quote Hook',
|
|
511
|
-
symbol: 'FQHOOK',
|
|
512
|
-
})
|
|
513
|
-
|
|
514
|
-
// Create main token
|
|
515
|
-
const { token: tokenAddr } = await result.current.createSync.mutateAsync({
|
|
516
|
-
currency: 'USD',
|
|
517
|
-
name: 'Finalize Main Hook',
|
|
518
|
-
symbol: 'FMHOOK',
|
|
519
|
-
})
|
|
520
|
-
|
|
521
|
-
// Prepare quote token update first
|
|
522
|
-
await result.current.prepareUpdateQuoteTokenSync.mutateAsync({
|
|
523
|
-
token: tokenAddr,
|
|
524
|
-
quoteToken,
|
|
525
|
-
})
|
|
526
|
-
|
|
527
|
-
const hash = await result.current.updateQuoteToken.mutateAsync({
|
|
528
|
-
token: tokenAddr,
|
|
529
|
-
})
|
|
530
|
-
expect(hash).toBeDefined()
|
|
531
|
-
|
|
532
|
-
await vi.waitFor(() =>
|
|
533
|
-
expect(result.current.updateQuoteToken.isSuccess).toBeTruthy(),
|
|
534
|
-
)
|
|
535
|
-
})
|
|
536
|
-
})
|
|
537
|
-
|
|
538
372
|
describe('useUpdateQuoteTokenSync', () => {
|
|
539
373
|
test('default', async () => {
|
|
540
374
|
const { result } = await renderHook(() => ({
|
|
@@ -646,44 +480,6 @@ describe('useGrantRolesSync', () => {
|
|
|
646
480
|
})
|
|
647
481
|
})
|
|
648
482
|
|
|
649
|
-
describe('useMint', () => {
|
|
650
|
-
test('default', async () => {
|
|
651
|
-
const { result } = await renderHook(() => ({
|
|
652
|
-
connect: useConnect(),
|
|
653
|
-
createSync: hooks.useCreateSync(),
|
|
654
|
-
grantRolesSync: hooks.useGrantRolesSync(),
|
|
655
|
-
mint: hooks.useMint(),
|
|
656
|
-
}))
|
|
657
|
-
|
|
658
|
-
await result.current.connect.connectAsync({
|
|
659
|
-
connector: config.connectors[0]!,
|
|
660
|
-
})
|
|
661
|
-
|
|
662
|
-
// Create a new token
|
|
663
|
-
const { token: tokenAddr } = await result.current.createSync.mutateAsync({
|
|
664
|
-
currency: 'USD',
|
|
665
|
-
name: 'Mint Hook Token',
|
|
666
|
-
symbol: 'MINTHOOK',
|
|
667
|
-
})
|
|
668
|
-
|
|
669
|
-
// Grant issuer role
|
|
670
|
-
await result.current.grantRolesSync.mutateAsync({
|
|
671
|
-
token: tokenAddr,
|
|
672
|
-
roles: ['issuer'],
|
|
673
|
-
to: account.address,
|
|
674
|
-
})
|
|
675
|
-
|
|
676
|
-
const hash = await result.current.mint.mutateAsync({
|
|
677
|
-
token: tokenAddr,
|
|
678
|
-
to: account.address,
|
|
679
|
-
amount: parseUnits('100', 6),
|
|
680
|
-
})
|
|
681
|
-
expect(hash).toBeDefined()
|
|
682
|
-
|
|
683
|
-
await vi.waitFor(() => expect(result.current.mint.isSuccess).toBeTruthy())
|
|
684
|
-
})
|
|
685
|
-
})
|
|
686
|
-
|
|
687
483
|
describe('useMintSync', () => {
|
|
688
484
|
test('default', async () => {
|
|
689
485
|
const { result } = await renderHook(() => ({
|
|
@@ -723,42 +519,6 @@ describe('useMintSync', () => {
|
|
|
723
519
|
})
|
|
724
520
|
})
|
|
725
521
|
|
|
726
|
-
describe('usePause', () => {
|
|
727
|
-
test('default', async () => {
|
|
728
|
-
const { result } = await renderHook(() => ({
|
|
729
|
-
connect: useConnect(),
|
|
730
|
-
createSync: hooks.useCreateSync(),
|
|
731
|
-
grantRolesSync: hooks.useGrantRolesSync(),
|
|
732
|
-
pause: hooks.usePause(),
|
|
733
|
-
}))
|
|
734
|
-
|
|
735
|
-
await result.current.connect.connectAsync({
|
|
736
|
-
connector: config.connectors[0]!,
|
|
737
|
-
})
|
|
738
|
-
|
|
739
|
-
// Create a new token
|
|
740
|
-
const { token: tokenAddr } = await result.current.createSync.mutateAsync({
|
|
741
|
-
currency: 'USD',
|
|
742
|
-
name: 'Pause Hook Token',
|
|
743
|
-
symbol: 'PAUSEHOOK',
|
|
744
|
-
})
|
|
745
|
-
|
|
746
|
-
// Grant pause role
|
|
747
|
-
await result.current.grantRolesSync.mutateAsync({
|
|
748
|
-
token: tokenAddr,
|
|
749
|
-
roles: ['pause'],
|
|
750
|
-
to: account.address,
|
|
751
|
-
})
|
|
752
|
-
|
|
753
|
-
const hash = await result.current.pause.mutateAsync({
|
|
754
|
-
token: tokenAddr,
|
|
755
|
-
})
|
|
756
|
-
expect(hash).toBeDefined()
|
|
757
|
-
|
|
758
|
-
await vi.waitFor(() => expect(result.current.pause.isSuccess).toBeTruthy())
|
|
759
|
-
})
|
|
760
|
-
})
|
|
761
|
-
|
|
762
522
|
describe('usePauseSync', () => {
|
|
763
523
|
test('default', async () => {
|
|
764
524
|
const { result } = await renderHook(() => ({
|
|
@@ -796,45 +556,6 @@ describe('usePauseSync', () => {
|
|
|
796
556
|
})
|
|
797
557
|
})
|
|
798
558
|
|
|
799
|
-
describe('useRenounceRoles', () => {
|
|
800
|
-
test('default', async () => {
|
|
801
|
-
const { result } = await renderHook(() => ({
|
|
802
|
-
connect: useConnect(),
|
|
803
|
-
createSync: hooks.useCreateSync(),
|
|
804
|
-
grantRolesSync: hooks.useGrantRolesSync(),
|
|
805
|
-
renounceRoles: hooks.useRenounceRoles(),
|
|
806
|
-
}))
|
|
807
|
-
|
|
808
|
-
await result.current.connect.connectAsync({
|
|
809
|
-
connector: config.connectors[0]!,
|
|
810
|
-
})
|
|
811
|
-
|
|
812
|
-
// Create a new token
|
|
813
|
-
const { token: tokenAddr } = await result.current.createSync.mutateAsync({
|
|
814
|
-
currency: 'USD',
|
|
815
|
-
name: 'Renounce Hook Token',
|
|
816
|
-
symbol: 'RENOUNCEHOOK',
|
|
817
|
-
})
|
|
818
|
-
|
|
819
|
-
// Grant issuer role to ourselves
|
|
820
|
-
await result.current.grantRolesSync.mutateAsync({
|
|
821
|
-
token: tokenAddr,
|
|
822
|
-
roles: ['issuer'],
|
|
823
|
-
to: account.address,
|
|
824
|
-
})
|
|
825
|
-
|
|
826
|
-
const hash = await result.current.renounceRoles.mutateAsync({
|
|
827
|
-
token: tokenAddr,
|
|
828
|
-
roles: ['issuer'],
|
|
829
|
-
})
|
|
830
|
-
expect(hash).toBeDefined()
|
|
831
|
-
|
|
832
|
-
await vi.waitFor(() =>
|
|
833
|
-
expect(result.current.renounceRoles.isSuccess).toBeTruthy(),
|
|
834
|
-
)
|
|
835
|
-
})
|
|
836
|
-
})
|
|
837
|
-
|
|
838
559
|
describe('useRenounceRolesSync', () => {
|
|
839
560
|
test('default', async () => {
|
|
840
561
|
const { result } = await renderHook(() => ({
|
|
@@ -876,46 +597,6 @@ describe('useRenounceRolesSync', () => {
|
|
|
876
597
|
})
|
|
877
598
|
})
|
|
878
599
|
|
|
879
|
-
describe('useRevokeRoles', () => {
|
|
880
|
-
test('default', async () => {
|
|
881
|
-
const { result } = await renderHook(() => ({
|
|
882
|
-
connect: useConnect(),
|
|
883
|
-
createSync: hooks.useCreateSync(),
|
|
884
|
-
grantRolesSync: hooks.useGrantRolesSync(),
|
|
885
|
-
revokeRoles: hooks.useRevokeRoles(),
|
|
886
|
-
}))
|
|
887
|
-
|
|
888
|
-
await result.current.connect.connectAsync({
|
|
889
|
-
connector: config.connectors[0]!,
|
|
890
|
-
})
|
|
891
|
-
|
|
892
|
-
// Create a new token
|
|
893
|
-
const { token: tokenAddr } = await result.current.createSync.mutateAsync({
|
|
894
|
-
currency: 'USD',
|
|
895
|
-
name: 'Revoke Hook Token',
|
|
896
|
-
symbol: 'REVOKEHOOK',
|
|
897
|
-
})
|
|
898
|
-
|
|
899
|
-
// Grant issuer role to account2
|
|
900
|
-
await result.current.grantRolesSync.mutateAsync({
|
|
901
|
-
token: tokenAddr,
|
|
902
|
-
roles: ['issuer'],
|
|
903
|
-
to: account2.address,
|
|
904
|
-
})
|
|
905
|
-
|
|
906
|
-
const hash = await result.current.revokeRoles.mutateAsync({
|
|
907
|
-
token: tokenAddr,
|
|
908
|
-
roles: ['issuer'],
|
|
909
|
-
from: account2.address,
|
|
910
|
-
})
|
|
911
|
-
expect(hash).toBeDefined()
|
|
912
|
-
|
|
913
|
-
await vi.waitFor(() =>
|
|
914
|
-
expect(result.current.revokeRoles.isSuccess).toBeTruthy(),
|
|
915
|
-
)
|
|
916
|
-
})
|
|
917
|
-
})
|
|
918
|
-
|
|
919
600
|
describe('useRevokeRolesSync', () => {
|
|
920
601
|
test('default', async () => {
|
|
921
602
|
const { result } = await renderHook(() => ({
|
|
@@ -958,38 +639,6 @@ describe('useRevokeRolesSync', () => {
|
|
|
958
639
|
})
|
|
959
640
|
})
|
|
960
641
|
|
|
961
|
-
describe('useSetRoleAdmin', () => {
|
|
962
|
-
test('default', async () => {
|
|
963
|
-
const { result } = await renderHook(() => ({
|
|
964
|
-
connect: useConnect(),
|
|
965
|
-
createSync: hooks.useCreateSync(),
|
|
966
|
-
setRoleAdmin: hooks.useSetRoleAdmin(),
|
|
967
|
-
}))
|
|
968
|
-
|
|
969
|
-
await result.current.connect.connectAsync({
|
|
970
|
-
connector: config.connectors[0]!,
|
|
971
|
-
})
|
|
972
|
-
|
|
973
|
-
// Create a new token
|
|
974
|
-
const { token: tokenAddr } = await result.current.createSync.mutateAsync({
|
|
975
|
-
currency: 'USD',
|
|
976
|
-
name: 'Role Admin Hook Token',
|
|
977
|
-
symbol: 'ROLEADMINHOOK',
|
|
978
|
-
})
|
|
979
|
-
|
|
980
|
-
const hash = await result.current.setRoleAdmin.mutateAsync({
|
|
981
|
-
token: tokenAddr,
|
|
982
|
-
role: 'issuer',
|
|
983
|
-
adminRole: 'pause',
|
|
984
|
-
})
|
|
985
|
-
expect(hash).toBeDefined()
|
|
986
|
-
|
|
987
|
-
await vi.waitFor(() =>
|
|
988
|
-
expect(result.current.setRoleAdmin.isSuccess).toBeTruthy(),
|
|
989
|
-
)
|
|
990
|
-
})
|
|
991
|
-
})
|
|
992
|
-
|
|
993
642
|
describe('useSetRoleAdminSync', () => {
|
|
994
643
|
test('default', async () => {
|
|
995
644
|
const { result } = await renderHook(() => ({
|
|
@@ -1023,37 +672,6 @@ describe('useSetRoleAdminSync', () => {
|
|
|
1023
672
|
})
|
|
1024
673
|
})
|
|
1025
674
|
|
|
1026
|
-
describe('useSetSupplyCap', () => {
|
|
1027
|
-
test('default', async () => {
|
|
1028
|
-
const { result } = await renderHook(() => ({
|
|
1029
|
-
connect: useConnect(),
|
|
1030
|
-
createSync: hooks.useCreateSync(),
|
|
1031
|
-
setSupplyCap: hooks.useSetSupplyCap(),
|
|
1032
|
-
}))
|
|
1033
|
-
|
|
1034
|
-
await result.current.connect.connectAsync({
|
|
1035
|
-
connector: config.connectors[0]!,
|
|
1036
|
-
})
|
|
1037
|
-
|
|
1038
|
-
// Create a new token
|
|
1039
|
-
const { token: tokenAddr } = await result.current.createSync.mutateAsync({
|
|
1040
|
-
currency: 'USD',
|
|
1041
|
-
name: 'Supply Cap Hook Token',
|
|
1042
|
-
symbol: 'SUPPLYCAPHOOK',
|
|
1043
|
-
})
|
|
1044
|
-
|
|
1045
|
-
const hash = await result.current.setSupplyCap.mutateAsync({
|
|
1046
|
-
token: tokenAddr,
|
|
1047
|
-
supplyCap: parseUnits('1000000', 6),
|
|
1048
|
-
})
|
|
1049
|
-
expect(hash).toBeDefined()
|
|
1050
|
-
|
|
1051
|
-
await vi.waitFor(() =>
|
|
1052
|
-
expect(result.current.setSupplyCap.isSuccess).toBeTruthy(),
|
|
1053
|
-
)
|
|
1054
|
-
})
|
|
1055
|
-
})
|
|
1056
|
-
|
|
1057
675
|
describe('useSetSupplyCapSync', () => {
|
|
1058
676
|
test('default', async () => {
|
|
1059
677
|
const { result } = await renderHook(() => ({
|
|
@@ -1086,30 +704,6 @@ describe('useSetSupplyCapSync', () => {
|
|
|
1086
704
|
})
|
|
1087
705
|
})
|
|
1088
706
|
|
|
1089
|
-
describe('useTransfer', () => {
|
|
1090
|
-
test('default', async () => {
|
|
1091
|
-
const { result } = await renderHook(() => ({
|
|
1092
|
-
connect: useConnect(),
|
|
1093
|
-
transfer: hooks.useTransfer(),
|
|
1094
|
-
}))
|
|
1095
|
-
|
|
1096
|
-
await result.current.connect.connectAsync({
|
|
1097
|
-
connector: config.connectors[0]!,
|
|
1098
|
-
})
|
|
1099
|
-
|
|
1100
|
-
const hash = await result.current.transfer.mutateAsync({
|
|
1101
|
-
to: account2.address,
|
|
1102
|
-
amount: parseUnits('1', 6),
|
|
1103
|
-
token: addresses.alphaUsd,
|
|
1104
|
-
})
|
|
1105
|
-
expect(hash).toBeDefined()
|
|
1106
|
-
|
|
1107
|
-
await vi.waitFor(() =>
|
|
1108
|
-
expect(result.current.transfer.isSuccess).toBeTruthy(),
|
|
1109
|
-
)
|
|
1110
|
-
})
|
|
1111
|
-
})
|
|
1112
|
-
|
|
1113
707
|
describe('useTransferSync', () => {
|
|
1114
708
|
test('default', async () => {
|
|
1115
709
|
const { result } = await renderHook(() => ({
|
|
@@ -1135,50 +729,6 @@ describe('useTransferSync', () => {
|
|
|
1135
729
|
})
|
|
1136
730
|
})
|
|
1137
731
|
|
|
1138
|
-
describe('useUnpause', () => {
|
|
1139
|
-
test('default', async () => {
|
|
1140
|
-
const { result } = await renderHook(() => ({
|
|
1141
|
-
connect: useConnect(),
|
|
1142
|
-
createSync: hooks.useCreateSync(),
|
|
1143
|
-
grantRolesSync: hooks.useGrantRolesSync(),
|
|
1144
|
-
pauseSync: hooks.usePauseSync(),
|
|
1145
|
-
unpause: hooks.useUnpause(),
|
|
1146
|
-
}))
|
|
1147
|
-
|
|
1148
|
-
await result.current.connect.connectAsync({
|
|
1149
|
-
connector: config.connectors[0]!,
|
|
1150
|
-
})
|
|
1151
|
-
|
|
1152
|
-
// Create a new token
|
|
1153
|
-
const { token: tokenAddr } = await result.current.createSync.mutateAsync({
|
|
1154
|
-
currency: 'USD',
|
|
1155
|
-
name: 'Unpause Hook Token',
|
|
1156
|
-
symbol: 'UNPAUSEHOOK',
|
|
1157
|
-
})
|
|
1158
|
-
|
|
1159
|
-
// Grant pause and unpause roles
|
|
1160
|
-
await result.current.grantRolesSync.mutateAsync({
|
|
1161
|
-
token: tokenAddr,
|
|
1162
|
-
roles: ['pause', 'unpause'],
|
|
1163
|
-
to: account.address,
|
|
1164
|
-
})
|
|
1165
|
-
|
|
1166
|
-
// First pause it
|
|
1167
|
-
await result.current.pauseSync.mutateAsync({
|
|
1168
|
-
token: tokenAddr,
|
|
1169
|
-
})
|
|
1170
|
-
|
|
1171
|
-
const hash = await result.current.unpause.mutateAsync({
|
|
1172
|
-
token: tokenAddr,
|
|
1173
|
-
})
|
|
1174
|
-
expect(hash).toBeDefined()
|
|
1175
|
-
|
|
1176
|
-
await vi.waitFor(() =>
|
|
1177
|
-
expect(result.current.unpause.isSuccess).toBeTruthy(),
|
|
1178
|
-
)
|
|
1179
|
-
})
|
|
1180
|
-
})
|
|
1181
|
-
|
|
1182
732
|
describe('useUnpauseSync', () => {
|
|
1183
733
|
test('default', async () => {
|
|
1184
734
|
const { result } = await renderHook(() => ({
|
|
@@ -1224,44 +774,6 @@ describe('useUnpauseSync', () => {
|
|
|
1224
774
|
})
|
|
1225
775
|
})
|
|
1226
776
|
|
|
1227
|
-
describe('usePrepareUpdateQuoteToken', () => {
|
|
1228
|
-
test('default', async () => {
|
|
1229
|
-
const { result } = await renderHook(() => ({
|
|
1230
|
-
connect: useConnect(),
|
|
1231
|
-
createSync: hooks.useCreateSync(),
|
|
1232
|
-
prepareUpdateQuoteToken: hooks.usePrepareUpdateQuoteToken(),
|
|
1233
|
-
}))
|
|
1234
|
-
|
|
1235
|
-
await result.current.connect.connectAsync({
|
|
1236
|
-
connector: config.connectors[0]!,
|
|
1237
|
-
})
|
|
1238
|
-
|
|
1239
|
-
// Create quote token
|
|
1240
|
-
const { token: quoteToken } = await result.current.createSync.mutateAsync({
|
|
1241
|
-
currency: 'USD',
|
|
1242
|
-
name: 'Update Quote Hook',
|
|
1243
|
-
symbol: 'UQHOOK',
|
|
1244
|
-
})
|
|
1245
|
-
|
|
1246
|
-
// Create main token
|
|
1247
|
-
const { token: tokenAddr } = await result.current.createSync.mutateAsync({
|
|
1248
|
-
currency: 'USD',
|
|
1249
|
-
name: 'Update Main Hook',
|
|
1250
|
-
symbol: 'UMHOOK',
|
|
1251
|
-
})
|
|
1252
|
-
|
|
1253
|
-
const hash = await result.current.prepareUpdateQuoteToken.mutateAsync({
|
|
1254
|
-
token: tokenAddr,
|
|
1255
|
-
quoteToken,
|
|
1256
|
-
})
|
|
1257
|
-
expect(hash).toBeDefined()
|
|
1258
|
-
|
|
1259
|
-
await vi.waitFor(() =>
|
|
1260
|
-
expect(result.current.prepareUpdateQuoteToken.isSuccess).toBeTruthy(),
|
|
1261
|
-
)
|
|
1262
|
-
})
|
|
1263
|
-
})
|
|
1264
|
-
|
|
1265
777
|
describe('usePrepareUpdateQuoteTokenSync', () => {
|
|
1266
778
|
test('default', async () => {
|
|
1267
779
|
const { result } = await renderHook(() => ({
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import * as Hex from 'ox/Hex';
|
|
2
|
-
import * as PublicKey from 'ox/PublicKey';
|
|
3
|
-
import type { LocalAccount } from 'viem';
|
|
4
|
-
import type { RequiredBy } from '../../internal/types.js';
|
|
5
|
-
export type Account = RequiredBy<LocalAccount, 'sign' | 'signAuthorization'>;
|
|
6
|
-
/** @internal */
|
|
7
|
-
export declare function toPrivateKeyAccount(parameters: toPrivateKeyAccount.Parameters): toPrivateKeyAccount.ReturnValue;
|
|
8
|
-
export declare namespace toPrivateKeyAccount {
|
|
9
|
-
type Parameters = {
|
|
10
|
-
/** Address. */
|
|
11
|
-
address: Hex.Hex;
|
|
12
|
-
/** Public key. */
|
|
13
|
-
publicKey: PublicKey.PublicKey;
|
|
14
|
-
/** Sign function. */
|
|
15
|
-
sign: NonNullable<LocalAccount['sign']>;
|
|
16
|
-
/** Source. */
|
|
17
|
-
source?: string | undefined;
|
|
18
|
-
};
|
|
19
|
-
type ReturnValue = Account;
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=account.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../../src/viem/internal/account.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,QAAQ,CAAA;AAC7B,OAAO,KAAK,SAAS,MAAM,cAAc,CAAA;AACzC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAOxC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAIzD,MAAM,MAAM,OAAO,GAAG,UAAU,CAAC,YAAY,EAAE,MAAM,GAAG,mBAAmB,CAAC,CAAA;AAG5E,gBAAgB;AAChB,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,mBAAmB,CAAC,UAAU,GACzC,mBAAmB,CAAC,WAAW,CAsDjC;AAED,MAAM,CAAC,OAAO,WAAW,mBAAmB,CAAC;IAC3C,KAAY,UAAU,GAAG;QACvB,eAAe;QACf,OAAO,EAAE,GAAG,CAAC,GAAG,CAAA;QAChB,kBAAkB;QAClB,SAAS,EAAE,SAAS,CAAC,SAAS,CAAA;QAC9B,qBAAqB;QACrB,IAAI,EAAE,WAAW,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAA;QACvC,cAAc;QACd,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;KAC5B,CAAA;IAED,KAAY,WAAW,GAAG,OAAO,CAAA;CAClC"}
|