viem 2.21.50 → 2.21.52
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +26 -0
- package/_cjs/chains/definitions/boolBetaMainnet.js +24 -0
- package/_cjs/chains/definitions/boolBetaMainnet.js.map +1 -0
- package/_cjs/chains/definitions/corn.js +32 -0
- package/_cjs/chains/definitions/corn.js.map +1 -0
- package/_cjs/chains/definitions/cornTestnet.js +33 -0
- package/_cjs/chains/definitions/cornTestnet.js.map +1 -0
- package/_cjs/chains/definitions/redbellyMainnet.js +27 -0
- package/_cjs/chains/definitions/redbellyMainnet.js.map +1 -0
- package/_cjs/chains/definitions/redbellyTestnet.js +3 -3
- package/_cjs/chains/definitions/redbellyTestnet.js.map +1 -1
- package/_cjs/chains/definitions/sonicTestnet.js +24 -0
- package/_cjs/chains/definitions/sonicTestnet.js.map +1 -0
- package/_cjs/chains/definitions/swissdlt.js +26 -0
- package/_cjs/chains/definitions/swissdlt.js.map +1 -0
- package/_cjs/chains/definitions/worldLand.js +26 -0
- package/_cjs/chains/definitions/worldLand.js.map +1 -0
- package/_cjs/chains/index.js +23 -9
- package/_cjs/chains/index.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/experimental/eip7702/actions/prepareAuthorization.js +44 -0
- package/_cjs/experimental/eip7702/actions/prepareAuthorization.js.map +1 -0
- package/_cjs/experimental/eip7702/actions/signAuthorization.js +3 -30
- package/_cjs/experimental/eip7702/actions/signAuthorization.js.map +1 -1
- package/_cjs/experimental/eip7702/decorators/eip7702.js +2 -0
- package/_cjs/experimental/eip7702/decorators/eip7702.js.map +1 -1
- package/_cjs/experimental/index.js +3 -1
- package/_cjs/experimental/index.js.map +1 -1
- package/_cjs/utils/observe.js +4 -1
- package/_cjs/utils/observe.js.map +1 -1
- package/_esm/chains/definitions/boolBetaMainnet.js +21 -0
- package/_esm/chains/definitions/boolBetaMainnet.js.map +1 -0
- package/_esm/chains/definitions/corn.js +29 -0
- package/_esm/chains/definitions/corn.js.map +1 -0
- package/_esm/chains/definitions/cornTestnet.js +30 -0
- package/_esm/chains/definitions/cornTestnet.js.map +1 -0
- package/_esm/chains/definitions/redbellyMainnet.js +24 -0
- package/_esm/chains/definitions/redbellyMainnet.js.map +1 -0
- package/_esm/chains/definitions/redbellyTestnet.js +3 -3
- package/_esm/chains/definitions/redbellyTestnet.js.map +1 -1
- package/_esm/chains/definitions/sonicTestnet.js +21 -0
- package/_esm/chains/definitions/sonicTestnet.js.map +1 -0
- package/_esm/chains/definitions/swissdlt.js +23 -0
- package/_esm/chains/definitions/swissdlt.js.map +1 -0
- package/_esm/chains/definitions/worldLand.js +23 -0
- package/_esm/chains/definitions/worldLand.js.map +1 -0
- package/_esm/chains/index.js +8 -0
- package/_esm/chains/index.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/experimental/eip7702/actions/prepareAuthorization.js +82 -0
- package/_esm/experimental/eip7702/actions/prepareAuthorization.js.map +1 -0
- package/_esm/experimental/eip7702/actions/signAuthorization.js +3 -30
- package/_esm/experimental/eip7702/actions/signAuthorization.js.map +1 -1
- package/_esm/experimental/eip7702/decorators/eip7702.js +2 -0
- package/_esm/experimental/eip7702/decorators/eip7702.js.map +1 -1
- package/_esm/experimental/index.js +1 -0
- package/_esm/experimental/index.js.map +1 -1
- package/_esm/utils/observe.js +4 -1
- package/_esm/utils/observe.js.map +1 -1
- package/_types/chains/definitions/boolBetaMainnet.d.ts +37 -0
- package/_types/chains/definitions/boolBetaMainnet.d.ts.map +1 -0
- package/_types/chains/definitions/corn.d.ts +34 -0
- package/_types/chains/definitions/corn.d.ts.map +1 -0
- package/_types/chains/definitions/cornTestnet.d.ts +34 -0
- package/_types/chains/definitions/cornTestnet.d.ts.map +1 -0
- package/_types/chains/definitions/redbellyMainnet.d.ts +38 -0
- package/_types/chains/definitions/redbellyMainnet.d.ts.map +1 -0
- package/_types/chains/definitions/redbellyTestnet.d.ts +3 -3
- package/_types/chains/definitions/redbellyTestnet.d.ts.map +1 -1
- package/_types/chains/definitions/sonicTestnet.d.ts +37 -0
- package/_types/chains/definitions/sonicTestnet.d.ts.map +1 -0
- package/_types/chains/definitions/swissdlt.d.ts +37 -0
- package/_types/chains/definitions/swissdlt.d.ts.map +1 -0
- package/_types/chains/definitions/worldLand.d.ts +37 -0
- package/_types/chains/definitions/worldLand.d.ts.map +1 -0
- package/_types/chains/index.d.ts +8 -0
- package/_types/chains/index.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/experimental/eip7702/actions/prepareAuthorization.d.ts +66 -0
- package/_types/experimental/eip7702/actions/prepareAuthorization.d.ts.map +1 -0
- package/_types/experimental/eip7702/actions/signAuthorization.d.ts +3 -15
- package/_types/experimental/eip7702/actions/signAuthorization.d.ts.map +1 -1
- package/_types/experimental/eip7702/decorators/eip7702.d.ts +45 -0
- package/_types/experimental/eip7702/decorators/eip7702.d.ts.map +1 -1
- package/_types/experimental/index.d.ts +1 -0
- package/_types/experimental/index.d.ts.map +1 -1
- package/_types/utils/observe.d.ts.map +1 -1
- package/chains/definitions/boolBetaMainnet.ts +21 -0
- package/chains/definitions/corn.ts +31 -0
- package/chains/definitions/cornTestnet.ts +32 -0
- package/chains/definitions/redbellyMainnet.ts +25 -0
- package/chains/definitions/redbellyTestnet.ts +4 -3
- package/chains/definitions/sonicTestnet.ts +21 -0
- package/chains/definitions/swissdlt.ts +23 -0
- package/chains/definitions/worldLand.ts +23 -0
- package/chains/index.ts +8 -0
- package/errors/version.ts +1 -1
- package/experimental/eip7702/actions/prepareAuthorization.ts +141 -0
- package/experimental/eip7702/actions/signAuthorization.ts +9 -60
- package/experimental/eip7702/decorators/eip7702.ts +53 -0
- package/experimental/index.ts +6 -0
- package/package.json +1 -1
- package/utils/observe.ts +3 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"signAuthorization.d.ts","sourceRoot":"","sources":["../../../../experimental/eip7702/actions/signAuthorization.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,
|
1
|
+
{"version":3,"file":"signAuthorization.d.ts","sourceRoot":"","sources":["../../../../experimental/eip7702/actions/signAuthorization.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AACzD,OAAO,EACL,KAAK,qBAAqB,EAE3B,MAAM,yCAAyC,CAAA;AAChD,OAAO,KAAK,EACV,0BAA0B,IAAI,kCAAkC,EAChE,2BAA2B,IAAI,mCAAmC,EACnE,MAAM,8CAA8C,CAAA;AACrD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAA;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gDAAgD,CAAA;AAC/E,OAAO,EAEL,KAAK,wBAAwB,EAE7B,KAAK,gCAAgC,EACtC,MAAM,4BAA4B,CAAA;AACnC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACzD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AACpD,OAAO,EACL,KAAK,6BAA6B,EAClC,KAAK,8BAA8B,EAEpC,MAAM,2BAA2B,CAAA;AAElC,MAAM,MAAM,2BAA2B,CACrC,OAAO,SAAS,OAAO,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,IACvD,8BAA8B,CAAC,OAAO,CAAC,CAAA;AAE3C,MAAM,MAAM,2BAA2B,GAAG,mCAAmC,CAAA;AAE7E,MAAM,MAAM,0BAA0B,GAClC,qBAAqB,GACrB,wBAAwB,GACxB,gCAAgC,GAChC,6BAA6B,GAC7B,kCAAkC,GAClC,SAAS,CAAA;AAEb;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAsB,iBAAiB,CACrC,KAAK,SAAS,KAAK,GAAG,SAAS,EAC/B,OAAO,SAAS,OAAO,GAAG,SAAS,EAEnC,MAAM,EAAE,MAAM,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,CAAC,EACzC,UAAU,EAAE,2BAA2B,CAAC,OAAO,CAAC,GAC/C,OAAO,CAAC,2BAA2B,CAAC,CAoBtC"}
|
@@ -2,8 +2,53 @@ import type { Client } from '../../../clients/createClient.js';
|
|
2
2
|
import type { Transport } from '../../../clients/transports/createTransport.js';
|
3
3
|
import type { Account } from '../../../types/account.js';
|
4
4
|
import type { Chain } from '../../../types/chain.js';
|
5
|
+
import { type PrepareAuthorizationParameters, type PrepareAuthorizationReturnType } from '../actions/prepareAuthorization.js';
|
5
6
|
import { type SignAuthorizationParameters, type SignAuthorizationReturnType } from '../actions/signAuthorization.js';
|
6
7
|
export type Eip7702Actions<account extends Account | undefined = Account | undefined> = {
|
8
|
+
/**
|
9
|
+
* Prepares an [EIP-7702 Authorization](https://eips.ethereum.org/EIPS/eip-7702) object for signing.
|
10
|
+
* This Action will fill the required fields of the Authorization object if they are not provided (e.g. `nonce` and `chainId`).
|
11
|
+
*
|
12
|
+
* With the prepared Authorization object, you can use [`signAuthorization`](https://viem.sh/experimental/eip7702/signAuthorization) to sign over the Authorization object.
|
13
|
+
*
|
14
|
+
* @param client - Client to use
|
15
|
+
* @param parameters - {@link PrepareAuthorizationParameters}
|
16
|
+
* @returns The prepared Authorization object. {@link PrepareAuthorizationReturnType}
|
17
|
+
*
|
18
|
+
* @example
|
19
|
+
* import { createClient, http } from 'viem'
|
20
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
21
|
+
* import { mainnet } from 'viem/chains'
|
22
|
+
* import { eip7702Actions } from 'viem/experimental'
|
23
|
+
*
|
24
|
+
* const client = createClient({
|
25
|
+
* chain: mainnet,
|
26
|
+
* transport: http(),
|
27
|
+
* }).extend(eip7702Actions())
|
28
|
+
*
|
29
|
+
* const authorization = await client.prepareAuthorization({
|
30
|
+
* account: privateKeyToAccount('0x..'),
|
31
|
+
* contractAddress: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
32
|
+
* })
|
33
|
+
*
|
34
|
+
* @example
|
35
|
+
* // Account Hoisting
|
36
|
+
* import { createClient, http } from 'viem'
|
37
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
38
|
+
* import { mainnet } from 'viem/chains'
|
39
|
+
* import { eip7702Actions } from 'viem/experimental'
|
40
|
+
*
|
41
|
+
* const client = createClient({
|
42
|
+
* account: privateKeyToAccount('0x…'),
|
43
|
+
* chain: mainnet,
|
44
|
+
* transport: http(),
|
45
|
+
* }).extend(eip7702Actions())
|
46
|
+
*
|
47
|
+
* const authorization = await client.prepareAuthorization({
|
48
|
+
* contractAddress: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
49
|
+
* })
|
50
|
+
*/
|
51
|
+
prepareAuthorization: (parameters: PrepareAuthorizationParameters<account>) => Promise<PrepareAuthorizationReturnType>;
|
7
52
|
/**
|
8
53
|
* Signs an [EIP-7702 Authorization](https://eips.ethereum.org/EIPS/eip-7702) object.
|
9
54
|
*
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"eip7702.d.ts","sourceRoot":"","sources":["../../../../experimental/eip7702/decorators/eip7702.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAA;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gDAAgD,CAAA;AAC/E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AACpD,OAAO,EACL,KAAK,2BAA2B,EAChC,KAAK,2BAA2B,EAEjC,MAAM,iCAAiC,CAAA;AAExC,MAAM,MAAM,cAAc,CACxB,OAAO,SAAS,OAAO,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,IACvD;IACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2CG;IACH,iBAAiB,EAAE,CACjB,UAAU,EAAE,2BAA2B,CAAC,OAAO,CAAC,KAC7C,OAAO,CAAC,2BAA2B,CAAC,CAAA;CAC1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SAAS,EAAE,OAAO,CAAC,KACpD,cAAc,CAAC,OAAO,CAAC,CAO3B"}
|
@@ -9,6 +9,7 @@ type Eip5792Actions as WalletActionsEip5792,
|
|
9
9
|
/** @deprecated use `eip5792Actions` instead. */
|
10
10
|
eip5792Actions as walletActionsEip5792, type Eip5792Actions, eip5792Actions, } from './eip5792/decorators/eip5792.js';
|
11
11
|
export { type Eip7702Actions, eip7702Actions, } from './eip7702/decorators/eip7702.js';
|
12
|
+
export { type PrepareAuthorizationParameters, type PrepareAuthorizationReturnType, type PrepareAuthorizationErrorType, prepareAuthorization, } from './eip7702/actions/prepareAuthorization.js';
|
12
13
|
export { type SignAuthorizationParameters, type SignAuthorizationReturnType, type SignAuthorizationErrorType, signAuthorization, } from './eip7702/actions/signAuthorization.js';
|
13
14
|
export { type Authorization, type SignedAuthorization, type AuthorizationList, type SignedAuthorizationList, type SerializedAuthorization, type SerializedAuthorizationList, } from './eip7702/types/authorization.js';
|
14
15
|
export { type RpcAuthorizationList, type RpcAuthorization, } from './eip7702/types/rpc.js';
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../experimental/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,yBAAyB,EAC9B,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAC9B,eAAe,GAChB,MAAM,sCAAsC,CAAA;AAC7C,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,SAAS,GACV,MAAM,gCAAgC,CAAA;AACvC,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,wBAAwB,EAC7B,KAAK,wBAAwB,EAC7B,cAAc,GACf,MAAM,qCAAqC,CAAA;AAC5C,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAC9B,KAAK,yBAAyB,EAC9B,eAAe,GAChB,MAAM,sCAAsC,CAAA;AAC7C,OAAO,EACL,KAAK,uBAAuB,EA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DAAgD;AAChD,KAAK,cAAc,IAAI,oBAAoB;AAC3C,gDAAgD;AAChD,cAAc,IAAI,oBAAoB,EACtC,KAAK,cAAc,EACnB,cAAc,GACf,MAAM,iCAAiC,CAAA;AAExC,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,wBAAwB,EAC7B,cAAc,GACf,MAAM,iCAAiC,CAAA;AAExC,OAAO;AACL,6HAA6H;AAC7H,KAAK,8BAA8B;AACnC,8HAA8H;AAC9H,KAAK,+BAA+B;AACpC,8HAA8H;AAC9H,KAAK,+BAA+B;AACpC,+GAA+G;AAC/G,qBAAqB,GACtB,MAAM,6CAA6C,CAAA;AACpD,OAAO;AACL,0HAA0H;AAC1H,KAAK,2BAA2B;AAChC,2HAA2H;AAC3H,KAAK,4BAA4B;AACjC,2HAA2H;AAC3H,KAAK,4BAA4B;AACjC,4GAA4G;AAC5G,kBAAkB,GACnB,MAAM,0CAA0C,CAAA;AACjD,OAAO;AACL,iIAAiI;AACjI,KAAK,kCAAkC;AACvC,kIAAkI;AAClI,KAAK,mCAAmC;AACxC,kIAAkI;AAClI,KAAK,mCAAmC;AACxC,mHAAmH;AACnH,yBAAyB,GAC1B,MAAM,iDAAiD,CAAA"}
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../experimental/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,yBAAyB,EAC9B,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAC9B,eAAe,GAChB,MAAM,sCAAsC,CAAA;AAC7C,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,SAAS,GACV,MAAM,gCAAgC,CAAA;AACvC,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,wBAAwB,EAC7B,KAAK,wBAAwB,EAC7B,cAAc,GACf,MAAM,qCAAqC,CAAA;AAC5C,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAC9B,KAAK,yBA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I,CAAC,CAAC,CAAA;AAItC;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,SAAS,SAAS,SAAS,EACjD,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,SAAS,EACpB,EAAE,EAAE,YAAY,CAAC,SAAS,CAAC,cA6C5B"}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { defineChain } from '../../utils/chain/defineChain.js'
|
2
|
+
|
3
|
+
export const boolBetaMainnet = /*#__PURE__*/ defineChain({
|
4
|
+
id: 11100,
|
5
|
+
name: 'Bool Beta Mainnet',
|
6
|
+
nativeCurrency: {
|
7
|
+
decimals: 18,
|
8
|
+
name: 'BOL',
|
9
|
+
symbol: 'BOL',
|
10
|
+
},
|
11
|
+
rpcUrls: {
|
12
|
+
default: { http: ['https://beta-rpc-node-http.bool.network'] },
|
13
|
+
},
|
14
|
+
blockExplorers: {
|
15
|
+
default: {
|
16
|
+
name: 'BoolScan',
|
17
|
+
url: 'https://beta-mainnet.boolscan.com/',
|
18
|
+
},
|
19
|
+
},
|
20
|
+
testnet: false,
|
21
|
+
})
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import { defineChain } from '../../utils/chain/defineChain.js'
|
2
|
+
|
3
|
+
const sourceId = 1 // mainnet
|
4
|
+
|
5
|
+
export const corn = /*#__PURE__*/ defineChain({
|
6
|
+
id: 21_000_000,
|
7
|
+
name: 'Corn Maizenet',
|
8
|
+
nativeCurrency: {
|
9
|
+
decimals: 18,
|
10
|
+
name: 'Bitcorn',
|
11
|
+
symbol: 'BTCN',
|
12
|
+
},
|
13
|
+
rpcUrls: {
|
14
|
+
default: { http: ['https://rpc.ankr.com/corn_maizenet'] },
|
15
|
+
},
|
16
|
+
blockExplorers: {
|
17
|
+
default: {
|
18
|
+
name: 'Corn Explorer',
|
19
|
+
url: 'https://cornscan.io',
|
20
|
+
apiUrl:
|
21
|
+
'https://api.routescan.io/v2/network/mainnet/evm/21000000/etherscan/api',
|
22
|
+
},
|
23
|
+
},
|
24
|
+
contracts: {
|
25
|
+
multicall3: {
|
26
|
+
address: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
27
|
+
blockCreated: 3228,
|
28
|
+
},
|
29
|
+
},
|
30
|
+
sourceId,
|
31
|
+
})
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import { defineChain } from '../../utils/chain/defineChain.js'
|
2
|
+
|
3
|
+
const sourceId = 11_155_111 // sepolia
|
4
|
+
|
5
|
+
export const cornTestnet = /*#__PURE__*/ defineChain({
|
6
|
+
id: 21_000_001,
|
7
|
+
name: 'Corn Testnet',
|
8
|
+
nativeCurrency: {
|
9
|
+
decimals: 18,
|
10
|
+
name: 'Bitcorn',
|
11
|
+
symbol: 'BTCN',
|
12
|
+
},
|
13
|
+
rpcUrls: {
|
14
|
+
default: { http: ['https://rpc.ankr.com/corn_testnet'] },
|
15
|
+
},
|
16
|
+
blockExplorers: {
|
17
|
+
default: {
|
18
|
+
name: 'Corn Testnet Explorer',
|
19
|
+
url: 'https://testnet.cornscan.io',
|
20
|
+
apiUrl:
|
21
|
+
'https://api.routescan.io/v2/network/testnet/evm/21000001/etherscan/api',
|
22
|
+
},
|
23
|
+
},
|
24
|
+
contracts: {
|
25
|
+
multicall3: {
|
26
|
+
address: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
27
|
+
blockCreated: 4886,
|
28
|
+
},
|
29
|
+
},
|
30
|
+
testnet: true,
|
31
|
+
sourceId,
|
32
|
+
})
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import { defineChain } from '../../utils/chain/defineChain.js'
|
2
|
+
|
3
|
+
export const redbellyMainnet = /*#__PURE__*/ defineChain({
|
4
|
+
id: 151,
|
5
|
+
name: 'Redbelly Network Mainnet',
|
6
|
+
nativeCurrency: {
|
7
|
+
name: 'Redbelly Native Coin',
|
8
|
+
symbol: 'RBNT',
|
9
|
+
decimals: 18,
|
10
|
+
},
|
11
|
+
rpcUrls: {
|
12
|
+
default: {
|
13
|
+
http: ['https://governors.mainnet.redbelly.network'],
|
14
|
+
},
|
15
|
+
},
|
16
|
+
blockExplorers: {
|
17
|
+
default: {
|
18
|
+
name: 'Routescan',
|
19
|
+
url: 'https://redbelly.routescan.io',
|
20
|
+
apiUrl:
|
21
|
+
'https://api.routescan.io/v2/network/mainnet/evm/151/etherscan/api',
|
22
|
+
},
|
23
|
+
},
|
24
|
+
testnet: false,
|
25
|
+
})
|
@@ -15,9 +15,10 @@ export const redbellyTestnet = /*#__PURE__*/ defineChain({
|
|
15
15
|
},
|
16
16
|
blockExplorers: {
|
17
17
|
default: {
|
18
|
-
name: '
|
19
|
-
url: 'https://
|
20
|
-
apiUrl:
|
18
|
+
name: 'Routescan',
|
19
|
+
url: 'https://redbelly.testnet.routescan.io',
|
20
|
+
apiUrl:
|
21
|
+
'https://api.routescan.io/v2/network/testnet/evm/153_2/etherscan/api',
|
21
22
|
},
|
22
23
|
},
|
23
24
|
testnet: true,
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { defineChain } from '../../utils/chain/defineChain.js'
|
2
|
+
|
3
|
+
export const sonicTestnet = /*#__PURE__*/ defineChain({
|
4
|
+
id: 64_165,
|
5
|
+
name: 'Sonic Testnet',
|
6
|
+
nativeCurrency: {
|
7
|
+
decimals: 18,
|
8
|
+
name: 'Sonic',
|
9
|
+
symbol: 'S',
|
10
|
+
},
|
11
|
+
rpcUrls: {
|
12
|
+
default: { http: ['https://rpc.testnet.soniclabs.com'] },
|
13
|
+
},
|
14
|
+
blockExplorers: {
|
15
|
+
default: {
|
16
|
+
name: 'Sonic Testnet Explorer',
|
17
|
+
url: 'https://testnet.soniclabs.com/',
|
18
|
+
},
|
19
|
+
},
|
20
|
+
testnet: true,
|
21
|
+
})
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import { defineChain } from '../../utils/chain/defineChain.js'
|
2
|
+
|
3
|
+
export const swissdlt = /*#__PURE__*/ defineChain({
|
4
|
+
id: 94,
|
5
|
+
name: 'SwissDLT Mainnet',
|
6
|
+
nativeCurrency: {
|
7
|
+
decimals: 18,
|
8
|
+
name: 'BCTS',
|
9
|
+
symbol: 'BCTS',
|
10
|
+
},
|
11
|
+
rpcUrls: {
|
12
|
+
default: {
|
13
|
+
http: ['https://rpc.swissdlt.ch'],
|
14
|
+
},
|
15
|
+
},
|
16
|
+
blockExplorers: {
|
17
|
+
default: {
|
18
|
+
name: 'SwissDLT Explorer',
|
19
|
+
url: 'https://explorer.swissdlt.ch',
|
20
|
+
},
|
21
|
+
},
|
22
|
+
testnet: false,
|
23
|
+
})
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import { defineChain } from '../../utils/chain/defineChain.js'
|
2
|
+
|
3
|
+
export const worldLand = /*#__PURE__*/ defineChain({
|
4
|
+
id: 103,
|
5
|
+
name: 'WorldLand Mainnet',
|
6
|
+
nativeCurrency: {
|
7
|
+
decimals: 18,
|
8
|
+
name: 'WLC',
|
9
|
+
symbol: 'WLC',
|
10
|
+
},
|
11
|
+
rpcUrls: {
|
12
|
+
default: {
|
13
|
+
http: ['https://seoul.worldland.foundation'],
|
14
|
+
},
|
15
|
+
},
|
16
|
+
blockExplorers: {
|
17
|
+
default: {
|
18
|
+
name: 'WorldLand Scan',
|
19
|
+
url: 'https://scan.worldland.foundation',
|
20
|
+
},
|
21
|
+
},
|
22
|
+
testnet: false,
|
23
|
+
})
|
package/chains/index.ts
CHANGED
@@ -59,6 +59,7 @@ export { bob } from './definitions/bob.js'
|
|
59
59
|
export { boba } from './definitions/boba.js'
|
60
60
|
export { bobaSepolia } from './definitions/bobaSepolia.js'
|
61
61
|
export { bobSepolia } from './definitions/bobSepolia.js'
|
62
|
+
export { boolBetaMainnet } from './definitions/boolBetaMainnet.js'
|
62
63
|
export { botanixTestnet } from './definitions/botanixTestnet.js'
|
63
64
|
export { bounceBit } from './definitions/bounceBit.js'
|
64
65
|
export { bounceBitTestnet } from './definitions/bounceBitTestnet.js'
|
@@ -86,6 +87,8 @@ export { coinex } from './definitions/coinex.js'
|
|
86
87
|
export { confluxESpace } from './definitions/confluxESpace.js'
|
87
88
|
export { confluxESpaceTestnet } from './definitions/confluxESpaceTestnet.js'
|
88
89
|
export { coreDao } from './definitions/coreDao.js'
|
90
|
+
export { corn } from './definitions/corn.js'
|
91
|
+
export { cornTestnet } from './definitions/cornTestnet.js'
|
89
92
|
export { crab } from './definitions/crab.js'
|
90
93
|
export { cronos } from './definitions/cronos.js'
|
91
94
|
export { cronosTestnet } from './definitions/cronosTestnet.js'
|
@@ -135,6 +138,7 @@ export { evmosTestnet } from './definitions/evmosTestnet.js'
|
|
135
138
|
export { excelonMainnet } from './definitions/excelonMainnet.js'
|
136
139
|
export { expanse } from './definitions/expanse.js'
|
137
140
|
export { fantom } from './definitions/fantom.js'
|
141
|
+
/** @deprecated Use `sonicTestnet` instead. */
|
138
142
|
export { fantomSonicTestnet } from './definitions/fantomSonicTestnet.js'
|
139
143
|
export { fantomTestnet } from './definitions/fantomTestnet.js'
|
140
144
|
export { fibo } from './definitions/fibo.js'
|
@@ -321,6 +325,7 @@ export { ql1 } from './definitions/ql1.js'
|
|
321
325
|
export { qMainnet } from './definitions/qMainnet.js'
|
322
326
|
export { qTestnet } from './definitions/qTestnet.js'
|
323
327
|
export { real } from './definitions/real.js'
|
328
|
+
export { redbellyMainnet } from './definitions/redbellyMainnet.js'
|
324
329
|
export { redbellyTestnet } from './definitions/redbellyTestnet.js'
|
325
330
|
export { redstone } from './definitions/redstone.js'
|
326
331
|
export { rei } from './definitions/rei.js'
|
@@ -376,6 +381,7 @@ export { sketchpad } from './definitions/sketchpad.js'
|
|
376
381
|
export { snax } from './definitions/snax.js'
|
377
382
|
export { snaxTestnet } from './definitions/snaxTestnet.js'
|
378
383
|
export { soneiumMinato } from './definitions/soneiumMinato.js'
|
384
|
+
export { sonicTestnet } from './definitions/sonicTestnet.js'
|
379
385
|
export { songbird } from './definitions/songbird.js'
|
380
386
|
export { songbirdTestnet } from './definitions/songbirdTestnet.js'
|
381
387
|
export { sophon } from './definitions/sophon.js'
|
@@ -389,6 +395,7 @@ export { superposition } from './definitions/superposition.js'
|
|
389
395
|
export { swan } from './definitions/swan.js'
|
390
396
|
export { swanProximaTestnet } from './definitions/swanProximaTestnet.js'
|
391
397
|
export { swanSaturnTestnet } from './definitions/swanSaturnTestnet.js'
|
398
|
+
export { swissdlt } from './definitions/swissdlt.js'
|
392
399
|
export { syscoin } from './definitions/syscoin.js'
|
393
400
|
export { syscoinTestnet } from './definitions/syscoinTestnet.js'
|
394
401
|
export { taiko } from './definitions/taiko.js'
|
@@ -433,6 +440,7 @@ export { wemix } from './definitions/wemix.js'
|
|
433
440
|
export { wemixTestnet } from './definitions/wemixTestnet.js'
|
434
441
|
export { worldchain } from './definitions/worldchain.js'
|
435
442
|
export { worldchainSepolia } from './definitions/worldchainSepolia.js'
|
443
|
+
export { worldLand } from './definitions/worldLand.js'
|
436
444
|
export { xai } from './definitions/xai.js'
|
437
445
|
export { xaiTestnet } from './definitions/xaiTestnet.js'
|
438
446
|
export { xdc } from './definitions/xdc.js'
|
package/errors/version.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const version = '2.21.
|
1
|
+
export const version = '2.21.52'
|
@@ -0,0 +1,141 @@
|
|
1
|
+
import type { Address } from 'abitype'
|
2
|
+
import type { Account } from '../../../accounts/types.js'
|
3
|
+
import {
|
4
|
+
type ParseAccountErrorType,
|
5
|
+
parseAccount,
|
6
|
+
} from '../../../accounts/utils/parseAccount.js'
|
7
|
+
import { getChainId } from '../../../actions/public/getChainId.js'
|
8
|
+
import { getTransactionCount } from '../../../actions/public/getTransactionCount.js'
|
9
|
+
import type { Client } from '../../../clients/createClient.js'
|
10
|
+
import type { Transport } from '../../../clients/transports/createTransport.js'
|
11
|
+
import {
|
12
|
+
AccountNotFoundError,
|
13
|
+
type AccountNotFoundErrorType,
|
14
|
+
} from '../../../errors/account.js'
|
15
|
+
import type { ErrorType } from '../../../errors/utils.js'
|
16
|
+
import type { GetAccountParameter } from '../../../types/account.js'
|
17
|
+
import type { Chain } from '../../../types/chain.js'
|
18
|
+
import type { PartialBy } from '../../../types/utils.js'
|
19
|
+
import { isAddressEqual } from '../../../utils/address/isAddressEqual.js'
|
20
|
+
import type { RequestErrorType } from '../../../utils/buildRequest.js'
|
21
|
+
import { getAction } from '../../../utils/getAction.js'
|
22
|
+
import type { Authorization } from '../types/authorization.js'
|
23
|
+
|
24
|
+
export type PrepareAuthorizationParameters<
|
25
|
+
account extends Account | undefined = Account | undefined,
|
26
|
+
> = GetAccountParameter<account> &
|
27
|
+
PartialBy<Authorization, 'chainId' | 'nonce'> & {
|
28
|
+
/**
|
29
|
+
* Whether the EIP-7702 Transaction will be executed by another Account.
|
30
|
+
*
|
31
|
+
* If not specified, it will be assumed that the EIP-7702 Transaction will
|
32
|
+
* be executed by the Account that signed the Authorization.
|
33
|
+
*/
|
34
|
+
delegate?: true | Address | Account | undefined
|
35
|
+
}
|
36
|
+
|
37
|
+
export type PrepareAuthorizationReturnType = Authorization
|
38
|
+
|
39
|
+
export type PrepareAuthorizationErrorType =
|
40
|
+
| ParseAccountErrorType
|
41
|
+
| RequestErrorType
|
42
|
+
| AccountNotFoundErrorType
|
43
|
+
| ErrorType
|
44
|
+
|
45
|
+
/**
|
46
|
+
* Prepares an [EIP-7702 Authorization](https://eips.ethereum.org/EIPS/eip-7702) object for signing.
|
47
|
+
* This Action will fill the required fields of the Authorization object if they are not provided (e.g. `nonce` and `chainId`).
|
48
|
+
*
|
49
|
+
* With the prepared Authorization object, you can use [`signAuthorization`](https://viem.sh/experimental/eip7702/signAuthorization) to sign over the Authorization object.
|
50
|
+
*
|
51
|
+
* @param client - Client to use
|
52
|
+
* @param parameters - {@link PrepareAuthorizationParameters}
|
53
|
+
* @returns The prepared Authorization object. {@link PrepareAuthorizationReturnType}
|
54
|
+
*
|
55
|
+
* @example
|
56
|
+
* import { createClient, http } from 'viem'
|
57
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
58
|
+
* import { mainnet } from 'viem/chains'
|
59
|
+
* import { prepareAuthorization } from 'viem/experimental'
|
60
|
+
*
|
61
|
+
* const client = createClient({
|
62
|
+
* chain: mainnet,
|
63
|
+
* transport: http(),
|
64
|
+
* })
|
65
|
+
* const authorization = await prepareAuthorization(client, {
|
66
|
+
* account: privateKeyToAccount('0x..'),
|
67
|
+
* contractAddress: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
68
|
+
* })
|
69
|
+
*
|
70
|
+
* @example
|
71
|
+
* // Account Hoisting
|
72
|
+
* import { createClient, http } from 'viem'
|
73
|
+
* import { privateKeyToAccount } from 'viem/accounts'
|
74
|
+
* import { mainnet } from 'viem/chains'
|
75
|
+
* import { prepareAuthorization } from 'viem/experimental'
|
76
|
+
*
|
77
|
+
* const client = createClient({
|
78
|
+
* account: privateKeyToAccount('0x…'),
|
79
|
+
* chain: mainnet,
|
80
|
+
* transport: http(),
|
81
|
+
* })
|
82
|
+
* const authorization = await prepareAuthorization(client, {
|
83
|
+
* contractAddress: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',
|
84
|
+
* })
|
85
|
+
*/
|
86
|
+
export async function prepareAuthorization<
|
87
|
+
chain extends Chain | undefined,
|
88
|
+
account extends Account | undefined,
|
89
|
+
>(
|
90
|
+
client: Client<Transport, chain, account>,
|
91
|
+
parameters: PrepareAuthorizationParameters<account>,
|
92
|
+
): Promise<PrepareAuthorizationReturnType> {
|
93
|
+
const {
|
94
|
+
account: account_ = client.account,
|
95
|
+
contractAddress,
|
96
|
+
chainId,
|
97
|
+
nonce,
|
98
|
+
delegate: delegate_,
|
99
|
+
} = parameters
|
100
|
+
|
101
|
+
if (!account_)
|
102
|
+
throw new AccountNotFoundError({
|
103
|
+
docsPath: '/experimental/eip7702/prepareAuthorization',
|
104
|
+
})
|
105
|
+
const account = parseAccount(account_)
|
106
|
+
|
107
|
+
const delegate = (() => {
|
108
|
+
if (typeof delegate_ === 'boolean') return delegate_
|
109
|
+
if (delegate_) return parseAccount(delegate_)
|
110
|
+
return undefined
|
111
|
+
})()
|
112
|
+
|
113
|
+
const authorization = {
|
114
|
+
contractAddress,
|
115
|
+
chainId,
|
116
|
+
nonce,
|
117
|
+
} as Authorization
|
118
|
+
|
119
|
+
if (typeof authorization.chainId === 'undefined')
|
120
|
+
authorization.chainId =
|
121
|
+
client.chain?.id ??
|
122
|
+
(await getAction(client, getChainId, 'getChainId')({}))
|
123
|
+
|
124
|
+
if (typeof authorization.nonce === 'undefined') {
|
125
|
+
authorization.nonce = await getAction(
|
126
|
+
client,
|
127
|
+
getTransactionCount,
|
128
|
+
'getTransactionCount',
|
129
|
+
)({
|
130
|
+
address: account.address,
|
131
|
+
blockTag: 'pending',
|
132
|
+
})
|
133
|
+
if (
|
134
|
+
!delegate ||
|
135
|
+
(delegate !== true && isAddressEqual(account.address, delegate.address))
|
136
|
+
)
|
137
|
+
authorization.nonce += 1
|
138
|
+
}
|
139
|
+
|
140
|
+
return authorization
|
141
|
+
}
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import type { Address } from 'abitype'
|
2
1
|
import type { Account } from '../../../accounts/types.js'
|
3
2
|
import {
|
4
3
|
type ParseAccountErrorType,
|
@@ -8,8 +7,6 @@ import type {
|
|
8
7
|
SignAuthorizationErrorType as SignAuthorizationErrorType_account,
|
9
8
|
SignAuthorizationReturnType as SignAuthorizationReturnType_account,
|
10
9
|
} from '../../../accounts/utils/signAuthorization.js'
|
11
|
-
import { getChainId } from '../../../actions/public/getChainId.js'
|
12
|
-
import { getTransactionCount } from '../../../actions/public/getTransactionCount.js'
|
13
10
|
import type { Client } from '../../../clients/createClient.js'
|
14
11
|
import type { Transport } from '../../../clients/transports/createTransport.js'
|
15
12
|
import {
|
@@ -19,34 +16,24 @@ import {
|
|
19
16
|
type AccountTypeNotSupportedErrorType,
|
20
17
|
} from '../../../errors/account.js'
|
21
18
|
import type { ErrorType } from '../../../errors/utils.js'
|
22
|
-
import type { GetAccountParameter } from '../../../types/account.js'
|
23
19
|
import type { Chain } from '../../../types/chain.js'
|
24
|
-
import
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
20
|
+
import {
|
21
|
+
type PrepareAuthorizationErrorType,
|
22
|
+
type PrepareAuthorizationParameters,
|
23
|
+
prepareAuthorization,
|
24
|
+
} from './prepareAuthorization.js'
|
29
25
|
|
30
26
|
export type SignAuthorizationParameters<
|
31
27
|
account extends Account | undefined = Account | undefined,
|
32
|
-
> =
|
33
|
-
PartialBy<Authorization, 'chainId' | 'nonce'> & {
|
34
|
-
/**
|
35
|
-
* Whether the EIP-7702 Transaction will be executed by another Account.
|
36
|
-
*
|
37
|
-
* If not specified, it will be assumed that the EIP-7702 Transaction will
|
38
|
-
* be executed by the Account that signed the Authorization.
|
39
|
-
*/
|
40
|
-
delegate?: true | Address | Account | undefined
|
41
|
-
}
|
28
|
+
> = PrepareAuthorizationParameters<account>
|
42
29
|
|
43
30
|
export type SignAuthorizationReturnType = SignAuthorizationReturnType_account
|
44
31
|
|
45
32
|
export type SignAuthorizationErrorType =
|
46
33
|
| ParseAccountErrorType
|
47
|
-
| RequestErrorType
|
48
34
|
| AccountNotFoundErrorType
|
49
35
|
| AccountTypeNotSupportedErrorType
|
36
|
+
| PrepareAuthorizationErrorType
|
50
37
|
| SignAuthorizationErrorType_account
|
51
38
|
| ErrorType
|
52
39
|
|
@@ -99,13 +86,7 @@ export async function signAuthorization<
|
|
99
86
|
client: Client<Transport, chain, account>,
|
100
87
|
parameters: SignAuthorizationParameters<account>,
|
101
88
|
): Promise<SignAuthorizationReturnType> {
|
102
|
-
const {
|
103
|
-
account: account_ = client.account,
|
104
|
-
contractAddress,
|
105
|
-
chainId,
|
106
|
-
nonce,
|
107
|
-
delegate: delegate_,
|
108
|
-
} = parameters
|
89
|
+
const { account: account_ = client.account } = parameters
|
109
90
|
|
110
91
|
if (!account_)
|
111
92
|
throw new AccountNotFoundError({
|
@@ -113,12 +94,6 @@ export async function signAuthorization<
|
|
113
94
|
})
|
114
95
|
const account = parseAccount(account_)
|
115
96
|
|
116
|
-
const delegate = (() => {
|
117
|
-
if (typeof delegate_ === 'boolean') return delegate_
|
118
|
-
if (delegate_) return parseAccount(delegate_)
|
119
|
-
return undefined
|
120
|
-
})()
|
121
|
-
|
122
97
|
if (!account.experimental_signAuthorization)
|
123
98
|
throw new AccountTypeNotSupportedError({
|
124
99
|
docsPath: '/experimental/eip7702/signAuthorization',
|
@@ -128,32 +103,6 @@ export async function signAuthorization<
|
|
128
103
|
type: account.type,
|
129
104
|
})
|
130
105
|
|
131
|
-
const authorization =
|
132
|
-
contractAddress,
|
133
|
-
chainId,
|
134
|
-
nonce,
|
135
|
-
} as Authorization
|
136
|
-
|
137
|
-
if (typeof authorization.chainId === 'undefined')
|
138
|
-
authorization.chainId =
|
139
|
-
client.chain?.id ??
|
140
|
-
(await getAction(client, getChainId, 'getChainId')({}))
|
141
|
-
|
142
|
-
if (typeof authorization.nonce === 'undefined') {
|
143
|
-
authorization.nonce = await getAction(
|
144
|
-
client,
|
145
|
-
getTransactionCount,
|
146
|
-
'getTransactionCount',
|
147
|
-
)({
|
148
|
-
address: account.address,
|
149
|
-
blockTag: 'pending',
|
150
|
-
})
|
151
|
-
if (
|
152
|
-
!delegate ||
|
153
|
-
(delegate !== true && isAddressEqual(account.address, delegate.address))
|
154
|
-
)
|
155
|
-
authorization.nonce += 1
|
156
|
-
}
|
157
|
-
|
106
|
+
const authorization = await prepareAuthorization(client, parameters)
|
158
107
|
return account.experimental_signAuthorization(authorization)
|
159
108
|
}
|