viem 2.47.18 → 2.48.0
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 +12 -0
- package/_cjs/chains/definitions/tempo.js +2 -2
- package/_cjs/chains/definitions/tempo.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/errors/version.js.map +1 -1
- package/_cjs/tempo/Addresses.js +2 -1
- package/_cjs/tempo/Addresses.js.map +1 -1
- package/_cjs/tempo/Decorator.js +16 -0
- package/_cjs/tempo/Decorator.js.map +1 -1
- package/_cjs/tempo/Storage.js +77 -0
- package/_cjs/tempo/Storage.js.map +1 -0
- package/_cjs/tempo/actions/index.js +2 -1
- package/_cjs/tempo/actions/index.js.map +1 -1
- package/_cjs/tempo/actions/zone.js +432 -0
- package/_cjs/tempo/actions/zone.js.map +1 -0
- package/_cjs/tempo/index.js +2 -1
- package/_cjs/tempo/index.js.map +1 -1
- package/_cjs/tempo/zones/Abis.js +82 -0
- package/_cjs/tempo/zones/Abis.js.map +1 -0
- package/_cjs/tempo/zones/index.js +13 -0
- package/_cjs/tempo/zones/index.js.map +1 -0
- package/_cjs/tempo/zones/transport.js +24 -0
- package/_cjs/tempo/zones/transport.js.map +1 -0
- package/_cjs/tempo/zones/zone.js +53 -0
- package/_cjs/tempo/zones/zone.js.map +1 -0
- package/_esm/chains/definitions/tempo.js +2 -2
- package/_esm/chains/definitions/tempo.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/errors/version.js.map +1 -1
- package/_esm/tempo/Addresses.js +1 -0
- package/_esm/tempo/Addresses.js.map +1 -1
- package/_esm/tempo/Decorator.js +16 -0
- package/_esm/tempo/Decorator.js.map +1 -1
- package/_esm/tempo/Storage.js +96 -0
- package/_esm/tempo/Storage.js.map +1 -0
- package/_esm/tempo/actions/index.js +1 -0
- package/_esm/tempo/actions/index.js.map +1 -1
- package/_esm/tempo/actions/zone.js +786 -0
- package/_esm/tempo/actions/zone.js.map +1 -0
- package/_esm/tempo/index.js +1 -0
- package/_esm/tempo/index.js.map +1 -1
- package/_esm/tempo/zones/Abis.js +79 -0
- package/_esm/tempo/zones/Abis.js.map +1 -0
- package/_esm/tempo/zones/index.js +5 -0
- package/_esm/tempo/zones/index.js.map +1 -0
- package/_esm/tempo/zones/transport.js +39 -0
- package/_esm/tempo/zones/transport.js.map +1 -0
- package/_esm/tempo/zones/zone.js +49 -0
- package/_esm/tempo/zones/zone.js.map +1 -0
- package/_types/chains/definitions/tempo.d.ts +4 -4
- package/_types/errors/version.d.ts +1 -1
- package/_types/errors/version.d.ts.map +1 -1
- package/_types/tempo/Addresses.d.ts +1 -0
- package/_types/tempo/Addresses.d.ts.map +1 -1
- package/_types/tempo/Decorator.d.ts +283 -0
- package/_types/tempo/Decorator.d.ts.map +1 -1
- package/_types/tempo/Storage.d.ts +42 -0
- package/_types/tempo/Storage.d.ts.map +1 -0
- package/_types/tempo/actions/index.d.ts +1 -0
- package/_types/tempo/actions/index.d.ts.map +1 -1
- package/_types/tempo/actions/zone.d.ts +874 -0
- package/_types/tempo/actions/zone.d.ts.map +1 -0
- package/_types/tempo/index.d.ts +1 -0
- package/_types/tempo/index.d.ts.map +1 -1
- package/_types/tempo/zones/Abis.d.ts +124 -0
- package/_types/tempo/zones/Abis.d.ts.map +1 -0
- package/_types/tempo/zones/index.d.ts +4 -0
- package/_types/tempo/zones/index.d.ts.map +1 -0
- package/_types/tempo/zones/transport.d.ts +26 -0
- package/_types/tempo/zones/transport.d.ts.map +1 -0
- package/_types/tempo/zones/zone.d.ts +2775 -0
- package/_types/tempo/zones/zone.d.ts.map +1 -0
- package/chains/definitions/tempo.ts +2 -2
- package/errors/version.ts +1 -1
- package/package.json +7 -2
- package/tempo/Addresses.ts +1 -0
- package/tempo/Decorator.ts +337 -0
- package/tempo/Storage.ts +118 -0
- package/tempo/actions/index.ts +1 -0
- package/tempo/actions/zone.ts +1317 -0
- package/tempo/index.ts +1 -0
- package/tempo/zones/Abis.ts +79 -0
- package/tempo/zones/index.ts +10 -0
- package/tempo/zones/package.json +6 -0
- package/tempo/zones/transport.ts +58 -0
- package/tempo/zones/zone.ts +70 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zone.d.ts","sourceRoot":"","sources":["../../../tempo/zones/zone.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,eAAe;;;;;CAKsC,CAAA;AAElE,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,GACb,KAAK,MAAM,EAAE,CASf;AAED,eAAO,MAAM,IAAI,OAYH,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqBnB;AAED,OAAO,WAAW,IAAI,CAAC;IACrB,KAAK,OAAO,GAAG;QACb,uEAAuE;QACvE,OAAO,EAAE,MAAM,CAAA;QACf,0FAA0F;QAC1F,QAAQ,EAAE,MAAM,CAAA;KACjB,CAAA;CACF"}
|
|
@@ -18,8 +18,8 @@ export const tempo = /*#__PURE__*/ defineChain({
|
|
|
18
18
|
},
|
|
19
19
|
rpcUrls: {
|
|
20
20
|
default: {
|
|
21
|
-
http: ['https://rpc.
|
|
22
|
-
webSocket: ['wss://rpc.
|
|
21
|
+
http: ['https://rpc.tempo.xyz'],
|
|
22
|
+
webSocket: ['wss://rpc.tempo.xyz'],
|
|
23
23
|
},
|
|
24
24
|
},
|
|
25
25
|
})
|
package/errors/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '2.
|
|
1
|
+
export const version = '2.48.0'
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "viem",
|
|
3
3
|
"description": "TypeScript Interface for Ethereum",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.48.0",
|
|
5
5
|
"main": "./_cjs/index.js",
|
|
6
6
|
"module": "./_esm/index.js",
|
|
7
7
|
"types": "./_types/index.d.ts",
|
|
@@ -124,6 +124,11 @@
|
|
|
124
124
|
"import": "./_esm/tempo/actions/index.js",
|
|
125
125
|
"default": "./_cjs/tempo/actions/index.js"
|
|
126
126
|
},
|
|
127
|
+
"./tempo/zones": {
|
|
128
|
+
"types": "./_types/tempo/zones/index.d.ts",
|
|
129
|
+
"import": "./_esm/tempo/zones/index.js",
|
|
130
|
+
"default": "./_cjs/tempo/zones/index.js"
|
|
131
|
+
},
|
|
127
132
|
"./utils": {
|
|
128
133
|
"types": "./_types/utils/index.d.ts",
|
|
129
134
|
"import": "./_esm/utils/index.js",
|
|
@@ -217,7 +222,7 @@
|
|
|
217
222
|
"@scure/bip39": "1.6.0",
|
|
218
223
|
"abitype": "1.2.3",
|
|
219
224
|
"isows": "1.0.7",
|
|
220
|
-
"ox": "0.14.
|
|
225
|
+
"ox": "0.14.17",
|
|
221
226
|
"ws": "8.18.3"
|
|
222
227
|
},
|
|
223
228
|
"license": "MIT",
|
package/tempo/Addresses.ts
CHANGED
|
@@ -9,3 +9,4 @@ export const stablecoinDex = '0xdec0000000000000000000000000000000000000'
|
|
|
9
9
|
export const tip20Factory = '0x20fc000000000000000000000000000000000000'
|
|
10
10
|
export const tip403Registry = '0x403c000000000000000000000000000000000000'
|
|
11
11
|
export const validator = '0xcccccccc00000000000000000000000000000000'
|
|
12
|
+
export const zoneOutbox = '0x1c00000000000000000000000000000000000002'
|
package/tempo/Decorator.ts
CHANGED
|
@@ -14,6 +14,7 @@ import * as rewardActions from './actions/reward.js'
|
|
|
14
14
|
import * as simulateActions from './actions/simulate.js'
|
|
15
15
|
import * as tokenActions from './actions/token.js'
|
|
16
16
|
import * as validatorActions from './actions/validator.js'
|
|
17
|
+
import * as zoneActions from './actions/zone.js'
|
|
17
18
|
|
|
18
19
|
export type Decorator<
|
|
19
20
|
chain extends Chain | undefined = Chain | undefined,
|
|
@@ -3804,6 +3805,316 @@ export type Decorator<
|
|
|
3804
3805
|
parameters: validatorActions.updateSync.Parameters<chain, account>,
|
|
3805
3806
|
) => Promise<validatorActions.updateSync.ReturnValue>
|
|
3806
3807
|
}
|
|
3808
|
+
zone: {
|
|
3809
|
+
/**
|
|
3810
|
+
* Deposits tokens into a zone.
|
|
3811
|
+
* Batches approve and deposit into a single transaction.
|
|
3812
|
+
*
|
|
3813
|
+
* @example
|
|
3814
|
+
* ```ts
|
|
3815
|
+
* import { createClient, http } from 'viem'
|
|
3816
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
3817
|
+
* import { tempoModerato } from 'viem/chains'
|
|
3818
|
+
* import { tempoActions } from 'viem/tempo'
|
|
3819
|
+
*
|
|
3820
|
+
* const client = createClient({
|
|
3821
|
+
* account: privateKeyToAccount('0x...'),
|
|
3822
|
+
* chain: tempoModerato,
|
|
3823
|
+
* transport: http(),
|
|
3824
|
+
* }).extend(tempoActions())
|
|
3825
|
+
*
|
|
3826
|
+
* const hash = await client.zone.deposit({
|
|
3827
|
+
* token: '0x20c0...0001',
|
|
3828
|
+
* amount: 1_000_000n,
|
|
3829
|
+
* zoneId: 7,
|
|
3830
|
+
* })
|
|
3831
|
+
* ```
|
|
3832
|
+
*
|
|
3833
|
+
* @param parameters - Parameters.
|
|
3834
|
+
* @returns The transaction hash.
|
|
3835
|
+
*/
|
|
3836
|
+
deposit: (
|
|
3837
|
+
parameters: zoneActions.deposit.Parameters<chain, account>,
|
|
3838
|
+
) => Promise<zoneActions.deposit.ReturnValue>
|
|
3839
|
+
/**
|
|
3840
|
+
* Deposits tokens into a zone and waits for the transaction receipt.
|
|
3841
|
+
*
|
|
3842
|
+
* @example
|
|
3843
|
+
* ```ts
|
|
3844
|
+
* import { createClient, http } from 'viem'
|
|
3845
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
3846
|
+
* import { tempoModerato } from 'viem/chains'
|
|
3847
|
+
* import { tempoActions } from 'viem/tempo'
|
|
3848
|
+
*
|
|
3849
|
+
* const client = createClient({
|
|
3850
|
+
* account: privateKeyToAccount('0x...'),
|
|
3851
|
+
* chain: tempoModerato,
|
|
3852
|
+
* transport: http(),
|
|
3853
|
+
* }).extend(tempoActions())
|
|
3854
|
+
*
|
|
3855
|
+
* const { receipt } = await client.zone.depositSync({
|
|
3856
|
+
* token: '0x20c0...0001',
|
|
3857
|
+
* amount: 1_000_000n,
|
|
3858
|
+
* zoneId: 7,
|
|
3859
|
+
* })
|
|
3860
|
+
* ```
|
|
3861
|
+
*
|
|
3862
|
+
* @param parameters - Parameters.
|
|
3863
|
+
* @returns The transaction receipt.
|
|
3864
|
+
*/
|
|
3865
|
+
depositSync: (
|
|
3866
|
+
parameters: zoneActions.depositSync.Parameters<chain, account>,
|
|
3867
|
+
) => Promise<zoneActions.depositSync.ReturnValue>
|
|
3868
|
+
/**
|
|
3869
|
+
* Deposits tokens into a zone with encrypted recipient and memo.
|
|
3870
|
+
*
|
|
3871
|
+
* @example
|
|
3872
|
+
* ```ts
|
|
3873
|
+
* const hash = await client.zone.encryptedDeposit({
|
|
3874
|
+
* token: '0x20c0...0001',
|
|
3875
|
+
* amount: 1_000_000n,
|
|
3876
|
+
* zoneId: 7,
|
|
3877
|
+
* })
|
|
3878
|
+
* ```
|
|
3879
|
+
*
|
|
3880
|
+
* @param parameters - Parameters.
|
|
3881
|
+
* @returns The transaction hash.
|
|
3882
|
+
*/
|
|
3883
|
+
encryptedDeposit: (
|
|
3884
|
+
parameters: zoneActions.encryptedDeposit.Parameters<chain, account>,
|
|
3885
|
+
) => Promise<zoneActions.encryptedDeposit.ReturnValue>
|
|
3886
|
+
/**
|
|
3887
|
+
* Deposits tokens into a zone with encrypted recipient and memo and
|
|
3888
|
+
* waits for the transaction receipt.
|
|
3889
|
+
*
|
|
3890
|
+
* @example
|
|
3891
|
+
* ```ts
|
|
3892
|
+
* const { receipt } = await client.zone.encryptedDepositSync({
|
|
3893
|
+
* token: '0x20c0...0001',
|
|
3894
|
+
* amount: 1_000_000n,
|
|
3895
|
+
* zoneId: 7,
|
|
3896
|
+
* })
|
|
3897
|
+
* ```
|
|
3898
|
+
*
|
|
3899
|
+
* @param parameters - Parameters.
|
|
3900
|
+
* @returns The transaction receipt.
|
|
3901
|
+
*/
|
|
3902
|
+
encryptedDepositSync: (
|
|
3903
|
+
parameters: zoneActions.encryptedDepositSync.Parameters<chain, account>,
|
|
3904
|
+
) => Promise<zoneActions.encryptedDepositSync.ReturnValue>
|
|
3905
|
+
/**
|
|
3906
|
+
* Returns the authenticated account address and authorization token expiry.
|
|
3907
|
+
*
|
|
3908
|
+
* @example
|
|
3909
|
+
* ```ts
|
|
3910
|
+
* import { createClient } from 'viem'
|
|
3911
|
+
* import { http, zoneModerato } from 'viem/tempo/zones'
|
|
3912
|
+
* import { tempoActions } from 'viem/tempo'
|
|
3913
|
+
*
|
|
3914
|
+
* const client = createClient({
|
|
3915
|
+
* chain: zoneModerato(7),
|
|
3916
|
+
* transport: http(),
|
|
3917
|
+
* }).extend(tempoActions())
|
|
3918
|
+
*
|
|
3919
|
+
* const info = await client.zone.getAuthorizationTokenInfo()
|
|
3920
|
+
* ```
|
|
3921
|
+
*
|
|
3922
|
+
* @returns The account address and token expiry.
|
|
3923
|
+
*/
|
|
3924
|
+
getAuthorizationTokenInfo: () => Promise<zoneActions.getAuthorizationTokenInfo.ReturnType>
|
|
3925
|
+
/**
|
|
3926
|
+
* Returns deposit processing status for a given Tempo block number.
|
|
3927
|
+
*
|
|
3928
|
+
* @example
|
|
3929
|
+
* ```ts
|
|
3930
|
+
* import { createClient } from 'viem'
|
|
3931
|
+
* import { http, zoneModerato } from 'viem/tempo/zones'
|
|
3932
|
+
* import { tempoActions } from 'viem/tempo'
|
|
3933
|
+
*
|
|
3934
|
+
* const client = createClient({
|
|
3935
|
+
* chain: zoneModerato(7),
|
|
3936
|
+
* transport: http(),
|
|
3937
|
+
* }).extend(tempoActions())
|
|
3938
|
+
*
|
|
3939
|
+
* const status = await client.zone.getDepositStatus({
|
|
3940
|
+
* tempoBlockNumber: 1n,
|
|
3941
|
+
* })
|
|
3942
|
+
* ```
|
|
3943
|
+
*
|
|
3944
|
+
* @param parameters - Parameters.
|
|
3945
|
+
* @returns The deposit status.
|
|
3946
|
+
*/
|
|
3947
|
+
getDepositStatus: (
|
|
3948
|
+
parameters: zoneActions.getDepositStatus.Parameters,
|
|
3949
|
+
) => Promise<zoneActions.getDepositStatus.ReturnType>
|
|
3950
|
+
/**
|
|
3951
|
+
* Returns the withdrawal fee for a given gas limit.
|
|
3952
|
+
*
|
|
3953
|
+
* @example
|
|
3954
|
+
* ```ts
|
|
3955
|
+
* import { createClient } from 'viem'
|
|
3956
|
+
* import { http, zoneModerato } from 'viem/tempo/zones'
|
|
3957
|
+
* import { tempoActions } from 'viem/tempo'
|
|
3958
|
+
*
|
|
3959
|
+
* const client = createClient({
|
|
3960
|
+
* chain: zoneModerato(7),
|
|
3961
|
+
* transport: http(),
|
|
3962
|
+
* }).extend(tempoActions())
|
|
3963
|
+
*
|
|
3964
|
+
* const fee = await client.zone.getWithdrawalFee()
|
|
3965
|
+
* ```
|
|
3966
|
+
*
|
|
3967
|
+
* @param parameters - Parameters.
|
|
3968
|
+
* @returns The withdrawal fee.
|
|
3969
|
+
*/
|
|
3970
|
+
getWithdrawalFee: (
|
|
3971
|
+
parameters?: zoneActions.getWithdrawalFee.Parameters,
|
|
3972
|
+
) => Promise<zoneActions.getWithdrawalFee.ReturnType>
|
|
3973
|
+
/**
|
|
3974
|
+
* Returns the current zone metadata.
|
|
3975
|
+
*
|
|
3976
|
+
* @example
|
|
3977
|
+
* ```ts
|
|
3978
|
+
* import { createClient } from 'viem'
|
|
3979
|
+
* import { http, zoneModerato } from 'viem/tempo/zones'
|
|
3980
|
+
* import { tempoActions } from 'viem/tempo'
|
|
3981
|
+
*
|
|
3982
|
+
* const client = createClient({
|
|
3983
|
+
* chain: zoneModerato(7),
|
|
3984
|
+
* transport: http(),
|
|
3985
|
+
* }).extend(tempoActions())
|
|
3986
|
+
*
|
|
3987
|
+
* const info = await client.zone.getZoneInfo()
|
|
3988
|
+
* ```
|
|
3989
|
+
*
|
|
3990
|
+
* @returns The zone metadata.
|
|
3991
|
+
*/
|
|
3992
|
+
getZoneInfo: () => Promise<zoneActions.getZoneInfo.ReturnType>
|
|
3993
|
+
/**
|
|
3994
|
+
* Requests a withdrawal from a zone to the parent Tempo chain.
|
|
3995
|
+
* Batches approve and withdrawal into a single transaction.
|
|
3996
|
+
*
|
|
3997
|
+
* @example
|
|
3998
|
+
* ```ts
|
|
3999
|
+
* import { createClient } from 'viem'
|
|
4000
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
4001
|
+
* import { http, zoneModerato } from 'viem/tempo/zones'
|
|
4002
|
+
* import { tempoActions } from 'viem/tempo'
|
|
4003
|
+
*
|
|
4004
|
+
* const client = createClient({
|
|
4005
|
+
* account: privateKeyToAccount('0x...'),
|
|
4006
|
+
* chain: zoneModerato(7),
|
|
4007
|
+
* transport: http(),
|
|
4008
|
+
* }).extend(tempoActions())
|
|
4009
|
+
*
|
|
4010
|
+
* const hash = await client.zone.requestWithdrawal({
|
|
4011
|
+
* token: '0x20c0...0001',
|
|
4012
|
+
* amount: 1_000_000n,
|
|
4013
|
+
* })
|
|
4014
|
+
* ```
|
|
4015
|
+
*
|
|
4016
|
+
* @param parameters - Parameters.
|
|
4017
|
+
* @returns The transaction hash.
|
|
4018
|
+
*/
|
|
4019
|
+
requestWithdrawal: (
|
|
4020
|
+
parameters: zoneActions.requestWithdrawal.Parameters<chain, account>,
|
|
4021
|
+
) => Promise<zoneActions.requestWithdrawal.ReturnValue>
|
|
4022
|
+
/**
|
|
4023
|
+
* Requests a withdrawal and waits for the transaction receipt.
|
|
4024
|
+
*
|
|
4025
|
+
* @example
|
|
4026
|
+
* ```ts
|
|
4027
|
+
* import { createClient } from 'viem'
|
|
4028
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
4029
|
+
* import { http, zoneModerato } from 'viem/tempo/zones'
|
|
4030
|
+
* import { tempoActions } from 'viem/tempo'
|
|
4031
|
+
*
|
|
4032
|
+
* const client = createClient({
|
|
4033
|
+
* account: privateKeyToAccount('0x...'),
|
|
4034
|
+
* chain: zoneModerato(7),
|
|
4035
|
+
* transport: http(),
|
|
4036
|
+
* }).extend(tempoActions())
|
|
4037
|
+
*
|
|
4038
|
+
* const { receipt } = await client.zone.requestWithdrawalSync({
|
|
4039
|
+
* token: '0x20c0...0001',
|
|
4040
|
+
* amount: 1_000_000n,
|
|
4041
|
+
* })
|
|
4042
|
+
* ```
|
|
4043
|
+
*
|
|
4044
|
+
* @param parameters - Parameters.
|
|
4045
|
+
* @returns The transaction receipt.
|
|
4046
|
+
*/
|
|
4047
|
+
requestWithdrawalSync: (
|
|
4048
|
+
parameters: zoneActions.requestWithdrawalSync.Parameters<chain, account>,
|
|
4049
|
+
) => Promise<zoneActions.requestWithdrawalSync.ReturnValue>
|
|
4050
|
+
/**
|
|
4051
|
+
* Requests a verifiable withdrawal from a zone.
|
|
4052
|
+
*
|
|
4053
|
+
* @example
|
|
4054
|
+
* ```ts
|
|
4055
|
+
* const hash = await client.zone.requestVerifiableWithdrawal({
|
|
4056
|
+
* token: '0x20c0...0001',
|
|
4057
|
+
* amount: 1_000_000n,
|
|
4058
|
+
* revealTo: '0x02abc...def',
|
|
4059
|
+
* })
|
|
4060
|
+
* ```
|
|
4061
|
+
*
|
|
4062
|
+
* @param parameters - Parameters.
|
|
4063
|
+
* @returns The transaction hash.
|
|
4064
|
+
*/
|
|
4065
|
+
requestVerifiableWithdrawal: (
|
|
4066
|
+
parameters: zoneActions.requestVerifiableWithdrawal.Parameters<
|
|
4067
|
+
chain,
|
|
4068
|
+
account
|
|
4069
|
+
>,
|
|
4070
|
+
) => Promise<zoneActions.requestVerifiableWithdrawal.ReturnValue>
|
|
4071
|
+
/**
|
|
4072
|
+
* Requests a verifiable withdrawal and waits for the transaction receipt.
|
|
4073
|
+
*
|
|
4074
|
+
* @example
|
|
4075
|
+
* ```ts
|
|
4076
|
+
* const { receipt } = await client.zone.requestVerifiableWithdrawalSync({
|
|
4077
|
+
* token: '0x20c0...0001',
|
|
4078
|
+
* amount: 1_000_000n,
|
|
4079
|
+
* revealTo: '0x02abc...def',
|
|
4080
|
+
* })
|
|
4081
|
+
* ```
|
|
4082
|
+
*
|
|
4083
|
+
* @param parameters - Parameters.
|
|
4084
|
+
* @returns The transaction receipt.
|
|
4085
|
+
*/
|
|
4086
|
+
requestVerifiableWithdrawalSync: (
|
|
4087
|
+
parameters: zoneActions.requestVerifiableWithdrawalSync.Parameters<
|
|
4088
|
+
chain,
|
|
4089
|
+
account
|
|
4090
|
+
>,
|
|
4091
|
+
) => Promise<zoneActions.requestVerifiableWithdrawalSync.ReturnValue>
|
|
4092
|
+
/**
|
|
4093
|
+
* Signs and stores a zone authorization token.
|
|
4094
|
+
*
|
|
4095
|
+
* @example
|
|
4096
|
+
* ```ts
|
|
4097
|
+
* import { createClient } from 'viem'
|
|
4098
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
|
4099
|
+
* import { http, zoneModerato } from 'viem/tempo/zones'
|
|
4100
|
+
* import { tempoActions } from 'viem/tempo'
|
|
4101
|
+
*
|
|
4102
|
+
* const client = createClient({
|
|
4103
|
+
* account: privateKeyToAccount('0x...'),
|
|
4104
|
+
* chain: zoneModerato(7),
|
|
4105
|
+
* transport: http(),
|
|
4106
|
+
* }).extend(tempoActions())
|
|
4107
|
+
*
|
|
4108
|
+
* const result = await client.zone.signAuthorizationToken()
|
|
4109
|
+
* ```
|
|
4110
|
+
*
|
|
4111
|
+
* @param parameters - Parameters.
|
|
4112
|
+
* @returns The authentication object and serialized token.
|
|
4113
|
+
*/
|
|
4114
|
+
signAuthorizationToken: (
|
|
4115
|
+
parameters?: zoneActions.signAuthorizationToken.Parameters<account>,
|
|
4116
|
+
) => Promise<zoneActions.signAuthorizationToken.ReturnType>
|
|
4117
|
+
}
|
|
3807
4118
|
}
|
|
3808
4119
|
|
|
3809
4120
|
export function decorator() {
|
|
@@ -4050,6 +4361,32 @@ export function decorator() {
|
|
|
4050
4361
|
updateSync: (parameters) =>
|
|
4051
4362
|
validatorActions.updateSync(client, parameters),
|
|
4052
4363
|
},
|
|
4364
|
+
zone: {
|
|
4365
|
+
deposit: (parameters) => zoneActions.deposit(client, parameters),
|
|
4366
|
+
depositSync: (parameters) =>
|
|
4367
|
+
zoneActions.depositSync(client, parameters),
|
|
4368
|
+
encryptedDeposit: (parameters) =>
|
|
4369
|
+
zoneActions.encryptedDeposit(client, parameters),
|
|
4370
|
+
encryptedDepositSync: (parameters) =>
|
|
4371
|
+
zoneActions.encryptedDepositSync(client, parameters),
|
|
4372
|
+
getAuthorizationTokenInfo: () =>
|
|
4373
|
+
zoneActions.getAuthorizationTokenInfo(client),
|
|
4374
|
+
getDepositStatus: (parameters) =>
|
|
4375
|
+
zoneActions.getDepositStatus(client, parameters),
|
|
4376
|
+
getWithdrawalFee: (parameters) =>
|
|
4377
|
+
zoneActions.getWithdrawalFee(client, parameters),
|
|
4378
|
+
getZoneInfo: () => zoneActions.getZoneInfo(client),
|
|
4379
|
+
requestWithdrawal: (parameters) =>
|
|
4380
|
+
zoneActions.requestWithdrawal(client, parameters),
|
|
4381
|
+
requestWithdrawalSync: (parameters) =>
|
|
4382
|
+
zoneActions.requestWithdrawalSync(client, parameters),
|
|
4383
|
+
requestVerifiableWithdrawal: (parameters) =>
|
|
4384
|
+
zoneActions.requestVerifiableWithdrawal(client, parameters),
|
|
4385
|
+
requestVerifiableWithdrawalSync: (parameters) =>
|
|
4386
|
+
zoneActions.requestVerifiableWithdrawalSync(client, parameters),
|
|
4387
|
+
signAuthorizationToken: (parameters) =>
|
|
4388
|
+
zoneActions.signAuthorizationToken(client, parameters),
|
|
4389
|
+
},
|
|
4053
4390
|
}
|
|
4054
4391
|
}
|
|
4055
4392
|
}
|
package/tempo/Storage.ts
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import type { MaybePromise } from '../types/utils.js'
|
|
2
|
+
|
|
3
|
+
export type Storage = {
|
|
4
|
+
getItem(key: string): MaybePromise<string | null | undefined>
|
|
5
|
+
setItem(key: string, value: string): MaybePromise<void>
|
|
6
|
+
removeItem(key: string): MaybePromise<void>
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Wraps a base storage with an optional key prefix and request
|
|
11
|
+
* deduplication — concurrent `getItem` calls for the same key share
|
|
12
|
+
* a single in-flight promise.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* import * as Storage from 'viem/tempo/zones'
|
|
17
|
+
*
|
|
18
|
+
* const storage = Storage.from(Storage.memory(), { key: 'tempo' })
|
|
19
|
+
* await storage.setItem('foo', 'bar')
|
|
20
|
+
* // stored under "tempo:foo"
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export function from(storage: Storage, options: from.Options = {}): Storage {
|
|
24
|
+
const { key } = options
|
|
25
|
+
const prefix = key ? `${key}:` : ''
|
|
26
|
+
const inflight = new Map<string, Promise<string | null | undefined>>()
|
|
27
|
+
return {
|
|
28
|
+
getItem(k) {
|
|
29
|
+
const fullKey = `${prefix}${k}`
|
|
30
|
+
const existing = inflight.get(fullKey)
|
|
31
|
+
if (existing) return existing
|
|
32
|
+
const result = Promise.resolve(storage.getItem(fullKey)).finally(() => {
|
|
33
|
+
inflight.delete(fullKey)
|
|
34
|
+
})
|
|
35
|
+
inflight.set(fullKey, result)
|
|
36
|
+
return result
|
|
37
|
+
},
|
|
38
|
+
setItem(k, value) {
|
|
39
|
+
const fullKey = `${prefix}${k}`
|
|
40
|
+
inflight.delete(fullKey)
|
|
41
|
+
return storage.setItem(fullKey, value)
|
|
42
|
+
},
|
|
43
|
+
removeItem(k) {
|
|
44
|
+
const fullKey = `${prefix}${k}`
|
|
45
|
+
inflight.delete(fullKey)
|
|
46
|
+
return storage.removeItem(fullKey)
|
|
47
|
+
},
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export declare namespace from {
|
|
52
|
+
type Options = {
|
|
53
|
+
/** Key prefix prepended to all storage keys. */
|
|
54
|
+
key?: string | undefined
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** Creates an in-memory storage backed by a `Map`. */
|
|
59
|
+
export function memory(options: from.Options = {}): Storage {
|
|
60
|
+
const store = new Map<string, string>()
|
|
61
|
+
return from(
|
|
62
|
+
{
|
|
63
|
+
getItem(key) {
|
|
64
|
+
return store.get(key) ?? null
|
|
65
|
+
},
|
|
66
|
+
setItem(key, value) {
|
|
67
|
+
store.set(key, value)
|
|
68
|
+
},
|
|
69
|
+
removeItem(key) {
|
|
70
|
+
store.delete(key)
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
options,
|
|
74
|
+
)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Creates a storage backed by `globalThis.sessionStorage`. */
|
|
78
|
+
export function session(options: from.Options = {}): Storage {
|
|
79
|
+
return from(
|
|
80
|
+
{
|
|
81
|
+
getItem(key) {
|
|
82
|
+
return globalThis.sessionStorage.getItem(key)
|
|
83
|
+
},
|
|
84
|
+
setItem(key, value) {
|
|
85
|
+
try {
|
|
86
|
+
globalThis.sessionStorage.setItem(key, value)
|
|
87
|
+
} catch {}
|
|
88
|
+
},
|
|
89
|
+
removeItem(key) {
|
|
90
|
+
globalThis.sessionStorage.removeItem(key)
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
options,
|
|
94
|
+
)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
let _default: Storage | undefined
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Returns the default storage for the current environment.
|
|
101
|
+
*
|
|
102
|
+
* Returns a singleton so that the zone transport and actions share the
|
|
103
|
+
* same instance without requiring explicit plumbing.
|
|
104
|
+
*
|
|
105
|
+
* - Browser: `sessionStorage`
|
|
106
|
+
* - Server/unsupported: in-memory `Map`-based storage
|
|
107
|
+
*/
|
|
108
|
+
export function defaultStorage(): Storage {
|
|
109
|
+
if (_default) return _default
|
|
110
|
+
if (
|
|
111
|
+
typeof globalThis !== 'undefined' &&
|
|
112
|
+
'sessionStorage' in globalThis &&
|
|
113
|
+
globalThis.sessionStorage
|
|
114
|
+
)
|
|
115
|
+
_default = session()
|
|
116
|
+
else _default = memory()
|
|
117
|
+
return _default
|
|
118
|
+
}
|
package/tempo/actions/index.ts
CHANGED