viem 2.58.6 → 2.58.8
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 +18 -0
- package/_cjs/chains/definitions/primiumTestnet.js +29 -0
- package/_cjs/chains/definitions/primiumTestnet.js.map +1 -0
- package/_cjs/chains/definitions/tsxBastion.js +33 -0
- package/_cjs/chains/definitions/tsxBastion.js.map +1 -0
- package/_cjs/chains/definitions/tsxHorizon.js +33 -0
- package/_cjs/chains/definitions/tsxHorizon.js.map +1 -0
- package/_cjs/chains/definitions/tsxTestnet.js +34 -0
- package/_cjs/chains/definitions/tsxTestnet.js.map +1 -0
- package/_cjs/chains/index.js +14 -6
- package/_cjs/chains/index.js.map +1 -1
- package/_cjs/constants/abis.js +33 -0
- package/_cjs/constants/abis.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/tempo/Account.js.map +1 -1
- package/_cjs/tempo/Client.js.map +1 -1
- package/_cjs/tempo/Transaction.js.map +1 -1
- package/_cjs/tempo/actions/accounts.js.map +1 -1
- package/_cjs/tempo/chainConfig.js +65 -17
- package/_cjs/tempo/chainConfig.js.map +1 -1
- package/_esm/chains/definitions/primiumTestnet.js +26 -0
- package/_esm/chains/definitions/primiumTestnet.js.map +1 -0
- package/_esm/chains/definitions/tsxBastion.js +30 -0
- package/_esm/chains/definitions/tsxBastion.js.map +1 -0
- package/_esm/chains/definitions/tsxHorizon.js +30 -0
- package/_esm/chains/definitions/tsxHorizon.js.map +1 -0
- package/_esm/chains/definitions/tsxTestnet.js +31 -0
- package/_esm/chains/definitions/tsxTestnet.js.map +1 -0
- package/_esm/chains/index.js +4 -0
- package/_esm/chains/index.js.map +1 -1
- package/_esm/constants/abis.js +33 -0
- package/_esm/constants/abis.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/tempo/Account.js.map +1 -1
- package/_esm/tempo/Client.js +2 -1
- package/_esm/tempo/Client.js.map +1 -1
- package/_esm/tempo/Transaction.js.map +1 -1
- package/_esm/tempo/actions/accounts.js +1 -2
- package/_esm/tempo/actions/accounts.js.map +1 -1
- package/_esm/tempo/chainConfig.js +80 -17
- package/_esm/tempo/chainConfig.js.map +1 -1
- package/_types/chains/definitions/primiumTestnet.d.ts +52 -0
- package/_types/chains/definitions/primiumTestnet.d.ts.map +1 -0
- package/_types/chains/definitions/tsxBastion.d.ts +52 -0
- package/_types/chains/definitions/tsxBastion.d.ts.map +1 -0
- package/_types/chains/definitions/tsxHorizon.d.ts +52 -0
- package/_types/chains/definitions/tsxHorizon.d.ts.map +1 -0
- package/_types/chains/definitions/tsxTestnet.d.ts +52 -0
- package/_types/chains/definitions/tsxTestnet.d.ts.map +1 -0
- package/_types/chains/index.d.ts +4 -0
- package/_types/chains/index.d.ts.map +1 -1
- package/_types/constants/abis.d.ts +24 -0
- package/_types/constants/abis.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/tempo/Account.d.ts +0 -1
- package/_types/tempo/Account.d.ts.map +1 -1
- package/_types/tempo/Client.d.ts +2 -1
- package/_types/tempo/Client.d.ts.map +1 -1
- package/_types/tempo/Transaction.d.ts +4 -0
- package/_types/tempo/Transaction.d.ts.map +1 -1
- package/_types/tempo/actions/accounts.d.ts +1 -2
- package/_types/tempo/actions/accounts.d.ts.map +1 -1
- package/_types/tempo/chainConfig.d.ts.map +1 -1
- package/chains/definitions/primiumTestnet.ts +26 -0
- package/chains/definitions/tsxBastion.ts +30 -0
- package/chains/definitions/tsxHorizon.ts +30 -0
- package/chains/definitions/tsxTestnet.ts +31 -0
- package/chains/index.ts +4 -0
- package/constants/abis.ts +33 -0
- package/errors/version.ts +1 -1
- package/package.json +1 -1
- package/tempo/Account.ts +0 -1
- package/tempo/Client.ts +2 -1
- package/tempo/Transaction.ts +4 -0
- package/tempo/actions/accounts.ts +1 -2
- package/tempo/chainConfig.ts +116 -25
package/constants/abis.ts
CHANGED
|
@@ -1707,6 +1707,17 @@ export const erc4626Abi = [
|
|
|
1707
1707
|
stateMutability: 'view',
|
|
1708
1708
|
type: 'function',
|
|
1709
1709
|
},
|
|
1710
|
+
{
|
|
1711
|
+
inputs: [],
|
|
1712
|
+
name: 'decimals',
|
|
1713
|
+
outputs: [
|
|
1714
|
+
{
|
|
1715
|
+
type: 'uint8',
|
|
1716
|
+
},
|
|
1717
|
+
],
|
|
1718
|
+
stateMutability: 'view',
|
|
1719
|
+
type: 'function',
|
|
1720
|
+
},
|
|
1710
1721
|
{
|
|
1711
1722
|
inputs: [
|
|
1712
1723
|
{
|
|
@@ -1817,6 +1828,17 @@ export const erc4626Abi = [
|
|
|
1817
1828
|
stateMutability: 'nonpayable',
|
|
1818
1829
|
type: 'function',
|
|
1819
1830
|
},
|
|
1831
|
+
{
|
|
1832
|
+
inputs: [],
|
|
1833
|
+
name: 'name',
|
|
1834
|
+
outputs: [
|
|
1835
|
+
{
|
|
1836
|
+
type: 'string',
|
|
1837
|
+
},
|
|
1838
|
+
],
|
|
1839
|
+
stateMutability: 'view',
|
|
1840
|
+
type: 'function',
|
|
1841
|
+
},
|
|
1820
1842
|
{
|
|
1821
1843
|
inputs: [
|
|
1822
1844
|
{
|
|
@@ -1910,6 +1932,17 @@ export const erc4626Abi = [
|
|
|
1910
1932
|
stateMutability: 'nonpayable',
|
|
1911
1933
|
type: 'function',
|
|
1912
1934
|
},
|
|
1935
|
+
{
|
|
1936
|
+
inputs: [],
|
|
1937
|
+
name: 'symbol',
|
|
1938
|
+
outputs: [
|
|
1939
|
+
{
|
|
1940
|
+
type: 'string',
|
|
1941
|
+
},
|
|
1942
|
+
],
|
|
1943
|
+
stateMutability: 'view',
|
|
1944
|
+
type: 'function',
|
|
1945
|
+
},
|
|
1913
1946
|
{
|
|
1914
1947
|
inputs: [],
|
|
1915
1948
|
name: 'totalAssets',
|
package/errors/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '2.58.
|
|
1
|
+
export const version = '2.58.8'
|
package/package.json
CHANGED
package/tempo/Account.ts
CHANGED
package/tempo/Client.ts
CHANGED
|
@@ -107,7 +107,8 @@ export type CreateClientErrorType = ErrorType
|
|
|
107
107
|
* client can be created with `createClient()`. Pass `testnet` to use the
|
|
108
108
|
* Tempo testnet, or `chain` to override the chain entirely. Pass `feeToken`
|
|
109
109
|
* to set a default fee token for every transaction. Use `withRelay` with a
|
|
110
|
-
* `Relay.accounts` plugin to
|
|
110
|
+
* `Relay.accounts` plugin, or `http` to a relay that serves the `account_*`
|
|
111
|
+
* methods, to coordinate owner approvals.
|
|
111
112
|
*
|
|
112
113
|
* @example
|
|
113
114
|
* ```ts
|
package/tempo/Transaction.ts
CHANGED
|
@@ -151,6 +151,10 @@ export type TransactionRequestTempo<
|
|
|
151
151
|
/** Fee-payer account, external relay URL, or sponsorship preference. */
|
|
152
152
|
feePayer?: Account | boolean | string | undefined
|
|
153
153
|
feeToken?: TempoAddress.Address | bigint | undefined
|
|
154
|
+
/**
|
|
155
|
+
* Hash of a stored configurable account operation to approve. With an owner account as
|
|
156
|
+
* `account` and no `owner`, the operation names the configurable account.
|
|
157
|
+
*/
|
|
154
158
|
hash?: Hex.Hex | undefined
|
|
155
159
|
keyAuthorization?: KeyAuthorization.Signed<quantity, index> | undefined
|
|
156
160
|
/**
|
|
@@ -34,7 +34,7 @@ import type * as Transaction from '../Transaction.js'
|
|
|
34
34
|
*
|
|
35
35
|
* The precompile validates the config and derives the address from its hash.
|
|
36
36
|
* To derive the address locally, use
|
|
37
|
-
* `AccountConfig.getAddress` or `Account.fromConfig
|
|
37
|
+
* `AccountConfig.getAddress` or `Account.fromConfig` with an initial config.
|
|
38
38
|
*
|
|
39
39
|
* @example
|
|
40
40
|
* ```ts
|
|
@@ -297,7 +297,6 @@ export declare namespace getOperation {
|
|
|
297
297
|
* '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80',
|
|
298
298
|
* )
|
|
299
299
|
* const account = Account.fromConfig({
|
|
300
|
-
* address: 'infer',
|
|
301
300
|
* owners: [owner],
|
|
302
301
|
* })
|
|
303
302
|
* const client = createClient({
|
package/tempo/chainConfig.ts
CHANGED
|
@@ -16,6 +16,10 @@ import type { Client } from '../clients/createClient.js'
|
|
|
16
16
|
import { maxUint256 } from '../constants/number.js'
|
|
17
17
|
import { BaseError } from '../errors/base.js'
|
|
18
18
|
import { ContractFunctionRevertedError } from '../errors/contract.js'
|
|
19
|
+
import {
|
|
20
|
+
MethodNotFoundRpcError,
|
|
21
|
+
MethodNotSupportedRpcError,
|
|
22
|
+
} from '../errors/rpc.js'
|
|
19
23
|
import type { Chain, ChainConfig as viem_ChainConfig } from '../types/chain.js'
|
|
20
24
|
import type { RpcBlock } from '../types/rpc.js'
|
|
21
25
|
import { isAddressEqual } from '../utils/address/isAddressEqual.js'
|
|
@@ -27,7 +31,11 @@ import { getAction } from '../utils/getAction.js'
|
|
|
27
31
|
import { keccak256 } from '../utils/hash/keccak256.js'
|
|
28
32
|
import { recoverAddress } from '../utils/signature/recoverAddress.js'
|
|
29
33
|
import type { SerializeTransactionFn } from '../utils/transaction/serializeTransaction.js'
|
|
30
|
-
import
|
|
34
|
+
import {
|
|
35
|
+
type Account,
|
|
36
|
+
type ConfigurableAccount,
|
|
37
|
+
fromConfig,
|
|
38
|
+
} from './Account.js'
|
|
31
39
|
import {
|
|
32
40
|
getMetadata,
|
|
33
41
|
verifyHash as verifyAccessKey,
|
|
@@ -132,6 +140,46 @@ export const chainConfig = {
|
|
|
132
140
|
}
|
|
133
141
|
|
|
134
142
|
if (request.hash) {
|
|
143
|
+
// The operation hash commits to its account, so an owner account approves alone.
|
|
144
|
+
const approver =
|
|
145
|
+
request.account &&
|
|
146
|
+
typeof request.account !== 'string' &&
|
|
147
|
+
request.account.source === 'root' &&
|
|
148
|
+
!request.owner
|
|
149
|
+
? request.account
|
|
150
|
+
: undefined
|
|
151
|
+
if (approver) {
|
|
152
|
+
const operation = await getStoredOperation(client, request.hash)
|
|
153
|
+
if (
|
|
154
|
+
!operation.config.owners.some(({ owner }) =>
|
|
155
|
+
isAddressEqual(owner, approver.address),
|
|
156
|
+
)
|
|
157
|
+
)
|
|
158
|
+
throw new Error(
|
|
159
|
+
'Owner account is not an owner of the stored account operation.',
|
|
160
|
+
)
|
|
161
|
+
const storedTransaction = Transaction.deserialize(
|
|
162
|
+
operation.transaction as Transaction.TransactionSerializedTempo,
|
|
163
|
+
)
|
|
164
|
+
return {
|
|
165
|
+
...storedTransaction,
|
|
166
|
+
// Serialized zero values must not trigger a new fill of an approved transaction.
|
|
167
|
+
gas: storedTransaction.gas ?? 0n,
|
|
168
|
+
maxFeePerGas: storedTransaction.maxFeePerGas ?? 0n,
|
|
169
|
+
maxPriorityFeePerGas: storedTransaction.maxPriorityFeePerGas ?? 0n,
|
|
170
|
+
// Core preparation sets `from` to this account's address, so it names the sender:
|
|
171
|
+
// the parent of a configurable access key (TIP-1111), else the configurable account.
|
|
172
|
+
account: fromConfig(operation.userAddress ?? operation.account),
|
|
173
|
+
from: operation.userAddress ?? operation.account,
|
|
174
|
+
accountSimulation: {
|
|
175
|
+
...getAccountSimulation({ config: operation.config }),
|
|
176
|
+
...(operation.userAddress ? { signer: operation.account } : {}),
|
|
177
|
+
},
|
|
178
|
+
// A prepared request signs through its account, which delegates to the owner.
|
|
179
|
+
owner: approver,
|
|
180
|
+
} as unknown as typeof r
|
|
181
|
+
}
|
|
182
|
+
|
|
135
183
|
// A configurable access key (TIP-1111) approves as its delegate, for its parent.
|
|
136
184
|
const local = (() => {
|
|
137
185
|
const account = request.account
|
|
@@ -155,19 +203,7 @@ export const chainConfig = {
|
|
|
155
203
|
throw new Error(
|
|
156
204
|
'A Tempo owner account is required to approve a stored configurable account transaction.',
|
|
157
205
|
)
|
|
158
|
-
const
|
|
159
|
-
client,
|
|
160
|
-
getTransaction,
|
|
161
|
-
'getTransaction',
|
|
162
|
-
)({ hash: request.hash })
|
|
163
|
-
const operation =
|
|
164
|
-
'operation' in transaction
|
|
165
|
-
? (transaction.operation as
|
|
166
|
-
| AccountOperation.TransactionOperation
|
|
167
|
-
| undefined)
|
|
168
|
-
: undefined
|
|
169
|
-
if (!operation)
|
|
170
|
-
throw new Error('Expected an account operation transaction.')
|
|
206
|
+
const operation = await getStoredOperation(client, request.hash)
|
|
171
207
|
const parent = local === request.account ? undefined : request.account
|
|
172
208
|
if (
|
|
173
209
|
!isAddressEqual(operation.account, local.address) ||
|
|
@@ -182,15 +218,6 @@ export const chainConfig = {
|
|
|
182
218
|
const storedTransaction = Transaction.deserialize(
|
|
183
219
|
operation.transaction as Transaction.TransactionSerializedTempo,
|
|
184
220
|
)
|
|
185
|
-
const hash = AccountOperation.getHash({
|
|
186
|
-
account: operation.account,
|
|
187
|
-
config: operation.config,
|
|
188
|
-
transaction: operation.transaction,
|
|
189
|
-
type: 'transaction',
|
|
190
|
-
userAddress: operation.userAddress,
|
|
191
|
-
})
|
|
192
|
-
if (hash.toLowerCase() !== request.hash.toLowerCase())
|
|
193
|
-
throw new Error('Account operation hash does not match transaction.')
|
|
194
221
|
return {
|
|
195
222
|
...storedTransaction,
|
|
196
223
|
// Serialized zero values must not trigger a new fill of an approved transaction.
|
|
@@ -262,7 +289,10 @@ export const chainConfig = {
|
|
|
262
289
|
const coordinated =
|
|
263
290
|
(!!configurableIdentity || !!delegate) &&
|
|
264
291
|
!!request.owner &&
|
|
265
|
-
(
|
|
292
|
+
(await supportsAccounts(
|
|
293
|
+
client,
|
|
294
|
+
configurableIdentity?.account ?? delegate!.address,
|
|
295
|
+
))
|
|
266
296
|
if (configurableIdentity) {
|
|
267
297
|
const { account, local } = configurableIdentity
|
|
268
298
|
if (!configurableIdentity.config && !coordinated)
|
|
@@ -289,7 +319,7 @@ export const chainConfig = {
|
|
|
289
319
|
if (delegate) {
|
|
290
320
|
const config =
|
|
291
321
|
delegate.config ??
|
|
292
|
-
((client.
|
|
322
|
+
((await supportsAccounts(client, delegate.address))
|
|
293
323
|
? await getAction(
|
|
294
324
|
client,
|
|
295
325
|
getConfig,
|
|
@@ -657,6 +687,67 @@ async function isRegistered(client: Client, key: KeyAuthorizationManager.Key) {
|
|
|
657
687
|
)
|
|
658
688
|
}
|
|
659
689
|
|
|
690
|
+
/**
|
|
691
|
+
* Reads a stored account operation by its hash, and checks that the hash commits to the
|
|
692
|
+
* operation's account, config, and transaction.
|
|
693
|
+
*/
|
|
694
|
+
async function getStoredOperation(client: Client, hash: Hex.Hex) {
|
|
695
|
+
const transaction = await getAction(
|
|
696
|
+
client,
|
|
697
|
+
getTransaction,
|
|
698
|
+
'getTransaction',
|
|
699
|
+
)({ hash })
|
|
700
|
+
const operation =
|
|
701
|
+
'operation' in transaction
|
|
702
|
+
? (transaction.operation as
|
|
703
|
+
| AccountOperation.TransactionOperation
|
|
704
|
+
| undefined)
|
|
705
|
+
: undefined
|
|
706
|
+
if (!operation) throw new Error('Expected an account operation transaction.')
|
|
707
|
+
const hash_operation = AccountOperation.getHash({
|
|
708
|
+
account: operation.account,
|
|
709
|
+
config: operation.config,
|
|
710
|
+
transaction: operation.transaction,
|
|
711
|
+
type: 'transaction',
|
|
712
|
+
userAddress: operation.userAddress,
|
|
713
|
+
})
|
|
714
|
+
if (hash_operation.toLowerCase() !== hash.toLowerCase())
|
|
715
|
+
throw new Error('Account operation hash does not match transaction.')
|
|
716
|
+
return operation
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
/** Whether each transport serves the `account_*` methods, by transport. */
|
|
720
|
+
const accountsSupport = new WeakMap<object, Promise<boolean>>()
|
|
721
|
+
|
|
722
|
+
/**
|
|
723
|
+
* Whether the client's transport serves the `account_*` methods. Relay transports advertise
|
|
724
|
+
* them; other transports, such as `http` to a relay with `Relay.accounts`, answer one
|
|
725
|
+
* `account_getConfig` probe. Only a definitive answer is cached.
|
|
726
|
+
*/
|
|
727
|
+
async function supportsAccounts(client: Client, address: Address) {
|
|
728
|
+
const { transport } = client
|
|
729
|
+
if ((transport as { accounts?: boolean }).accounts === true) return true
|
|
730
|
+
const cached = accountsSupport.get(transport)
|
|
731
|
+
if (cached) return cached
|
|
732
|
+
const supported = getAction(
|
|
733
|
+
client,
|
|
734
|
+
getConfig,
|
|
735
|
+
'getConfig',
|
|
736
|
+
)({ address }).then(
|
|
737
|
+
() => true,
|
|
738
|
+
(error) => {
|
|
739
|
+
if (
|
|
740
|
+
!(error instanceof MethodNotFoundRpcError) &&
|
|
741
|
+
!(error instanceof MethodNotSupportedRpcError)
|
|
742
|
+
)
|
|
743
|
+
accountsSupport.delete(transport)
|
|
744
|
+
return false
|
|
745
|
+
},
|
|
746
|
+
)
|
|
747
|
+
accountsSupport.set(transport, supported)
|
|
748
|
+
return supported
|
|
749
|
+
}
|
|
750
|
+
|
|
660
751
|
/**
|
|
661
752
|
* Returns whether a request uses an expiring nonce: when asked for, when sponsored,
|
|
662
753
|
* or when another request for the same sender is in flight.
|