FRE-600: Fix code review blockers

- Consolidated duplicate UndoManagers to single instance
- Fixed connection promise to only resolve on 'connected' status
- Fixed WebSocketProvider import (WebsocketProvider)
- Added proper doc.destroy() cleanup
- Renamed isPresenceInitialized property to avoid conflict

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
2026-04-25 00:08:01 -04:00
parent 65b552bb08
commit 7c684a42cc
48450 changed files with 5679671 additions and 383 deletions

2274
node_modules/viem/_esm/tempo/Abis.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

1
node_modules/viem/_esm/tempo/Abis.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

402
node_modules/viem/_esm/tempo/Account.js generated vendored Normal file
View File

@@ -0,0 +1,402 @@
import * as Address from 'ox/Address';
import * as Hex from 'ox/Hex';
import * as P256 from 'ox/P256';
import * as PublicKey from 'ox/PublicKey';
import * as Secp256k1 from 'ox/Secp256k1';
import * as Signature from 'ox/Signature';
import { KeyAuthorization, SignatureEnvelope } from 'ox/tempo';
import * as WebAuthnP256 from 'ox/WebAuthnP256';
import * as WebCryptoP256 from 'ox/WebCryptoP256';
import { parseAccount } from '../accounts/utils/parseAccount.js';
import { hashAuthorization } from '../utils/authorization/hashAuthorization.js';
import { keccak256 } from '../utils/hash/keccak256.js';
import { hashMessage } from '../utils/signature/hashMessage.js';
import { hashTypedData } from '../utils/signature/hashTypedData.js';
import * as Transaction from './Transaction.js';
/** Instantiates an Account. */
export function from(parameters) {
const { access } = parameters;
if (access)
return fromAccessKey(parameters);
return fromRoot(parameters);
}
/**
* Instantiates an Account from a headless WebAuthn credential (P256 private key).
*
* @example
* ```ts
* import { Account } from 'viem/tempo'
*
* const account = Account.fromHeadlessWebAuthn('0x...')
* ```
*
* @param privateKey P256 private key.
* @returns Account.
*/
export function fromHeadlessWebAuthn(privateKey, options) {
const { access, rpId, origin, internal_version } = options;
const publicKey = P256.getPublicKey({ privateKey });
return from({
access,
internal_version,
keyType: 'webAuthn',
publicKey,
async sign({ hash }) {
const { metadata, payload } = WebAuthnP256.getSignPayload({
...options,
challenge: hash,
rpId,
origin,
});
const signature = P256.sign({
payload,
privateKey,
hash: true,
});
return SignatureEnvelope.serialize({
metadata,
signature,
publicKey,
type: 'webAuthn',
});
},
});
}
/**
* Instantiates an Account from a P256 private key.
*
* @example
* ```ts
* import { Account } from 'viem/tempo'
*
* const account = Account.fromP256('0x...')
* ```
*
* @param privateKey P256 private key.
* @returns Account.
*/
export function fromP256(privateKey, options = {}) {
const { access, internal_version } = options;
const publicKey = P256.getPublicKey({ privateKey });
return from({
access,
internal_version,
keyType: 'p256',
publicKey,
async sign({ hash }) {
const signature = P256.sign({ payload: hash, privateKey });
return SignatureEnvelope.serialize({
signature,
publicKey,
type: 'p256',
});
},
});
}
/**
* Instantiates an Account from a Secp256k1 private key.
*
* @example
* ```ts
* import { Account } from 'viem/tempo'
*
* const account = Account.fromSecp256k1('0x...')
* ```
*
* @param privateKey Secp256k1 private key.
* @returns Account.
*/
export function fromSecp256k1(privateKey, options = {}) {
const { access, internal_version } = options;
const publicKey = Secp256k1.getPublicKey({ privateKey });
return from({
access,
internal_version,
keyType: 'secp256k1',
publicKey,
async sign(parameters) {
const { hash } = parameters;
const signature = Secp256k1.sign({ payload: hash, privateKey });
return Signature.toHex(signature);
},
});
}
/**
* Instantiates an Account from a WebAuthn credential.
*
* @example
*
* ### Create Passkey + Instantiate Account
*
* Create a credential with `WebAuthnP256.createCredential` and then instantiate
* a Viem Account with `Account.fromWebAuthnP256`.
*
* It is highly recommended to store the credential's public key in an external store
* for future use (ie. for future calls to `WebAuthnP256.getCredential`).
*
* ```ts
* import { Account, WebAuthnP256 } from 'viem/tempo'
* import { publicKeyStore } from './store'
*
* // 1. Create credential
* const credential = await WebAuthnP256.createCredential({ name: 'Example' })
*
* // 2. Instantiate account
* const account = Account.fromWebAuthnP256(credential)
*
* // 3. Store public key
* await publicKeyStore.set(credential.id, credential.publicKey)
*
* ```
*
* @example
*
* ### Get Credential + Instantiate Account
*
* Gets a credential from `WebAuthnP256.getCredential` and then instantiates
* an account with `Account.fromWebAuthnP256`.
*
* The `getPublicKey` function is required to fetch the public key paired with the credential
* from an external store. The public key is required to derive the account's address.
*
* ```ts
* import { Account, WebAuthnP256 } from 'viem/tempo'
* import { publicKeyStore } from './store'
*
* // 1. Get credential
* const credential = await WebAuthnP256.getCredential({
* async getPublicKey(credential) {
* // 2. Get public key from external store.
* return await publicKeyStore.get(credential.id)
* }
* })
*
* // 3. Instantiate account
* const account = Account.fromWebAuthnP256(credential)
* ```
*
* @param credential WebAuthnP256 credential.
* @returns Account.
*/
export function fromWebAuthnP256(credential, options = {}) {
const { id } = credential;
const publicKey = PublicKey.fromHex(credential.publicKey);
return from({
keyType: 'webAuthn',
publicKey,
async sign({ hash }) {
const { metadata, signature } = await WebAuthnP256.sign({
...options,
challenge: hash,
credentialId: id,
});
return SignatureEnvelope.serialize({
publicKey,
metadata,
signature,
type: 'webAuthn',
});
},
});
}
/**
* Instantiates an Account from a P256 private key.
*
* @example
* ```ts
* import { Account } from 'viem/tempo'
* import { WebCryptoP256 } from 'ox'
*
* const keyPair = await WebCryptoP256.createKeyPair()
*
* const account = Account.fromWebCryptoP256(keyPair)
* ```
*
* @param keyPair WebCryptoP256 key pair.
* @returns Account.
*/
export function fromWebCryptoP256(keyPair, options = {}) {
const { access, internal_version } = options;
const { publicKey, privateKey } = keyPair;
return from({
access,
internal_version,
keyType: 'p256',
publicKey,
async sign({ hash }) {
const signature = await WebCryptoP256.sign({ payload: hash, privateKey });
return SignatureEnvelope.serialize({
signature,
prehash: true,
publicKey,
type: 'p256',
});
},
});
}
export async function signKeyAuthorization(account, parameters) {
const { chainId, key, expiry, limits, scopes } = parameters;
const { accessKeyAddress, keyType: type } = resolveAccessKey(key);
const signature = await account.sign({
hash: KeyAuthorization.getSignPayload({
address: accessKeyAddress,
chainId,
expiry,
limits,
scopes,
type,
}),
});
return KeyAuthorization.from({
address: accessKeyAddress,
chainId,
expiry,
limits,
scopes,
signature: SignatureEnvelope.from(signature),
type,
});
}
/** @internal */
// biome-ignore lint/correctness/noUnusedVariables: _
function fromBase(parameters) {
const { keyType = 'secp256k1', parentAddress, source = 'privateKey', internal_version = 'v2', } = parameters;
const address = parentAddress ?? Address.fromPublicKey(parameters.publicKey);
const publicKey = PublicKey.toHex(parameters.publicKey, {
includePrefix: false,
});
async function sign({ hash }) {
const innerHash = parentAddress && internal_version === 'v2'
? keccak256(Hex.concat('0x04', hash, parentAddress))
: hash;
const signature = await parameters.sign({ hash: innerHash });
if (parentAddress)
return SignatureEnvelope.serialize(SignatureEnvelope.from({
userAddress: parentAddress,
inner: SignatureEnvelope.from(signature),
type: 'keychain',
version: internal_version,
}));
return signature;
}
return {
address: Address.checksum(address),
keyType,
sign,
async signAuthorization(parameters) {
const { chainId, nonce } = parameters;
const address = parameters.contractAddress ?? parameters.address;
const signature = await sign({
hash: hashAuthorization({ address, chainId, nonce }),
});
const envelope = SignatureEnvelope.from(signature);
if (envelope.type !== 'secp256k1')
throw new Error('Unsupported signature type. Expected `secp256k1` but got `' +
envelope.type +
'`.');
const { r, s, yParity } = envelope.signature;
return {
address,
chainId,
nonce,
r: Hex.fromNumber(r, { size: 32 }),
s: Hex.fromNumber(s, { size: 32 }),
yParity,
};
},
async signMessage(parameters) {
const { message } = parameters;
return await sign({ hash: hashMessage(message) });
},
async signTransaction(transaction, options) {
const { serializer = Transaction.serialize } = options ?? {};
const presign = (() => {
if ('feePayerSignature' in transaction && transaction.feePayerSignature)
return { ...transaction, feePayerSignature: null };
return transaction;
})();
const signature = await sign({
hash: keccak256(await serializer(presign)),
});
const envelope = SignatureEnvelope.from(signature);
return await serializer(transaction, envelope);
},
async signTypedData(typedData) {
return await sign({ hash: hashTypedData(typedData) });
},
publicKey,
source,
type: 'local',
};
}
/** @internal */
// biome-ignore lint/correctness/noUnusedVariables: _
function fromRoot(parameters) {
const account = fromBase(parameters);
return {
...account,
source: 'root',
async signKeyAuthorization(key, parameters) {
const { chainId, expiry, limits, scopes } = parameters;
const { accessKeyAddress, keyType: type } = resolveAccessKey(key);
const signature = await account.sign({
hash: KeyAuthorization.getSignPayload({
address: accessKeyAddress,
chainId,
expiry,
limits,
scopes,
type,
}),
});
const keyAuthorization = KeyAuthorization.from({
address: accessKeyAddress,
chainId,
expiry,
limits,
scopes,
signature: SignatureEnvelope.from(signature),
type,
});
return keyAuthorization;
},
};
}
// biome-ignore lint/correctness/noUnusedVariables: _
function fromAccessKey(parameters) {
const { access } = parameters;
const { address: parentAddress } = parseAccount(access);
const account = fromBase({ ...parameters, parentAddress });
return {
...account,
accessKeyAddress: Address.fromPublicKey(parameters.publicKey),
source: 'accessKey',
};
}
/** @internal */
export function resolveAccessKey(accessKey) {
if ('accessKeyAddress' in accessKey)
return {
accessKeyAddress: accessKey.accessKeyAddress,
keyType: accessKey.keyType,
};
if ('publicKey' in accessKey && accessKey.publicKey)
return {
accessKeyAddress: Address.fromPublicKey(PublicKey.fromHex(accessKey.publicKey)),
keyType: accessKey.type,
};
return {
accessKeyAddress: accessKey.address,
keyType: accessKey.type,
};
}
// Export types required for inference.
// biome-ignore lint/performance/noBarrelFile: _
export {
/** @deprecated */
KeyAuthorization as z_KeyAuthorization,
/** @deprecated */
SignatureEnvelope as z_SignatureEnvelope,
/** @deprecated */
TxEnvelopeTempo as z_TxEnvelopeTempo, } from 'ox/tempo';
//# sourceMappingURL=Account.js.map

1
node_modules/viem/_esm/tempo/Account.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

13
node_modules/viem/_esm/tempo/Addresses.js generated vendored Normal file
View File

@@ -0,0 +1,13 @@
export const accountImplementation = '0x7702c00000000000000000000000000000000000';
export const accountKeychain = '0xaAAAaaAA00000000000000000000000000000000';
export const accountRegistrar = '0x7702ac0000000000000000000000000000000000';
export const addressRegistry = '0xfdc0000000000000000000000000000000000000';
export const feeManager = '0xfeec000000000000000000000000000000000000';
export const nonceManager = '0x4e4F4E4345000000000000000000000000000000';
export const pathUsd = '0x20c0000000000000000000000000000000000000';
export const stablecoinDex = '0xdec0000000000000000000000000000000000000';
export const tip20Factory = '0x20fc000000000000000000000000000000000000';
export const tip403Registry = '0x403c000000000000000000000000000000000000';
export const validator = '0xcccccccc00000000000000000000000000000000';
export const zoneOutbox = '0x1c00000000000000000000000000000000000002';
//# sourceMappingURL=Addresses.js.map

1
node_modules/viem/_esm/tempo/Addresses.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"Addresses.js","sourceRoot":"","sources":["../../tempo/Addresses.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,qBAAqB,GAChC,4CAA4C,CAAA;AAC9C,MAAM,CAAC,MAAM,eAAe,GAAG,4CAA4C,CAAA;AAC3E,MAAM,CAAC,MAAM,gBAAgB,GAAG,4CAA4C,CAAA;AAC5E,MAAM,CAAC,MAAM,eAAe,GAAG,4CAA4C,CAAA;AAC3E,MAAM,CAAC,MAAM,UAAU,GAAG,4CAA4C,CAAA;AACtE,MAAM,CAAC,MAAM,YAAY,GAAG,4CAA4C,CAAA;AACxE,MAAM,CAAC,MAAM,OAAO,GAAG,4CAA4C,CAAA;AACnE,MAAM,CAAC,MAAM,aAAa,GAAG,4CAA4C,CAAA;AACzE,MAAM,CAAC,MAAM,YAAY,GAAG,4CAA4C,CAAA;AACxE,MAAM,CAAC,MAAM,cAAc,GAAG,4CAA4C,CAAA;AAC1E,MAAM,CAAC,MAAM,SAAS,GAAG,4CAA4C,CAAA;AACrE,MAAM,CAAC,MAAM,UAAU,GAAG,4CAA4C,CAAA"}

2
node_modules/viem/_esm/tempo/Capabilities.js generated vendored Normal file
View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=Capabilities.js.map

1
node_modules/viem/_esm/tempo/Capabilities.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"Capabilities.js","sourceRoot":"","sources":["../../tempo/Capabilities.ts"],"names":[],"mappings":""}

199
node_modules/viem/_esm/tempo/Decorator.js generated vendored Normal file
View File

@@ -0,0 +1,199 @@
import * as accessKeyActions from './actions/accessKey.js';
import * as ammActions from './actions/amm.js';
import * as dexActions from './actions/dex.js';
import * as faucetActions from './actions/faucet.js';
import * as feeActions from './actions/fee.js';
import * as nonceActions from './actions/nonce.js';
import * as policyActions from './actions/policy.js';
import * as rewardActions from './actions/reward.js';
import * as simulateActions from './actions/simulate.js';
import * as tokenActions from './actions/token.js';
import * as validatorActions from './actions/validator.js';
import * as virtualAddressActions from './actions/virtualAddress.js';
import * as zoneActions from './actions/zone.js';
export function decorator() {
return (client) => {
return {
accessKey: {
authorize: (parameters) => accessKeyActions.authorize(client, parameters),
authorizeSync: (parameters) => accessKeyActions.authorizeSync(client, parameters),
getMetadata: (parameters) => accessKeyActions.getMetadata(client, parameters),
getRemainingLimit: (parameters) => accessKeyActions.getRemainingLimit(client, parameters),
revoke: (parameters) => accessKeyActions.revoke(client, parameters),
revokeSync: (parameters) => accessKeyActions.revokeSync(client, parameters),
updateLimit: (parameters) => accessKeyActions.updateLimit(client, parameters),
updateLimitSync: (parameters) => accessKeyActions.updateLimitSync(client, parameters),
},
amm: {
getPool: (parameters) => ammActions.getPool(client, parameters),
getLiquidityBalance: (parameters) => ammActions.getLiquidityBalance(client, parameters),
burn: (parameters) => ammActions.burn(client, parameters),
burnSync: (parameters) => ammActions.burnSync(client, parameters),
mint: (parameters) => ammActions.mint(client, parameters),
mintSync: (parameters) => ammActions.mintSync(client, parameters),
rebalanceSwap: (parameters) => ammActions.rebalanceSwap(client, parameters),
rebalanceSwapSync: (parameters) => ammActions.rebalanceSwapSync(client, parameters),
watchBurn: (parameters) => ammActions.watchBurn(client, parameters),
watchMint: (parameters) => ammActions.watchMint(client, parameters),
watchRebalanceSwap: (parameters) => ammActions.watchRebalanceSwap(client, parameters),
},
dex: {
buy: (parameters) => dexActions.buy(client, parameters),
buySync: (parameters) => dexActions.buySync(client, parameters),
cancel: (parameters) => dexActions.cancel(client, parameters),
cancelSync: (parameters) => dexActions.cancelSync(client, parameters),
cancelStale: (parameters) => dexActions.cancelStale(client, parameters),
cancelStaleSync: (parameters) => dexActions.cancelStaleSync(client, parameters),
createPair: (parameters) => dexActions.createPair(client, parameters),
createPairSync: (parameters) => dexActions.createPairSync(client, parameters),
getBalance: (parameters) => dexActions.getBalance(client, parameters),
getBuyQuote: (parameters) => dexActions.getBuyQuote(client, parameters),
getOrder: (parameters) => dexActions.getOrder(client, parameters),
getTickLevel: (parameters) => dexActions.getTickLevel(client, parameters),
getSellQuote: (parameters) => dexActions.getSellQuote(client, parameters),
place: (parameters) => dexActions.place(client, parameters),
placeSync: (parameters) => dexActions.placeSync(client, parameters),
placeFlip: (parameters) => dexActions.placeFlip(client, parameters),
placeFlipSync: (parameters) => dexActions.placeFlipSync(client, parameters),
sell: (parameters) => dexActions.sell(client, parameters),
sellSync: (parameters) => dexActions.sellSync(client, parameters),
withdraw: (parameters) => dexActions.withdraw(client, parameters),
withdrawSync: (parameters) => dexActions.withdrawSync(client, parameters),
watchFlipOrderPlaced: (parameters) => dexActions.watchFlipOrderPlaced(client, parameters),
watchOrderCancelled: (parameters) => dexActions.watchOrderCancelled(client, parameters),
watchOrderFilled: (parameters) => dexActions.watchOrderFilled(client, parameters),
watchOrderPlaced: (parameters) => dexActions.watchOrderPlaced(client, parameters),
},
faucet: {
fund: (parameters) => faucetActions.fund(client, parameters),
fundSync: (parameters) => faucetActions.fundSync(client, parameters),
},
nonce: {
getNonce: (parameters) => nonceActions.getNonce(client, parameters),
watchNonceIncremented: (parameters) => nonceActions.watchNonceIncremented(client, parameters),
},
fee: {
// @ts-expect-error
getUserToken: (parameters) =>
// @ts-expect-error
feeActions.getUserToken(client, parameters),
setUserToken: (parameters) => feeActions.setUserToken(client, parameters),
setUserTokenSync: (parameters) => feeActions.setUserTokenSync(client, parameters),
watchSetUserToken: (parameters) => feeActions.watchSetUserToken(client, parameters),
},
policy: {
create: (parameters) => policyActions.create(client, parameters),
createSync: (parameters) => policyActions.createSync(client, parameters),
setAdmin: (parameters) => policyActions.setAdmin(client, parameters),
setAdminSync: (parameters) => policyActions.setAdminSync(client, parameters),
modifyWhitelist: (parameters) => policyActions.modifyWhitelist(client, parameters),
modifyWhitelistSync: (parameters) => policyActions.modifyWhitelistSync(client, parameters),
modifyBlacklist: (parameters) => policyActions.modifyBlacklist(client, parameters),
modifyBlacklistSync: (parameters) => policyActions.modifyBlacklistSync(client, parameters),
getData: (parameters) => policyActions.getData(client, parameters),
isAuthorized: (parameters) => policyActions.isAuthorized(client, parameters),
watchCreate: (parameters) => policyActions.watchCreate(client, parameters),
watchAdminUpdated: (parameters) => policyActions.watchAdminUpdated(client, parameters),
watchWhitelistUpdated: (parameters) => policyActions.watchWhitelistUpdated(client, parameters),
watchBlacklistUpdated: (parameters) => policyActions.watchBlacklistUpdated(client, parameters),
},
reward: {
claim: (parameters) => rewardActions.claim(client, parameters),
claimSync: (parameters) => rewardActions.claimSync(client, parameters),
distribute: (parameters) => rewardActions.distribute(client, parameters),
distributeSync: (parameters) => rewardActions.distributeSync(client, parameters),
getUserRewardInfo: (parameters) => rewardActions.getUserRewardInfo(client, parameters),
setRecipient: (parameters) => rewardActions.setRecipient(client, parameters),
setRecipientSync: (parameters) => rewardActions.setRecipientSync(client, parameters),
watchRewardDistributed: (parameters) => rewardActions.watchRewardDistributed(client, parameters),
watchRewardRecipientSet: (parameters) => rewardActions.watchRewardRecipientSet(client, parameters),
},
simulate: {
simulateBlocks: (parameters) => simulateActions.simulateBlocks(client, parameters),
simulateCalls: (parameters) => simulateActions.simulateCalls(client, parameters),
},
token: {
approve: (parameters) => tokenActions.approve(client, parameters),
approveSync: (parameters) => tokenActions.approveSync(client, parameters),
burnBlocked: (parameters) => tokenActions.burnBlocked(client, parameters),
burnBlockedSync: (parameters) => tokenActions.burnBlockedSync(client, parameters),
burn: (parameters) => tokenActions.burn(client, parameters),
burnSync: (parameters) => tokenActions.burnSync(client, parameters),
changeTransferPolicy: (parameters) => tokenActions.changeTransferPolicy(client, parameters),
changeTransferPolicySync: (parameters) => tokenActions.changeTransferPolicySync(client, parameters),
create: (parameters) => tokenActions.create(client, parameters),
createSync: (parameters) => tokenActions.createSync(client, parameters),
getAllowance: (parameters) => tokenActions.getAllowance(client, parameters),
getBalance: (parameters) => tokenActions.getBalance(client, parameters),
getMetadata: (parameters) => tokenActions.getMetadata(client, parameters),
getRoleAdmin: (parameters) => tokenActions.getRoleAdmin(client, parameters),
hasRole: (parameters) => tokenActions.hasRole(client, parameters),
grantRoles: (parameters) => tokenActions.grantRoles(client, parameters),
grantRolesSync: (parameters) => tokenActions.grantRolesSync(client, parameters),
mint: (parameters) => tokenActions.mint(client, parameters),
mintSync: (parameters) => tokenActions.mintSync(client, parameters),
pause: (parameters) => tokenActions.pause(client, parameters),
pauseSync: (parameters) => tokenActions.pauseSync(client, parameters),
renounceRoles: (parameters) => tokenActions.renounceRoles(client, parameters),
renounceRolesSync: (parameters) => tokenActions.renounceRolesSync(client, parameters),
revokeRoles: (parameters) => tokenActions.revokeRoles(client, parameters),
revokeRolesSync: (parameters) => tokenActions.revokeRolesSync(client, parameters),
setSupplyCap: (parameters) => tokenActions.setSupplyCap(client, parameters),
setSupplyCapSync: (parameters) => tokenActions.setSupplyCapSync(client, parameters),
setRoleAdmin: (parameters) => tokenActions.setRoleAdmin(client, parameters),
setRoleAdminSync: (parameters) => tokenActions.setRoleAdminSync(client, parameters),
transfer: (parameters) => tokenActions.transfer(client, parameters),
transferSync: (parameters) => tokenActions.transferSync(client, parameters),
unpause: (parameters) => tokenActions.unpause(client, parameters),
unpauseSync: (parameters) => tokenActions.unpauseSync(client, parameters),
watchApprove: (parameters) => tokenActions.watchApprove(client, parameters),
watchBurn: (parameters) => tokenActions.watchBurn(client, parameters),
watchCreate: (parameters) => tokenActions.watchCreate(client, parameters),
watchMint: (parameters) => tokenActions.watchMint(client, parameters),
watchAdminRole: (parameters) => tokenActions.watchAdminRole(client, parameters),
watchRole: (parameters) => tokenActions.watchRole(client, parameters),
watchTransfer: (parameters) => tokenActions.watchTransfer(client, parameters),
},
validator: {
add: (parameters) => validatorActions.add(client, parameters),
addSync: (parameters) => validatorActions.addSync(client, parameters),
changeOwner: (parameters) => validatorActions.changeOwner(client, parameters),
changeOwnerSync: (parameters) => validatorActions.changeOwnerSync(client, parameters),
changeStatus: (parameters) => validatorActions.changeStatus(client, parameters),
changeStatusSync: (parameters) => validatorActions.changeStatusSync(client, parameters),
get: (parameters) => validatorActions.get(client, parameters),
getByIndex: (parameters) => validatorActions.getByIndex(client, parameters),
getCount: (parameters) => validatorActions.getCount(client, parameters),
getNextFullDkgCeremony: (parameters) => validatorActions.getNextFullDkgCeremony(client, parameters),
getOwner: (parameters) => validatorActions.getOwner(client, parameters),
list: (parameters) => validatorActions.list(client, parameters),
setNextFullDkgCeremony: (parameters) => validatorActions.setNextFullDkgCeremony(client, parameters),
setNextFullDkgCeremonySync: (parameters) => validatorActions.setNextFullDkgCeremonySync(client, parameters),
update: (parameters) => validatorActions.update(client, parameters),
updateSync: (parameters) => validatorActions.updateSync(client, parameters),
},
virtualAddress: {
getMasterAddress: (parameters) => virtualAddressActions.getMasterAddress(client, parameters),
registerMaster: (parameters) => virtualAddressActions.registerMaster(client, parameters),
registerMasterSync: (parameters) => virtualAddressActions.registerMasterSync(client, parameters),
resolve: (parameters) => virtualAddressActions.resolve(client, parameters),
},
zone: {
deposit: (parameters) => zoneActions.deposit(client, parameters),
depositSync: (parameters) => zoneActions.depositSync(client, parameters),
encryptedDeposit: (parameters) => zoneActions.encryptedDeposit(client, parameters),
encryptedDepositSync: (parameters) => zoneActions.encryptedDepositSync(client, parameters),
getAuthorizationTokenInfo: () => zoneActions.getAuthorizationTokenInfo(client),
getDepositStatus: (parameters) => zoneActions.getDepositStatus(client, parameters),
getWithdrawalFee: (parameters) => zoneActions.getWithdrawalFee(client, parameters),
getZoneInfo: () => zoneActions.getZoneInfo(client),
requestWithdrawal: (parameters) => zoneActions.requestWithdrawal(client, parameters),
requestWithdrawalSync: (parameters) => zoneActions.requestWithdrawalSync(client, parameters),
requestVerifiableWithdrawal: (parameters) => zoneActions.requestVerifiableWithdrawal(client, parameters),
requestVerifiableWithdrawalSync: (parameters) => zoneActions.requestVerifiableWithdrawalSync(client, parameters),
signAuthorizationToken: (parameters) => zoneActions.signAuthorizationToken(client, parameters),
},
};
};
}
//# sourceMappingURL=Decorator.js.map

1
node_modules/viem/_esm/tempo/Decorator.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

29
node_modules/viem/_esm/tempo/Expiry.js generated vendored Normal file
View File

@@ -0,0 +1,29 @@
/** Returns a unix timestamp `n` days from now. */
export function days(n) {
return Math.floor(Date.now() / 1000) + n * 24 * 60 * 60;
}
/** Returns a unix timestamp `n` hours from now. */
export function hours(n) {
return Math.floor(Date.now() / 1000) + n * 60 * 60;
}
/** Returns a unix timestamp `n` minutes from now. */
export function minutes(n) {
return Math.floor(Date.now() / 1000) + n * 60;
}
/** Returns a unix timestamp `n` months (30 days) from now. */
export function months(n) {
return Math.floor(Date.now() / 1000) + n * 30 * 24 * 60 * 60;
}
/** Returns a unix timestamp `n` seconds from now. */
export function seconds(n) {
return Math.floor(Date.now() / 1000) + n;
}
/** Returns a unix timestamp `n` weeks from now. */
export function weeks(n) {
return Math.floor(Date.now() / 1000) + n * 7 * 24 * 60 * 60;
}
/** Returns a unix timestamp `n` years (365 days) from now. */
export function years(n) {
return Math.floor(Date.now() / 1000) + n * 365 * 24 * 60 * 60;
}
//# sourceMappingURL=Expiry.js.map

1
node_modules/viem/_esm/tempo/Expiry.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"Expiry.js","sourceRoot":"","sources":["../../tempo/Expiry.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD,MAAM,UAAU,IAAI,CAAC,CAAS;IAC5B,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAA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unities to make this file less duplicated + more simplified with Viem v3.
import * as Hex from 'ox/Hex';
import { Transaction as ox_Transaction, TransactionRequest as ox_TransactionRequest, } from 'ox/tempo';
import { parseAccount } from '../accounts/utils/parseAccount.js';
import { formatTransaction as viem_formatTransaction } from '../utils/formatters/transaction.js';
import { formatTransactionReceipt as viem_formatTransactionReceipt } from '../utils/formatters/transactionReceipt.js';
import { formatTransactionRequest as viem_formatTransactionRequest } from '../utils/formatters/transactionRequest.js';
import { isTempo, } from './Transaction.js';
export function formatTransaction(transaction) {
if (!isTempo(transaction))
return viem_formatTransaction(transaction);
const { feePayerSignature, gasPrice: _, nonce, ...tx } = ox_Transaction.fromRpc(transaction);
return {
...tx,
accessList: tx.accessList,
feePayerSignature: feePayerSignature
? {
r: Hex.fromNumber(feePayerSignature.r, { size: 32 }),
s: Hex.fromNumber(feePayerSignature.s, { size: 32 }),
v: BigInt(feePayerSignature.v ?? 27),
yParity: feePayerSignature.yParity,
}
: undefined,
nonce: Number(nonce),
typeHex: ox_Transaction.toRpcType[tx.type],
type: tx.type,
};
}
export function formatTransactionReceipt(receipt) {
return viem_formatTransactionReceipt(receipt);
}
export function formatTransactionRequest(r, action) {
const request = r;
const account = request.account
? parseAccount(request.account)
: undefined;
// If the request is not a Tempo transaction, route to Viem formatter.
if (!isTempo(request))
return viem_formatTransactionRequest(r, action);
if (action)
request.calls = request.calls ?? [
{
to: r.to ||
(!r.data || r.data === '0x'
? '0x0000000000000000000000000000000000000000'
: undefined),
value: r.value,
data: r.data,
},
];
// If we have marked the transaction as intended to be paid
// by a fee payer (feePayer: true), we will not use the fee token
// as the fee payer will choose their fee token.
if (request.feePayer === true)
delete request.feeToken;
const rpc = ox_TransactionRequest.toRpc({
...request,
type: 'tempo',
});
if (action === 'estimateGas') {
rpc.maxFeePerGas = undefined;
rpc.maxPriorityFeePerGas = undefined;
}
rpc.to = undefined;
rpc.data = undefined;
rpc.value = undefined;
const [keyType, keyData] = (() => {
const type = account && 'keyType' in account ? account.keyType : account?.source;
if (!type)
return [undefined, undefined];
if (type === 'webAuthn')
// TODO: derive correct bytes size of key data based on webauthn create metadata.
return ['webAuthn', `0x${'ff'.repeat(1400)}`];
if (['p256', 'secp256k1'].includes(type))
return [type, undefined];
return [undefined, undefined];
})();
const keyId = account && 'accessKeyAddress' in account
? account.accessKeyAddress
: undefined;
if (account)
rpc.from = account.address;
return {
...rpc,
...(keyData ? { keyData } : {}),
...(keyId ? { keyId } : {}),
...(keyType ? { keyType } : {}),
...(typeof request.feePayer !== 'undefined'
? {
feePayer: typeof request.feePayer === 'object'
? parseAccount(request.feePayer)
: request.feePayer,
}
: {}),
...('feePayerSignature' in request &&
request.feePayerSignature !== undefined
? { feePayerSignature: request.feePayerSignature }
: {}),
};
}
//# sourceMappingURL=Formatters.js.map

1
node_modules/viem/_esm/tempo/Formatters.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"Formatters.js","sourceRoot":"","sources":["../../tempo/Formatters.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAG7F,OAAO,KAAK,GAAG,MAAM,QAAQ,CAAA;AAC7B,OAAO,EACL,WAAW,IAAI,cAAc,EAC7B,kBAAkB,IAAI,qBAAqB,GAC5C,MAAM,UAAU,CAAA;AAEjB,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAA;AAChE,OAAO,EAAE,iBAAiB,IAAI,sBAAsB,EAAE,MAAM,oCAAoC,CAAA;AAChG,OAAO,EAAE,wBAAwB,IAAI,6BAA6B,EAAE,MAAM,2CAA2C,CAAA;AACrH,OAAO,EAAE,wBAAwB,IAAI,6BAA6B,EAAE,MAAM,2CAA2C,CAAA;AAErH,OAAO,EACL,OAAO,GAOR,MAAM,kBAAkB,CAAA;AAEzB,MAAM,UAAU,iBAAiB,CAC/B,WAA2B;IAE3B,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;QAAE,OAAO,sBAAsB,CAAC,WAAoB,CAAC,CAAA;IAE9E,MAAM,EACJ,iBAAi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CAAC,IAAI,CAAC;YAAE,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,CAAA;QAClE,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC,CAAA;IAC/B,CAAC,CAAC,EAAE,CAAA;IAEJ,MAAM,KAAK,GACT,OAAO,IAAI,kBAAkB,IAAI,OAAO;QACtC,CAAC,CAAC,OAAO,CAAC,gBAAgB;QAC1B,CAAC,CAAC,SAAS,CAAA;IAEf,IAAI,OAAO;QAAE,GAAG,CAAC,IAAI,GAAG,OAAO,CAAC,OAAO,CAAA;IAEvC,OAAO;QACL,GAAG,GAAG;QACN,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/B,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3B,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/B,GAAG,CAAC,OAAO,OAAO,CAAC,QAAQ,KAAK,WAAW;YACzC,CAAC,CAAC;gBACE,QAAQ,EACN,OAAO,OAAO,CAAC,QAAQ,KAAK,QAAQ;oBAClC,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,QAAQ,CAAC;oBAChC,CAAC,CAAC,OAAO,CAAC,QAAQ;aACvB;YACH,CAAC,CAAC,EAAE,CAAC;QACP,GAAG,CAAC,mBAAmB,IAAI,OAAO;YAClC,OAAO,CAAC,iBAAiB,KAAK,SAAS;YACrC,CAAC,CAAC,EAAE,iBAAiB,EAAE,OAAO,CAAC,iBAAiB,EAAE;YAClD,CAAC,CAAC,EAAE,CAAC;KACC,CAAA;AACZ,CAAC"}

15
node_modules/viem/_esm/tempo/Hardfork.js generated vendored Normal file
View File

@@ -0,0 +1,15 @@
export const hardforks = [
'genesis',
't0',
't1',
't1a',
't1b',
't1c',
't2',
't3',
];
/** Returns `true` if `current` is before `target`. */
export function lt(current, target) {
return hardforks.indexOf(current) < hardforks.indexOf(target);
}
//# sourceMappingURL=Hardfork.js.map

1
node_modules/viem/_esm/tempo/Hardfork.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"Hardfork.js","sourceRoot":"","sources":["../../tempo/Hardfork.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,SAAS;IACT,IAAI;IACJ,IAAI;IACJ,KAAK;IACL,KAAK;IACL,KAAK;IACL,IAAI;IACJ,IAAI;CACI,CAAA;AAIV,sDAAsD;AACtD,MAAM,UAAU,EAAE,CAAC,OAAe,EAAE,MAAgB;IAClD,OAAO,SAAS,CAAC,OAAO,CAAC,OAAmB,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;AAC3E,CAAC"}

3
node_modules/viem/_esm/tempo/P256.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
// biome-ignore lint/performance/noBarrelFile: _
export { randomPrivateKey } from 'ox/P256';
//# sourceMappingURL=P256.js.map

1
node_modules/viem/_esm/tempo/P256.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"P256.js","sourceRoot":"","sources":["../../tempo/P256.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA"}

96
node_modules/viem/_esm/tempo/Storage.js generated vendored Normal file
View File

@@ -0,0 +1,96 @@
/**
* Wraps a base storage with an optional key prefix and request
* deduplication — concurrent `getItem` calls for the same key share
* a single in-flight promise.
*
* @example
* ```ts
* import * as Storage from 'viem/tempo/zones'
*
* const storage = Storage.from(Storage.memory(), { key: 'tempo' })
* await storage.setItem('foo', 'bar')
* // stored under "tempo:foo"
* ```
*/
export function from(storage, options = {}) {
const { key } = options;
const prefix = key ? `${key}:` : '';
const inflight = new Map();
return {
getItem(k) {
const fullKey = `${prefix}${k}`;
const existing = inflight.get(fullKey);
if (existing)
return existing;
const result = Promise.resolve(storage.getItem(fullKey)).finally(() => {
inflight.delete(fullKey);
});
inflight.set(fullKey, result);
return result;
},
setItem(k, value) {
const fullKey = `${prefix}${k}`;
inflight.delete(fullKey);
return storage.setItem(fullKey, value);
},
removeItem(k) {
const fullKey = `${prefix}${k}`;
inflight.delete(fullKey);
return storage.removeItem(fullKey);
},
};
}
/** Creates an in-memory storage backed by a `Map`. */
export function memory(options = {}) {
const store = new Map();
return from({
getItem(key) {
return store.get(key) ?? null;
},
setItem(key, value) {
store.set(key, value);
},
removeItem(key) {
store.delete(key);
},
}, options);
}
/** Creates a storage backed by `globalThis.sessionStorage`. */
export function session(options = {}) {
return from({
getItem(key) {
return globalThis.sessionStorage.getItem(key);
},
setItem(key, value) {
try {
globalThis.sessionStorage.setItem(key, value);
}
catch { }
},
removeItem(key) {
globalThis.sessionStorage.removeItem(key);
},
}, options);
}
let _default;
/**
* Returns the default storage for the current environment.
*
* Returns a singleton so that the zone transport and actions share the
* same instance without requiring explicit plumbing.
*
* - Browser: `sessionStorage`
* - Server/unsupported: in-memory `Map`-based storage
*/
export function defaultStorage() {
if (_default)
return _default;
if (typeof globalThis !== 'undefined' &&
'sessionStorage' in globalThis &&
globalThis.sessionStorage)
_default = session();
else
_default = memory();
return _default;
}
//# sourceMappingURL=Storage.js.map

1
node_modules/viem/_esm/tempo/Storage.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"Storage.js","sourceRoot":"","sources":["../../tempo/Storage.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,IAAI,CAAC,OAAgB,EAAE,UAAwB,EAAE;IAC/D,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAA;IACvB,MAAM,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,CAAA;IACnC,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA8C,C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C,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;QACvB,CAAC;QACD,UAAU,CAAC,GAAG;YACZ,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;QACnB,CAAC;KACF,EACD,OAAO,CACR,CAAA;AACH,CAAC;AAED,+DAA+D;AAC/D,MAAM,UAAU,OAAO,CAAC,UAAwB,EAAE;IAChD,OAAO,IAAI,CACT;QACE,OAAO,CAAC,GAAG;YACT,OAAO,UAAU,CAAC,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;QAC/C,CAAC;QACD,OAAO,CAAC,GAAG,EAAE,KAAK;YAChB,IAAI,CAAC;gBACH,UAAU,CAAC,cAAc,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;YAC/C,CAAC;YAAC,MAAM,CAAC,CAAA,CAAC;QACZ,CAAC;QACD,UAAU,CAAC,GAAG;YACZ,UAAU,CAAC,cAAc,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;QAC3C,CAAC;KACF,EACD,OAAO,CACR,CAAA;AACH,CAAC;AAED,IAAI,QAA6B,CAAA;AAEjC;;;;;;;;GAQG;AACH,MAAM,UAAU,cAAc;IAC5B,IAAI,QAAQ;QAAE,OAAO,QAAQ,CAAA;IAC7B,IACE,OAAO,UAAU,KAAK,WAAW;QACjC,gBAAgB,IAAI,UAAU;QAC9B,UAAU,CAAC,cAAc;QAEzB,QAAQ,GAAG,OAAO,EAAE,CAAA;;QACjB,QAAQ,GAAG,MAAM,EAAE,CAAA;IACxB,OAAO,QAAQ,CAAA;AACjB,CAAC"}

2
node_modules/viem/_esm/tempo/TokenIds.js generated vendored Normal file
View File

@@ -0,0 +1,2 @@
export const pathUsd = 0n;
//# sourceMappingURL=TokenIds.js.map

1
node_modules/viem/_esm/tempo/TokenIds.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"TokenIds.js","sourceRoot":"","sources":["../../tempo/TokenIds.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,EAAE,CAAA"}

184
node_modules/viem/_esm/tempo/Transaction.js generated vendored Normal file
View File

@@ -0,0 +1,184 @@
// TODO: Find opportunities to make this file less duplicated + more simplified with Viem v3.
import * as Hex from 'ox/Hex';
import * as Secp256k1 from 'ox/Secp256k1';
import * as Signature from 'ox/Signature';
import { SignatureEnvelope, TxEnvelopeTempo as TxTempo, } from 'ox/tempo';
import { getTransactionType as viem_getTransactionType } from '../utils/transaction/getTransactionType.js';
import { parseTransaction as viem_parseTransaction, } from '../utils/transaction/parseTransaction.js';
import { serializeTransaction as viem_serializeTransaction } from '../utils/transaction/serializeTransaction.js';
export function getType(transaction) {
const account = transaction.account;
if ((account?.keyType && account.keyType !== 'secp256k1') ||
account?.source === 'accessKey' ||
typeof transaction.calls !== 'undefined' ||
typeof transaction.feePayer !== 'undefined' ||
typeof transaction.feeToken !== 'undefined' ||
typeof transaction.keyAuthorization !== 'undefined' ||
typeof transaction.nonceKey !== 'undefined' ||
typeof transaction.signature !== 'undefined' ||
typeof transaction.validBefore !== 'undefined' ||
typeof transaction.validAfter !== 'undefined')
return 'tempo';
if (transaction.type)
return transaction.type;
return viem_getTransactionType(transaction);
}
export function isTempo(transaction) {
try {
const type = getType(transaction);
return type === 'tempo';
}
catch {
return false;
}
}
export function deserialize(serializedTransaction) {
const type = Hex.slice(serializedTransaction, 0, 1);
if (type === '0x76' || type === '0x78')
return deserializeTempo(serializedTransaction);
return viem_parseTransaction(serializedTransaction);
}
export async function serialize(transaction, signature) {
// If the transaction is not a Tempo transaction, route to Viem serializer.
if (!isTempo(transaction)) {
if (signature && 'type' in signature && signature.type !== 'secp256k1')
throw new Error('Unsupported signature type. Expected `secp256k1` but got `' +
signature.type +
'`.');
if (signature && 'type' in signature) {
const { r, s, yParity } = signature?.signature;
return viem_serializeTransaction(transaction, {
r: Hex.fromNumber(r, { size: 32 }),
s: Hex.fromNumber(s, { size: 32 }),
yParity,
});
}
return viem_serializeTransaction(transaction, signature);
}
const type = getType(transaction);
if (type === 'tempo')
return serializeTempo(transaction, signature);
throw new Error('Unsupported transaction type');
}
////////////////////////////////////////////////////////////////////////////////////
// Internal
/** @internal */
function deserializeTempo(serializedTransaction) {
const { feePayerSignature, nonce, ...tx } = TxTempo.deserialize(serializedTransaction);
return {
...tx,
nonce: Number(nonce ?? 0n),
feePayerSignature: feePayerSignature
? {
r: Hex.fromNumber(feePayerSignature.r, { size: 32 }),
s: Hex.fromNumber(feePayerSignature.s, { size: 32 }),
yParity: feePayerSignature.yParity,
}
: feePayerSignature,
};
}
/** @internal */
async function serializeTempo(transaction, sig) {
const signature = (() => {
if (transaction.signature)
return transaction.signature;
if (sig && 'type' in sig)
return sig;
if (sig)
return SignatureEnvelope.from({
r: BigInt(sig.r),
s: BigInt(sig.s),
yParity: Number(sig.yParity),
});
return undefined;
})();
const { chainId, feePayer, nonce, ...rest } = transaction;
const feePayerSignature = (() => {
const feePayerSignature = transaction.feePayerSignature;
if (feePayerSignature)
return {
r: BigInt(feePayerSignature.r),
s: BigInt(feePayerSignature.s),
yParity: Number(feePayerSignature.yParity),
};
if (feePayerSignature === null || feePayer)
return null;
return undefined;
})();
const transaction_ox = {
...rest,
calls: rest.calls?.length
? rest.calls
: [
{
to: rest.to ||
(!rest.data || rest.data === '0x'
? '0x0000000000000000000000000000000000000000'
: undefined),
value: rest.value,
data: rest.data,
},
],
chainId: Number(chainId),
feePayerSignature,
type: 'tempo',
...(nonce ? { nonce: BigInt(nonce) } : {}),
};
// If we have marked the transaction as intended to be paid
// by a fee payer (feePayer: true), we will not use the fee token
// as the fee payer will choose their fee token.
if (feePayer === true)
delete transaction_ox.feeToken;
if (signature && typeof transaction.feePayer === 'object') {
const tx = TxTempo.from(transaction_ox, {
signature,
});
const sender = (() => {
if (transaction.from)
return transaction.from;
if (signature.type === 'secp256k1')
return Secp256k1.recoverAddress({
payload: TxTempo.getSignPayload(tx),
signature: signature.signature,
});
throw new Error('Unable to extract sender from transaction or signature.');
})();
const hash = TxTempo.getFeePayerSignPayload(tx, {
sender,
});
const feePayerSignature = await transaction.feePayer.sign({
hash,
});
return TxTempo.serialize(tx, {
feePayerSignature: Signature.from(feePayerSignature),
});
}
if (feePayer === true) {
if (signature)
return TxTempo.serialize(transaction_ox, {
format: 'feePayer',
sender: transaction.from,
signature,
});
return TxTempo.serialize(transaction_ox, {
feePayerSignature: null,
});
}
return TxTempo.serialize(
// If we have specified a fee payer, the user will not be signing over the fee token.
// Defer the fee token signing to the fee payer.
{ ...transaction_ox, ...(feePayer ? { feeToken: undefined } : {}) }, {
feePayerSignature: undefined,
signature,
});
}
// Export types required for inference.
// biome-ignore lint/performance/noBarrelFile: _
export {
/** @deprecated */
KeyAuthorization as z_KeyAuthorization,
/** @deprecated */
SignatureEnvelope as z_SignatureEnvelope,
/** @deprecated */
TxEnvelopeTempo as z_TxEnvelopeTempo, } from 'ox/tempo';
//# sourceMappingURL=Transaction.js.map

1
node_modules/viem/_esm/tempo/Transaction.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

193
node_modules/viem/_esm/tempo/Transport.js generated vendored Normal file
View File

@@ -0,0 +1,193 @@
import * as Address from 'ox/Address';
import * as Hash from 'ox/Hash';
import * as Hex from 'ox/Hex';
import * as Provider from 'ox/Provider';
import * as RpcRequest from 'ox/RpcRequest';
import { getTransactionReceipt } from '../actions/public/getTransactionReceipt.js';
import { sendTransaction } from '../actions/wallet/sendTransaction.js';
import { sendTransactionSync } from '../actions/wallet/sendTransactionSync.js';
import { createClient } from '../clients/createClient.js';
import { createTransport, } from '../clients/transports/createTransport.js';
import * as Transaction from './Transaction.js';
/**
* Creates a relay transport that routes requests between
* the default transport or the relay transport.
*
* All `eth_fillTransaction` requests are sent to the relay with the request's
* `feePayer` value preserved so the relay can decide whether to sponsor the transaction.
*
* The policy parameter controls how the relay handles sponsored transactions:
* - `'sign-only'`: Relay co-signs the transaction and returns it to the client transport, which then broadcasts it via the default transport
* - `'sign-and-broadcast'`: Relay co-signs and broadcasts the transaction directly
*
* @param defaultTransport - The default transport to use.
* @param relayTransport - The relay transport to use.
* @param parameters - Configuration parameters.
* @returns A relay transport.
*/
export function withRelay(defaultTransport, relayTransport, parameters) {
const { policy = 'sign-only' } = parameters ?? {};
return (config) => {
const transport_default = defaultTransport(config);
const transport_relay = relayTransport(config);
return createTransport({
key: withRelay.type,
name: 'Relay Proxy',
async request({ method, params }, options) {
if (method === 'eth_fillTransaction')
return transport_relay.request({ method, params }, options);
if (method === 'eth_sendRawTransactionSync' ||
method === 'eth_sendRawTransaction') {
const serialized = params[0];
const transaction = Transaction.deserialize(serialized);
// Serialized Tempo envelopes encode `feePayer: true` as a missing fee payer
// signature until the relay co-signs the transaction.
if (transaction.feePayerSignature === null) {
// For 'sign-and-broadcast', relay signs and broadcasts
if (policy === 'sign-and-broadcast')
return transport_relay.request({ method, params }, options);
// For 'sign-only', request signature from relay using eth_signRawTransaction
{
// Request signature from relay using eth_signRawTransaction
const signedTransaction = await transport_relay.request({
method: 'eth_signRawTransaction',
params: [serialized],
}, options);
// Broadcast the signed transaction via the default transport
return transport_default.request({ method, params: [signedTransaction] }, options);
}
}
}
return (await transport_default.request({ method, params }, options));
},
type: withRelay.type,
});
};
}
/** @deprecated Use `withRelay` instead. */
export function withFeePayer(defaultTransport, relayTransport, parameters) {
const { policy = 'sign-only' } = parameters ?? {};
return (config) => {
const transport_default = defaultTransport(config);
const transport_relay = relayTransport(config);
return createTransport({
key: withFeePayer.type,
name: 'Relay Proxy',
async request({ method, params }, options) {
if (method === 'eth_fillTransaction') {
const request = params?.[0];
if (request &&
typeof request === 'object' &&
'feePayer' in request &&
request.feePayer === true)
return transport_relay.request({ method, params }, options);
}
if (method === 'eth_sendRawTransactionSync' ||
method === 'eth_sendRawTransaction') {
const serialized = params[0];
const transaction = Transaction.deserialize(serialized);
// Serialized Tempo envelopes encode `feePayer: true` as a missing fee payer
// signature until the relay co-signs the transaction.
if (transaction.feePayerSignature === null) {
// For 'sign-and-broadcast', relay signs and broadcasts
if (policy === 'sign-and-broadcast')
return transport_relay.request({ method, params }, options);
// For 'sign-only', request signature from relay using eth_signRawTransaction
{
// Request signature from relay using eth_signRawTransaction
const signedTransaction = await transport_relay.request({
method: 'eth_signRawTransaction',
params: [serialized],
}, options);
// Broadcast the signed transaction via the default transport
return transport_default.request({ method, params: [signedTransaction] }, options);
}
}
}
return (await transport_default.request({ method, params }, options));
},
type: withFeePayer.type,
});
};
}
/**
* Creates a transport that instruments a compatibility layer for
* `wallet_` RPC actions (`sendCalls`, `getCallsStatus`, etc).
*
* @param transport - Transport to wrap.
* @returns Transport.
*/
export function walletNamespaceCompat(transport, options) {
const { account } = options;
const sendCallsMagic = Hash.keccak256(Hex.fromString('TEMPO_5792'));
return (options) => {
const t = transport(options);
const chain = options.chain;
return {
...t,
async request(args) {
const request = RpcRequest.from(args);
const client = createClient({
chain,
transport,
});
if (request.method === 'wallet_sendCalls') {
const params = request.params[0] ?? {};
const { capabilities, chainId, from } = params;
const { sync, ...properties } = capabilities ?? {};
if (!chainId)
throw new Provider.UnsupportedChainIdError();
if (Number(chainId) !== client.chain.id)
throw new Provider.UnsupportedChainIdError();
if (from && !Address.isEqual(from, account.address))
throw new Provider.DisconnectedError();
const calls = (params.calls ?? []).map((call) => ({
to: call.to,
value: call.value ? BigInt(call.value) : undefined,
data: call.data,
}));
const hash = await (async () => {
if (!sync)
return sendTransaction(client, {
account,
...(properties ? properties : {}),
calls,
});
const { transactionHash } = await sendTransactionSync(client, {
account,
...(properties ? properties : {}),
calls,
});
return transactionHash;
})();
const id = Hex.concat(hash, Hex.padLeft(chainId, 32), sendCallsMagic);
return {
capabilities: { sync },
id,
};
}
if (request.method === 'wallet_getCallsStatus') {
const [id] = request.params ?? [];
if (!id)
throw new Error('`id` not found');
if (!id.endsWith(sendCallsMagic.slice(2)))
throw new Error('`id` not supported');
Hex.assert(id);
const hash = Hex.slice(id, 0, 32);
const chainId = Hex.slice(id, 32, 64);
const receipt = await getTransactionReceipt(client, { hash });
return {
atomic: true,
chainId: Number(chainId),
id,
receipts: [receipt],
status: receipt.status === 'success' ? 200 : 500,
version: '2.0.0',
};
}
return t.request(args);
},
};
};
}
//# sourceMappingURL=Transport.js.map

1
node_modules/viem/_esm/tempo/Transport.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

97
node_modules/viem/_esm/tempo/WebAuthnP256.js generated vendored Normal file
View File

@@ -0,0 +1,97 @@
import * as Bytes from 'ox/Bytes';
import * as PublicKey from 'ox/PublicKey';
import * as WebAuthnP256 from 'ox/WebAuthnP256';
/**
* Creates a WebAuthn credential (ie. a passkey).
*
* This function returns the credential object, which includes the public key.
* It is recommended to store the public key against the credential in an external store
* as it is not possible to extract a public key from a credential after it has been created.
*
* @example
* ```ts
* import { WebAuthnP256 } from 'viem/tempo'
*
* const credential = await WebAuthnP256.createCredential({ name: 'Example' })
* // {
* // id: 'oZ48...',
* // publicKey: '0x...',
* // }
* ```
*
* @param parameters WebAuthnP256 createCredential options.
* @returns WebAuthn credential.
*/
export async function createCredential(parameters) {
const { createFn, label, rpId, userId } = parameters;
const credential = await WebAuthnP256.createCredential({
...parameters,
authenticatorSelection: {
...parameters.authenticatorSelection,
requireResidentKey: true,
residentKey: 'required',
userVerification: 'required',
},
createFn,
extensions: {
...parameters.extensions,
credProps: true,
},
rp: rpId
? {
id: rpId,
name: rpId,
}
: undefined,
name: undefined,
user: {
displayName: label,
id: new Uint8Array(userId ?? Bytes.fromString(label)),
name: label,
},
});
return {
id: credential.id,
publicKey: PublicKey.toHex(credential.publicKey, {
includePrefix: false,
}),
raw: credential.raw,
};
}
/**
* Gets a WebAuthn credential (ie. a passkey), and optionally signs over a digest/hash.
*
* A `getPublicKey` function is required to fetch the public key paired with the credential
* from an external store. It is not possible to extract a public key from a credential after
* the credential has been created with `WebAuthnP256.createCredential`.
*
* @example
* ```ts
* import { WebAuthnP256 } from 'viem/tempo'
*
* const credential = await WebAuthnP256.getCredential({
* async getPublicKey(credential) {
* // Get public key from store
* return store.getPublicKey(credential.id)
* }
* })
* ```
*
* @param parameters WebAuthnP256 getCredential options.
* @returns WebAuthn credential.
*/
export async function getCredential(parameters) {
const { metadata, raw, signature } = await WebAuthnP256.sign({
...parameters,
challenge: parameters.hash ?? '0x',
});
const publicKey = await parameters.getPublicKey(raw);
return {
id: raw.id,
metadata,
publicKey,
raw,
signature,
};
}
//# sourceMappingURL=WebAuthnP256.js.map

1
node_modules/viem/_esm/tempo/WebAuthnP256.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"WebAuthnP256.js","sourceRoot":"","sources":["../../tempo/WebAuthnP256.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,UAAU,CAAA;AAEjC,OAAO,KAAK,SAAS,MAAM,cAAc,CAAA;AACzC,OAAO,KAAK,YAAY,MAAM,iBAAiB,CAAA;AAQ/C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,UAAuC;IAEvC,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,UAAU,CAAA;IACpD,MAAM,UAAU,GAAG,MAAM,YAAY,CAAC,gBAAgB,CAAC;QACrD,GAAG,UAAU;QACb,sBAAsB,EAAE;YACtB,GAAG,UAAU,CAAC,sBAAsB;YACpC,kBAAkB,EAAE,IAAI;YACxB,WAAW,EAAE,UAAU;YACvB,gBAAgB,EAAE,UAAU;SAC7B;QACD,QAAQ;QACR,UAAU,EAAE;YACV,GAAG,UAAU,CAAC,UAAU;YACxB,SAAS,EAAE,IAAI;SAChB;QACD,EAAE,EAAE,IAAI;YACN,CAAC,CAAC;gBACE,EAAE,EAAE,IAAI;gBACR,IAAI,EAAE,IAAI;aACX;YACH,CAAC,CAAC,SAAS;QACb,IAAI,EAAE,SAAkB;QACxB,IAAI,EAAE;YACJ,WAAW,EAAE,KAAK;YAClB,EAAE,EAAE,IAAI,UAAU,CAAC,MAAM,IAAI,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;YACrD,IAAI,EAAE,KAAK;SACZ;KACF,CAAC,CAAA;IACF,OAAO;QACL,EAAE,EAAE,UAAU,CAAC,EAAE;QACjB,SAAS,EAAE,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,SAAS,EAAE;YAC/C,aAAa,EAAE,KAAK;SACrB,CAAC;QACF,GAAG,EAAE,UAAU,CAAC,GAAG;KACpB,CAAA;AACH,CAAC;AAyBD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,UAAoC;IAEpC,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,MAAM,YAAY,CAAC,IAAI,CAAC;QAC3D,GAAG,UAAU;QACb,SAAS,EAAE,UAAU,CAAC,IAAI,IAAI,IAAI;KACnC,CAAC,CAAA;IACF,MAAM,SAAS,GAAG,MAAM,UAAU,CAAC,YAAY,CAAC,GAAG,CAAC,CAAA;IACpD,OAAO;QACL,EAAE,EAAE,GAAG,CAAC,EAAE;QACV,QAAQ;QACR,SAAS;QACT,GAAG;QACH,SAAS;KACV,CAAA;AACH,CAAC"}

3
node_modules/viem/_esm/tempo/WebCryptoP256.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
// biome-ignore lint/performance/noBarrelFile: _
export { createKeyPair } from 'ox/WebCryptoP256';
//# sourceMappingURL=WebCryptoP256.js.map

1
node_modules/viem/_esm/tempo/WebCryptoP256.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"WebCryptoP256.js","sourceRoot":"","sources":["../../tempo/WebCryptoP256.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA"}

594
node_modules/viem/_esm/tempo/actions/accessKey.js generated vendored Normal file
View File

@@ -0,0 +1,594 @@
import { parseAccount } from '../../accounts/utils/parseAccount.js';
import { readContract } from '../../actions/public/readContract.js';
import { sendTransaction } from '../../actions/wallet/sendTransaction.js';
import { sendTransactionSync } from '../../actions/wallet/sendTransactionSync.js';
import { writeContract } from '../../actions/wallet/writeContract.js';
import { writeContractSync } from '../../actions/wallet/writeContractSync.js';
import { parseEventLogs } from '../../utils/abi/parseEventLogs.js';
import * as Abis from '../Abis.js';
import { signKeyAuthorization } from '../Account.js';
import * as Addresses from '../Addresses.js';
import * as Hardfork from '../Hardfork.js';
import { defineCall } from '../internal/utils.js';
/** @internal */
const signatureTypes = {
0: 'secp256k1',
1: 'p256',
2: 'webAuthn',
};
/** @internal */
const spendPolicies = {
true: 'limited',
false: 'unlimited',
};
/**
* Authorizes an access key by signing a key authorization and sending a transaction.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions, Account } from 'viem/tempo'
* import { generatePrivateKey } from 'viem/accounts'
*
* const account = Account.from({ privateKey: '0x...' })
* const client = createClient({
* account,
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' }),
* transport: http(),
* })
*
* const accessKey = Account.fromP256(generatePrivateKey(), {
* access: account,
* })
*
* const hash = await Actions.accessKey.authorize(client, {
* accessKey,
* expiry: Math.floor((Date.now() + 30_000) / 1000),
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction hash.
*/
export async function authorize(client, parameters) {
return authorize.inner(sendTransaction, client, parameters);
}
(function (authorize) {
/** @internal */
async function inner(action, client, parameters) {
const { accessKey, chainId = client.chain?.id, expiry, limits, scopes, ...rest } = parameters;
const account_ = rest.account ?? client.account;
if (!account_)
throw new Error('account is required.');
if (!chainId)
throw new Error('chainId is required.');
const parsed = parseAccount(account_);
const keyAuthorization = await signKeyAuthorization(parsed, {
chainId: BigInt(chainId),
key: accessKey,
expiry,
limits,
scopes,
});
return (await action(client, {
...rest,
keyAuthorization,
}));
}
authorize.inner = inner;
function extractEvent(logs) {
const [log] = parseEventLogs({
abi: Abis.accountKeychain,
logs,
eventName: 'KeyAuthorized',
strict: true,
});
if (!log)
throw new Error('`KeyAuthorized` event not found.');
return log;
}
authorize.extractEvent = extractEvent;
})(authorize || (authorize = {}));
/**
* Authorizes an access key and waits for the transaction receipt.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions, Account } from 'viem/tempo'
* import { generatePrivateKey } from 'viem/accounts'
*
* const account = Account.from({ privateKey: '0x...' })
* const client = createClient({
* account,
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' }),
* transport: http(),
* })
*
* const accessKey = Account.fromP256(generatePrivateKey(), {
* access: account,
* })
*
* const { receipt, ...result } = await Actions.accessKey.authorizeSync(client, {
* accessKey,
* expiry: Math.floor((Date.now() + 30_000) / 1000),
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
export async function authorizeSync(client, parameters) {
const { throwOnReceiptRevert = true, ...rest } = parameters;
const receipt = await authorize.inner(sendTransactionSync, client, {
...rest,
throwOnReceiptRevert,
});
const { args } = authorize.extractEvent(receipt.logs);
return {
...args,
receipt,
};
}
/**
* Revokes an authorized access key.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
* import { privateKeyToAccount } from 'viem/accounts'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' }),
* transport: http(),
* })
*
* const hash = await Actions.accessKey.revoke(client, {
* accessKey: '0x...',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction hash.
*/
export async function revoke(client, parameters) {
return revoke.inner(writeContract, client, parameters);
}
(function (revoke) {
/** @internal */
async function inner(action, client, parameters) {
const { accessKey, ...rest } = parameters;
const call = revoke.call({ accessKey });
return (await action(client, {
...rest,
...call,
}));
}
revoke.inner = inner;
/**
* Defines a call to the `revokeKey` function.
*
* Can be passed as a parameter to:
* - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
* - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
* - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls
*
* @example
* ```ts
* import { createClient, http, walletActions } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' }),
* transport: http(),
* }).extend(walletActions)
*
* const hash = await client.sendTransaction({
* calls: [
* Actions.accessKey.revoke.call({ accessKey: '0x...' }),
* ],
* })
* ```
*
* @param args - Arguments.
* @returns The call.
*/
function call(args) {
const { accessKey } = args;
return defineCall({
address: Addresses.accountKeychain,
abi: Abis.accountKeychain,
functionName: 'revokeKey',
args: [resolveAccessKeyAddress(accessKey)],
});
}
revoke.call = call;
function extractEvent(logs) {
const [log] = parseEventLogs({
abi: Abis.accountKeychain,
logs,
eventName: 'KeyRevoked',
strict: true,
});
if (!log)
throw new Error('`KeyRevoked` event not found.');
return log;
}
revoke.extractEvent = extractEvent;
})(revoke || (revoke = {}));
/**
* Revokes an authorized access key and waits for the transaction receipt.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
* import { privateKeyToAccount } from 'viem/accounts'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' }),
* transport: http(),
* })
*
* const result = await Actions.accessKey.revokeSync(client, {
* accessKey: '0x...',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
export async function revokeSync(client, parameters) {
const { throwOnReceiptRevert = true, ...rest } = parameters;
const receipt = await revoke.inner(writeContractSync, client, {
...rest,
throwOnReceiptRevert,
});
const { args } = revoke.extractEvent(receipt.logs);
return {
...args,
receipt,
};
}
/**
* Updates the spending limit for a specific token on an authorized access key.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
* import { privateKeyToAccount } from 'viem/accounts'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' }),
* transport: http(),
* })
*
* const hash = await Actions.accessKey.updateLimit(client, {
* accessKey: '0x...',
* token: '0x...',
* limit: 1000000000000000000n,
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction hash.
*/
export async function updateLimit(client, parameters) {
return updateLimit.inner(writeContract, client, parameters);
}
(function (updateLimit) {
/** @internal */
async function inner(action, client, parameters) {
const { accessKey, token, limit, ...rest } = parameters;
const call = updateLimit.call({ accessKey, token, limit });
return (await action(client, {
...rest,
...call,
}));
}
updateLimit.inner = inner;
/**
* Defines a call to the `updateSpendingLimit` function.
*
* Can be passed as a parameter to:
* - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
* - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
* - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls
*
* @example
* ```ts
* import { createClient, http, walletActions } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' }),
* transport: http(),
* }).extend(walletActions)
*
* const hash = await client.sendTransaction({
* calls: [
* Actions.accessKey.updateLimit.call({
* accessKey: '0x...',
* token: '0x...',
* limit: 1000000000000000000n,
* }),
* ],
* })
* ```
*
* @param args - Arguments.
* @returns The call.
*/
function call(args) {
const { accessKey, token, limit } = args;
return defineCall({
address: Addresses.accountKeychain,
abi: Abis.accountKeychain,
functionName: 'updateSpendingLimit',
args: [resolveAccessKeyAddress(accessKey), token, limit],
});
}
updateLimit.call = call;
function extractEvent(logs) {
const [log] = parseEventLogs({
abi: Abis.accountKeychain,
logs,
eventName: 'SpendingLimitUpdated',
strict: true,
});
if (!log)
throw new Error('`SpendingLimitUpdated` event not found.');
return log;
}
updateLimit.extractEvent = extractEvent;
})(updateLimit || (updateLimit = {}));
/**
* Updates the spending limit and waits for the transaction receipt.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
* import { privateKeyToAccount } from 'viem/accounts'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' }),
* transport: http(),
* })
*
* const result = await Actions.accessKey.updateLimitSync(client, {
* accessKey: '0x...',
* token: '0x...',
* limit: 1000000000000000000n,
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
export async function updateLimitSync(client, parameters) {
const { throwOnReceiptRevert = true, ...rest } = parameters;
const receipt = await updateLimit.inner(writeContractSync, client, {
...rest,
throwOnReceiptRevert,
});
const { args } = updateLimit.extractEvent(receipt.logs);
return {
account: args.account,
publicKey: args.publicKey,
token: args.token,
limit: args.newLimit,
receipt,
};
}
/**
* Gets access key information.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' }),
* transport: http(),
* })
*
* const key = await Actions.accessKey.getMetadata(client, {
* account: '0x...',
* accessKey: '0x...',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The key information.
*/
export async function getMetadata(client, parameters) {
const { account: account_ = client.account, accessKey, ...rest } = parameters;
if (!account_)
throw new Error('account is required.');
const account = parseAccount(account_);
const result = await readContract(client, {
...rest,
...getMetadata.call({ account: account.address, accessKey }),
});
return {
address: result.keyId,
keyType: signatureTypes[result.signatureType] ??
'secp256k1',
expiry: result.expiry,
spendPolicy: spendPolicies[`${result.enforceLimits}`],
isRevoked: result.isRevoked,
};
}
(function (getMetadata) {
/**
* Defines a call to the `getKey` function.
*
* @param args - Arguments.
* @returns The call.
*/
function call(args) {
const { account, accessKey } = args;
return defineCall({
address: Addresses.accountKeychain,
abi: Abis.accountKeychain,
functionName: 'getKey',
args: [account, resolveAccessKeyAddress(accessKey)],
});
}
getMetadata.call = call;
})(getMetadata || (getMetadata = {}));
/**
* Gets the remaining spending limit for a key-token pair.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' }),
* transport: http(),
* })
*
* const remaining = await Actions.accessKey.getRemainingLimit(client, {
* account: '0x...',
* accessKey: '0x...',
* token: '0x...',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The remaining spending amount.
*/
export async function getRemainingLimit(client, parameters) {
const { account: account_ = client.account, accessKey, token, ...rest } = parameters;
if (!account_)
throw new Error('account is required.');
const account = parseAccount(account_);
// TODO: remove pre-t3 branch once mainnet is on t3.
const hardfork = client.chain?.hardfork;
if (hardfork && Hardfork.lt(hardfork, 't3')) {
const remaining = await readContract(client, {
...rest,
...getRemainingLimit.call({ account: account.address, accessKey, token }),
});
return { remaining, periodEnd: undefined };
}
const [remaining, periodEnd] = await readContract(client, {
...rest,
...getRemainingLimit.callWithPeriod({
account: account.address,
accessKey,
token,
}),
});
return { remaining, periodEnd };
}
(function (getRemainingLimit) {
/**
* Defines a call to the `getRemainingLimit` function (pre-T3).
*
* @param args - Arguments.
* @returns The call.
*/
function call(args) {
const { account, accessKey, token } = args;
return defineCall({
address: Addresses.accountKeychain,
abi: Abis.accountKeychain,
functionName: 'getRemainingLimit',
args: [account, resolveAccessKeyAddress(accessKey), token],
});
}
getRemainingLimit.call = call;
/**
* Defines a call to the `getRemainingLimitWithPeriod` function (T3+).
*
* @param args - Arguments.
* @returns The call.
*/
function callWithPeriod(args) {
const { account, accessKey, token } = args;
return defineCall({
address: Addresses.accountKeychain,
abi: Abis.accountKeychain,
functionName: 'getRemainingLimitWithPeriod',
args: [account, resolveAccessKeyAddress(accessKey), token],
});
}
getRemainingLimit.callWithPeriod = callWithPeriod;
})(getRemainingLimit || (getRemainingLimit = {}));
/**
* Signs a key authorization for an access key.
*
* @example
* ```ts
* import { generatePrivateKey } from 'viem/accounts'
* import { Account, Actions } from 'viem/tempo'
*
* const account = Account.from({ privateKey: '0x...' })
* const accessKey = Account.fromP256(generatePrivateKey(), {
* access: account,
* })
*
* const keyAuthorization = await Actions.accessKey.signAuthorization(
* client,
* {
* account,
* accessKey,
* expiry: Math.floor((Date.now() + 30_000) / 1000),
* },
* )
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The signed key authorization.
*/
export async function signAuthorization(client, parameters) {
const { accessKey, chainId = client.chain?.id, ...rest } = parameters;
const account_ = rest.account ?? client.account;
if (!account_)
throw new Error('account is required.');
if (!chainId)
throw new Error('chainId is required.');
const parsed = parseAccount(account_);
return signKeyAuthorization(parsed, {
chainId: BigInt(chainId),
key: accessKey,
...rest,
});
}
/** @internal */
function resolveAccessKeyAddress(accessKey) {
if (typeof accessKey === 'string')
return accessKey;
return accessKey.accessKeyAddress;
}
//# sourceMappingURL=accessKey.js.map

File diff suppressed because one or more lines are too long

760
node_modules/viem/_esm/tempo/actions/amm.js generated vendored Normal file
View File

@@ -0,0 +1,760 @@
import { PoolId, TokenId } from 'ox/tempo';
import { multicall } from '../../actions/public/multicall.js';
import { readContract } from '../../actions/public/readContract.js';
import { watchContractEvent } from '../../actions/public/watchContractEvent.js';
import { writeContract } from '../../actions/wallet/writeContract.js';
import { writeContractSync } from '../../actions/wallet/writeContractSync.js';
import { parseEventLogs } from '../../utils/abi/parseEventLogs.js';
import * as Abis from '../Abis.js';
import * as Addresses from '../Addresses.js';
import { defineCall } from '../internal/utils.js';
/**
* Gets the reserves for a liquidity pool.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* })
*
* const pool = await Actions.amm.getPool(client, {
* userToken: '0x...',
* validatorToken: '0x...',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The pool reserves.
*/
export async function getPool(client, parameters) {
const { userToken, validatorToken, ...rest } = parameters;
const [pool, totalSupply] = await multicall(client, {
...rest,
contracts: getPool.calls({ userToken, validatorToken }),
allowFailure: false,
deployless: true,
});
return {
reserveUserToken: pool.reserveUserToken,
reserveValidatorToken: pool.reserveValidatorToken,
totalSupply,
};
}
(function (getPool) {
/**
* Defines calls to the `getPool` and `totalSupply` functions.
*
* @param args - Arguments.
* @returns The calls.
*/
function calls(args) {
const { userToken, validatorToken } = args;
return [
defineCall({
address: Addresses.feeManager,
abi: Abis.feeAmm,
args: [TokenId.toAddress(userToken), TokenId.toAddress(validatorToken)],
functionName: 'getPool',
}),
defineCall({
address: Addresses.feeManager,
abi: Abis.feeAmm,
args: [PoolId.from({ userToken, validatorToken })],
functionName: 'totalSupply',
}),
];
}
getPool.calls = calls;
})(getPool || (getPool = {}));
/**
* Gets the LP token balance for an account in a specific pool.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* })
*
* const poolId = await Actions.amm.getPoolId(client, {
* userToken: '0x...',
* validatorToken: '0x...',
* })
*
* const balance = await Actions.amm.getLiquidityBalance(client, {
* poolId,
* address: '0x...',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The LP token balance.
*/
export async function getLiquidityBalance(client, parameters) {
const { address, poolId, userToken, validatorToken, ...rest } = parameters;
return readContract(client, {
...rest,
...getLiquidityBalance.call({
address,
poolId,
userToken,
validatorToken,
}),
});
}
(function (getLiquidityBalance) {
/**
* Defines a call to the `liquidityBalances` function.
*
* @param args - Arguments.
* @returns The call.
*/
function call(args) {
const { address } = args;
const poolId = (() => {
if ('poolId' in args && args.poolId)
return args.poolId;
if ('userToken' in args && 'validatorToken' in args)
return PoolId.from({
userToken: args.userToken,
validatorToken: args.validatorToken,
});
throw new Error('`poolId`, or `userToken` and `validatorToken` must be provided.');
})();
return defineCall({
address: Addresses.feeManager,
abi: Abis.feeAmm,
args: [poolId, address],
functionName: 'liquidityBalances',
});
}
getLiquidityBalance.call = call;
})(getLiquidityBalance || (getLiquidityBalance = {}));
/**
* Performs a rebalance swap from validator token to user token.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
* import { privateKeyToAccount } from 'viem/accounts'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* })
*
* const hash = await Actions.amm.rebalanceSwap(client, {
* userToken: '0x...',
* validatorToken: '0x...',
* amountOut: 100n,
* to: '0x...',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction hash.
*/
export async function rebalanceSwap(client, parameters) {
return rebalanceSwap.inner(writeContract, client, parameters);
}
(function (rebalanceSwap) {
/** @internal */
async function inner(action, client, parameters) {
const { userToken, validatorToken, amountOut, to, ...rest } = parameters;
const call = rebalanceSwap.call({
userToken,
validatorToken,
amountOut,
to,
});
return (await action(client, {
...rest,
...call,
}));
}
rebalanceSwap.inner = inner;
/**
* Defines a call to the `rebalanceSwap` function.
*
* Can be passed as a parameter to:
* - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
* - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
* - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls
*
* @example
* ```ts
* import { createClient, http, walletActions } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(walletActions)
*
* const { result } = await client.sendCalls({
* calls: [
* actions.amm.rebalanceSwap.call({
* userToken: '0x20c0...beef',
* validatorToken: '0x20c0...babe',
* amountOut: 100n,
* to: '0xfeed...fede',
* }),
* actions.amm.rebalanceSwap.call({
* userToken: '0x20c0...babe',
* validatorToken: '0x20c0...babe',
* amountOut: 100n,
* to: '0xfeed...fede',
* }),
* ]
* })
* ```
*
* @param args - Arguments.
* @returns The call.
*/
function call(args) {
const { userToken, validatorToken, amountOut, to } = args;
return defineCall({
address: Addresses.feeManager,
abi: Abis.feeAmm,
functionName: 'rebalanceSwap',
args: [
TokenId.toAddress(userToken),
TokenId.toAddress(validatorToken),
amountOut,
to,
],
});
}
rebalanceSwap.call = call;
/**
* Extracts the `RebalanceSwap` event from logs.
*
* @param logs - The logs.
* @returns The `RebalanceSwap` event.
*/
function extractEvent(logs) {
const [log] = parseEventLogs({
abi: Abis.feeAmm,
logs,
eventName: 'RebalanceSwap',
strict: true,
});
if (!log)
throw new Error('`RebalanceSwap` event not found.');
return log;
}
rebalanceSwap.extractEvent = extractEvent;
})(rebalanceSwap || (rebalanceSwap = {}));
/**
* Performs a rebalance swap from validator token to user token.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
* import { privateKeyToAccount } from 'viem/accounts'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* })
*
* const result = await Actions.amm.rebalanceSwapSync(client, {
* userToken: '0x...',
* validatorToken: '0x...',
* amountOut: 100n,
* to: '0x...',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
export async function rebalanceSwapSync(client, parameters) {
const { throwOnReceiptRevert = true, ...rest } = parameters;
const receipt = await rebalanceSwap.inner(writeContractSync, client, {
...rest,
throwOnReceiptRevert,
});
const { args } = rebalanceSwap.extractEvent(receipt.logs);
return {
...args,
receipt,
};
}
/**
* Adds liquidity to a pool.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
* import { privateKeyToAccount } from 'viem/accounts'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* })
*
* const hash = await Actions.amm.mint(client, {
* userTokenAddress: '0x20c0...beef',
* validatorTokenAddress: '0x20c0...babe',
* validatorTokenAmount: 100n,
* to: '0xfeed...fede',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction hash.
*/
export async function mint(client, parameters) {
return mint.inner(writeContract, client, parameters);
}
(function (mint) {
/** @internal */
async function inner(action, client, parameters) {
const { to, userTokenAddress, validatorTokenAddress, validatorTokenAmount, ...rest } = parameters;
const call = mint.call({
to,
userTokenAddress,
validatorTokenAddress,
validatorTokenAmount,
});
return (await action(client, {
...rest,
...call,
}));
}
mint.inner = inner;
/**
* Defines a call to the `mint` function.
*
* Can be passed as a parameter to:
* - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
* - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
* - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls
*
* @example
* ```ts
* import { createClient, http, walletActions } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(walletActions)
*
* const { result } = await client.sendCalls({
* calls: [
* actions.amm.mint.call({
* userTokenAddress: '0x20c0...beef',
* validatorTokenAddress: '0x20c0...babe',
* validatorTokenAmount: 100n,
* to: '0xfeed...fede',
* }),
* actions.amm.mint.call({
* userTokenAddress: '0x20c0...babe',
* validatorTokenAddress: '0x20c0...babe',
* validatorTokenAmount: 100n,
* to: '0xfeed...fede',
* }),
* ]
* })
* ```
*
* @param args - Arguments.
* @returns The call.
*/
function call(args) {
const { to, userTokenAddress, validatorTokenAddress, validatorTokenAmount, } = args;
return defineCall({
address: Addresses.feeManager,
abi: Abis.feeAmm,
functionName: 'mint',
args: [
TokenId.toAddress(userTokenAddress),
TokenId.toAddress(validatorTokenAddress),
validatorTokenAmount,
to,
],
});
}
mint.call = call;
/**
* Extracts the `Mint` event from logs.
*
* @param logs - The logs.
* @returns The `Mint` event.
*/
function extractEvent(logs) {
const [log] = parseEventLogs({
abi: Abis.feeAmm,
logs,
eventName: 'Mint',
strict: true,
});
if (!log)
throw new Error('`Mint` event not found.');
return log;
}
mint.extractEvent = extractEvent;
})(mint || (mint = {}));
/**
* Adds liquidity to a pool.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
* import { privateKeyToAccount } from 'viem/accounts'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* })
*
* const hash = await Actions.amm.mint(client, {
* userTokenAddress: '0x20c0...beef',
* validatorTokenAddress: '0x20c0...babe',
* validatorTokenAmount: 100n,
* to: '0xfeed...fede',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
export async function mintSync(client, parameters) {
const { throwOnReceiptRevert = true, ...rest } = parameters;
const receipt = await mint.inner(writeContractSync, client, {
...rest,
throwOnReceiptRevert,
});
const { args } = mint.extractEvent(receipt.logs);
return {
...args,
receipt,
};
}
/**
* Removes liquidity from a pool.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
* import { privateKeyToAccount } from 'viem/accounts'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* })
*
* const hash = await Actions.amm.burn(client, {
* userToken: '0x20c0...beef',
* validatorToken: '0x20c0...babe',
* liquidity: 50n,
* to: '0xfeed...fede',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction hash.
*/
export async function burn(client, parameters) {
return burn.inner(writeContract, client, parameters);
}
(function (burn) {
/** @internal */
async function inner(action, client, parameters) {
const { liquidity, to, userToken, validatorToken, ...rest } = parameters;
const call = burn.call({ liquidity, to, userToken, validatorToken });
return (await action(client, {
...rest,
...call,
}));
}
burn.inner = inner;
/**
* Defines a call to the `burn` function.
*
* Can be passed as a parameter to:
* - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
* - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
* - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls
*
* @example
* ```ts
* import { createClient, http, walletActions } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(walletActions)
*
* const { result } = await client.sendCalls({
* calls: [
* actions.amm.burn.call({
* liquidity: 100n,
* to: '0xfeed...fede',
* userToken: '0x20c0...beef',
* validatorToken: '0x20c0...babe',
* }),
* actions.amm.burn.call({
* liquidity: 100n,
* to: '0xfeed...fede',
* userToken: '0x20c0...babe',
* validatorToken: '0x20c0...babe',
* }),
* ]
* })
* ```
*
* @param args - Arguments.
* @returns The call.
*/
function call(args) {
const { liquidity, to, userToken, validatorToken } = args;
return defineCall({
address: Addresses.feeManager,
abi: Abis.feeAmm,
functionName: 'burn',
args: [
TokenId.toAddress(userToken),
TokenId.toAddress(validatorToken),
liquidity,
to,
],
});
}
burn.call = call;
/**
* Extracts the `Burn` event from logs.
*
* @param logs - The logs.
* @returns The `Burn` event.
*/
function extractEvent(logs) {
const [log] = parseEventLogs({
abi: Abis.feeAmm,
logs,
eventName: 'Burn',
strict: true,
});
if (!log)
throw new Error('`Burn` event not found.');
return log;
}
burn.extractEvent = extractEvent;
})(burn || (burn = {}));
/**
* Removes liquidity from a pool.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
* import { privateKeyToAccount } from 'viem/accounts'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* })
*
* const result = await Actions.amm.burnSync(client, {
* userToken: '0x20c0...beef',
* validatorToken: '0x20c0...babe',
* liquidity: 50n,
* to: '0xfeed...fede',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
export async function burnSync(client, parameters) {
const { throwOnReceiptRevert = true, ...rest } = parameters;
const receipt = await burn.inner(writeContractSync, client, {
...rest,
throwOnReceiptRevert,
});
const { args } = burn.extractEvent(receipt.logs);
return {
...args,
receipt,
};
}
/**
* Watches for rebalance swap events.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* })
*
* const unwatch = actions.amm.watchRebalanceSwap(client, {
* onRebalanceSwap: (args, log) => {
* console.log('Rebalance swap:', args)
* },
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
export function watchRebalanceSwap(client, parameters) {
const { onRebalanceSwap, userToken, validatorToken, ...rest } = parameters;
return watchContractEvent(client, {
...rest,
address: Addresses.feeManager,
abi: Abis.feeAmm,
eventName: 'RebalanceSwap',
args: userToken !== undefined && validatorToken !== undefined
? {
userToken: TokenId.toAddress(userToken),
validatorToken: TokenId.toAddress(validatorToken),
}
: undefined,
onLogs: (logs) => {
for (const log of logs)
onRebalanceSwap(log.args, log);
},
strict: true,
});
}
/**
* Watches for liquidity mint events.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* })
*
* const unwatch = actions.amm.watchMint(client, {
* onMint: (args, log) => {
* console.log('Liquidity added:', args)
* },
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
export function watchMint(client, parameters) {
const { onMint, to, userToken, validatorToken, ...rest } = parameters;
return watchContractEvent(client, {
...rest,
address: Addresses.feeManager,
abi: Abis.feeAmm,
eventName: 'Mint',
args: {
to,
...(userToken !== undefined && {
userToken: TokenId.toAddress(userToken),
}),
...(validatorToken !== undefined && {
validatorToken: TokenId.toAddress(validatorToken),
}),
},
onLogs: (logs) => {
for (const log of logs)
onMint(log.args, log);
},
strict: true,
});
}
/**
* Watches for liquidity burn events.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* })
*
* const unwatch = actions.amm.watchBurn(client, {
* onBurn: (args, log) => {
* console.log('Liquidity removed:', args)
* },
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
export function watchBurn(client, parameters) {
const { onBurn, userToken, validatorToken, ...rest } = parameters;
return watchContractEvent(client, {
...rest,
address: Addresses.feeManager,
abi: Abis.feeAmm,
eventName: 'Burn',
args: userToken !== undefined && validatorToken !== undefined
? {
userToken: TokenId.toAddress(userToken),
validatorToken: TokenId.toAddress(validatorToken),
}
: undefined,
onLogs: (logs) => {
for (const log of logs)
onBurn(log.args, log);
},
strict: true,
});
}
//# sourceMappingURL=amm.js.map

1
node_modules/viem/_esm/tempo/actions/amm.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

1561
node_modules/viem/_esm/tempo/actions/dex.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

1
node_modules/viem/_esm/tempo/actions/dex.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

73
node_modules/viem/_esm/tempo/actions/faucet.js generated vendored Normal file
View File

@@ -0,0 +1,73 @@
import { parseAccount } from '../../accounts/utils/parseAccount.js';
import { waitForTransactionReceipt } from '../../actions/public/waitForTransactionReceipt.js';
/**
* Funds an account with an initial amount of set token(s)
* on Tempo's testnet.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' }),
* transport: http(),
* })
*
* const hashes = await Actions.faucet.fund(client, {
* account: '0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction hash.
*/
export async function fund(client, parameters) {
const account = parseAccount(parameters.account);
return client.request({
method: 'tempo_fundAddress',
params: [account.address],
});
}
/**
* Funds an account with an initial amount of set token(s)
* on Tempo's testnet. Waits for the transactions to be included
* on a block before returning a response.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' }),
* transport: http(),
* })
*
* const hashes = await Actions.faucet.fundSync(client, {
* account: '0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction hash.
*/
export async function fundSync(client, parameters) {
const { timeout = 10_000 } = parameters;
const account = parseAccount(parameters.account);
const hashes = await client.request({
method: 'tempo_fundAddress',
params: [account.address],
});
const receipts = await Promise.all(hashes.map((hash) => waitForTransactionReceipt(client, {
hash,
checkReplacement: false,
timeout,
})));
return receipts;
}
//# sourceMappingURL=faucet.js.map

1
node_modules/viem/_esm/tempo/actions/faucet.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"faucet.js","sourceRoot":"","sources":["../../../tempo/actions/faucet.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAA;AACnE,OAAO,EAAE,yBAAyB,EAAE,MAAM,mDAAmD,CAAA;AAO7F;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,KAAK,UAAU,IAAI,CACxB,MAAgC,EAChC,UAA2B;IAE3B,MAAM,OAAO,GAAG,YAAY,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;IAChD,OAAO,MAAM,CAAC,OAAO,CAIlB;QACD,MAAM,EAAE,mBAAmB;QAC3B,MAAM,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC;KAC1B,CAAC,CAAA;AACJ,CAAC;AAWD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,MAAgC,EAChC,UAA+B;IAE/B,MAAM,EAAE,OAAO,GAAG,MAAM,EAAE,GAAG,UAAU,CAAA;IACvC,MAAM,OAAO,GAAG,YAAY,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;IAChD,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAIhC;QACD,MAAM,EAAE,mBAAmB;QAC3B,MAAM,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC;KAC1B,CAAC,CAAA;IACF,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,GAAG,CAChC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAClB,yBAAyB,CAAC,MAAM,EAAE;QAChC,IAAI;QACJ,gBAAgB,EAAE,KAAK;QACvB,OAAO;KACR,CAAC,CACH,CACF,CAAA;IACD,OAAO,QAAQ,CAAA;AACjB,CAAC"}

467
node_modules/viem/_esm/tempo/actions/fee.js generated vendored Normal file
View File

@@ -0,0 +1,467 @@
import { TokenId } from 'ox/tempo';
import { parseAccount } from '../../accounts/utils/parseAccount.js';
import { readContract } from '../../actions/public/readContract.js';
import { watchContractEvent } from '../../actions/public/watchContractEvent.js';
import { writeContract } from '../../actions/wallet/writeContract.js';
import { writeContractSync } from '../../actions/wallet/writeContractSync.js';
import { zeroAddress } from '../../constants/address.js';
import { parseEventLogs } from '../../utils/abi/parseEventLogs.js';
import * as Abis from '../Abis.js';
import * as Addresses from '../Addresses.js';
import { defineCall } from '../internal/utils.js';
/**
* Gets the user's default fee token.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
* import { privateKeyToAccount } from 'viem/accounts'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* })
*
* const { address, id } = await Actions.fee.getUserToken(client)
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction hash.
*/
export async function getUserToken(client, ...parameters) {
const { account: account_ = client.account, ...rest } = parameters[0] ?? {};
if (!account_)
throw new Error('account is required.');
const account = parseAccount(account_);
const address = await readContract(client, {
...rest,
...getUserToken.call({ account: account.address }),
});
if (address === zeroAddress)
return null;
return {
address,
id: TokenId.fromAddress(address),
};
}
(function (getUserToken) {
/**
* Defines a call to the `userTokens` function.
*
* @param args - Arguments.
* @returns The call.
*/
function call(args) {
const { account } = args;
return defineCall({
address: Addresses.feeManager,
abi: Abis.feeManager,
args: [account],
functionName: 'userTokens',
});
}
getUserToken.call = call;
})(getUserToken || (getUserToken = {}));
/**
* Sets the user's default fee token.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
* import { privateKeyToAccount } from 'viem/accounts'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* })
*
* const hash = await Actions.fee.setUserToken(client, {
* token: '0x...',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction hash.
*/
export async function setUserToken(client, parameters) {
return setUserToken.inner(writeContract, client, parameters);
}
(function (setUserToken) {
/** @internal */
async function inner(action, client, parameters) {
const { token, ...rest } = parameters;
const call = setUserToken.call({ token });
return (await action(client, {
...rest,
...call,
}));
}
setUserToken.inner = inner;
/**
* Defines a call to the `setUserToken` function.
*
* Can be passed as a parameter to:
* - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
* - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
* - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls
*
* @example
* ```ts
* import { createClient, http, walletActions } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(walletActions)
*
* const { result } = await client.sendCalls({
* calls: [
* actions.fee.setUserToken.call({
* token: '0x20c0...beef',
* }),
* actions.fee.setUserToken.call({
* token: '0x20c0...babe',
* }),
* ]
* })
* ```
*
* @param args - Arguments.
* @returns The call.
*/
function call(args) {
const { token } = args;
return defineCall({
address: Addresses.feeManager,
abi: Abis.feeManager,
functionName: 'setUserToken',
args: [TokenId.toAddress(token)],
});
}
setUserToken.call = call;
function extractEvent(logs) {
const [log] = parseEventLogs({
abi: Abis.feeManager,
logs,
eventName: 'UserTokenSet',
strict: true,
});
if (!log)
throw new Error('`UserTokenSet` event not found.');
return log;
}
setUserToken.extractEvent = extractEvent;
})(setUserToken || (setUserToken = {}));
/**
* Sets the user's default fee token.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
* import { privateKeyToAccount } from 'viem/accounts'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* })
*
* const result = await Actions.fee.setUserTokenSync(client, {
* token: '0x...',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
export async function setUserTokenSync(client, parameters) {
const { throwOnReceiptRevert = true, ...rest } = parameters;
const receipt = await setUserToken.inner(writeContractSync, client, {
...rest,
throwOnReceiptRevert,
});
const { args } = setUserToken.extractEvent(receipt.logs);
return {
...args,
receipt,
};
}
/**
* Watches for user token set events.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* })
*
* const unwatch = actions.fee.watchSetUserToken(client, {
* onUserTokenSet: (args, log) => {
* console.log('User token set:', args)
* },
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
export function watchSetUserToken(client, parameters) {
const { onUserTokenSet, ...rest } = parameters;
return watchContractEvent(client, {
...rest,
address: Addresses.feeManager,
abi: Abis.feeManager,
eventName: 'UserTokenSet',
onLogs: (logs) => {
for (const log of logs)
onUserTokenSet(log.args, log);
},
strict: true,
});
}
/**
* Gets the validator's preferred fee token.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* })
*
* const { address, id } = await Actions.fee.getValidatorToken(client, {
* validator: '0x...',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The validator's preferred fee token, or null if not set.
*/
export async function getValidatorToken(client, parameters) {
const { validator, ...rest } = parameters;
const address = await readContract(client, {
...rest,
...getValidatorToken.call({ validator }),
});
if (address === zeroAddress)
return null;
return {
address,
id: TokenId.fromAddress(address),
};
}
(function (getValidatorToken) {
/**
* Defines a call to the `validatorTokens` function.
*
* @param args - Arguments.
* @returns The call.
*/
function call(args) {
const { validator } = args;
return defineCall({
address: Addresses.feeManager,
abi: Abis.feeManager,
args: [validator],
functionName: 'validatorTokens',
});
}
getValidatorToken.call = call;
})(getValidatorToken || (getValidatorToken = {}));
/**
* Sets the validator's preferred fee token.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
* import { privateKeyToAccount } from 'viem/accounts'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* })
*
* const hash = await Actions.fee.setValidatorToken(client, {
* token: '0x...',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction hash.
*/
export async function setValidatorToken(client, parameters) {
return setValidatorToken.inner(writeContract, client, parameters);
}
(function (setValidatorToken) {
/** @internal */
async function inner(action, client, parameters) {
const { token, ...rest } = parameters;
const call = setValidatorToken.call({ token });
return (await action(client, {
...rest,
...call,
}));
}
setValidatorToken.inner = inner;
/**
* Defines a call to the `setValidatorToken` function.
*
* Can be passed as a parameter to:
* - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
* - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
* - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls
*
* @example
* ```ts
* import { createClient, http, walletActions } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(walletActions)
*
* const { result } = await client.sendCalls({
* calls: [
* actions.fee.setValidatorToken.call({
* token: '0x20c0...beef',
* }),
* actions.fee.setValidatorToken.call({
* token: '0x20c0...babe',
* }),
* ]
* })
* ```
*
* @param args - Arguments.
* @returns The call.
*/
function call(args) {
const { token } = args;
return defineCall({
address: Addresses.feeManager,
abi: Abis.feeManager,
functionName: 'setValidatorToken',
args: [TokenId.toAddress(token)],
});
}
setValidatorToken.call = call;
function extractEvent(logs) {
const [log] = parseEventLogs({
abi: Abis.feeManager,
logs,
eventName: 'ValidatorTokenSet',
strict: true,
});
if (!log)
throw new Error('`ValidatorTokenSet` event not found.');
return log;
}
setValidatorToken.extractEvent = extractEvent;
})(setValidatorToken || (setValidatorToken = {}));
/**
* Sets the validator's preferred fee token.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
* import { privateKeyToAccount } from 'viem/accounts'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* })
*
* const result = await Actions.fee.setValidatorTokenSync(client, {
* token: '0x...',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
export async function setValidatorTokenSync(client, parameters) {
const { throwOnReceiptRevert = true, ...rest } = parameters;
const receipt = await setValidatorToken.inner(writeContractSync, client, {
...rest,
throwOnReceiptRevert,
});
const { args } = setValidatorToken.extractEvent(receipt.logs);
return {
...args,
receipt,
};
}
/**
* Watches for validator token set events.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* })
*
* const unwatch = actions.fee.watchSetValidatorToken(client, {
* onValidatorTokenSet: (args, log) => {
* console.log('Validator token set:', args)
* },
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
export function watchSetValidatorToken(client, parameters) {
const { onValidatorTokenSet, ...rest } = parameters;
return watchContractEvent(client, {
...rest,
address: Addresses.feeManager,
abi: Abis.feeManager,
eventName: 'ValidatorTokenSet',
onLogs: (logs) => {
for (const log of logs)
onValidatorTokenSet(log.args, log);
},
strict: true,
});
}
//# sourceMappingURL=fee.js.map

1
node_modules/viem/_esm/tempo/actions/fee.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

15
node_modules/viem/_esm/tempo/actions/index.js generated vendored Normal file
View File

@@ -0,0 +1,15 @@
// biome-ignore lint/performance/noBarrelFile: _
export * as accessKey from './accessKey.js';
export * as amm from './amm.js';
export * as dex from './dex.js';
export * as faucet from './faucet.js';
export * as fee from './fee.js';
export * as nonce from './nonce.js';
export * as policy from './policy.js';
export * as reward from './reward.js';
export * as simulate from './simulate.js';
export * as token from './token.js';
export * as validator from './validator.js';
export * as virtualAddress from './virtualAddress.js';
export * as zone from './zone.js';
//# sourceMappingURL=index.js.map

1
node_modules/viem/_esm/tempo/actions/index.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../tempo/actions/index.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AACzC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAA;AACrD,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA"}

93
node_modules/viem/_esm/tempo/actions/nonce.js generated vendored Normal file
View File

@@ -0,0 +1,93 @@
import { readContract } from '../../actions/public/readContract.js';
import { watchContractEvent } from '../../actions/public/watchContractEvent.js';
import * as Abis from '../Abis.js';
import * as Addresses from '../Addresses.js';
import { defineCall } from '../internal/utils.js';
/**
* Gets the nonce for an account and nonce key.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' }),
* transport: http(),
* })
*
* const nonce = await Actions.nonce.getNonce(client, {
* account: '0x...',
* nonceKey: 1n,
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The nonce value.
*/
export async function getNonce(client, parameters) {
const { account, nonceKey, ...rest } = parameters;
return readContract(client, {
...rest,
...getNonce.call({ account, nonceKey }),
});
}
(function (getNonce) {
/**
* Defines a call to the `getNonce` function.
*
* Can be passed as a parameter to:
* - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
* - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
* - [`multicall`](https://viem.sh/docs/contract/multicall): execute multiple calls in parallel
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' }),
* transport: http(),
* })
*
* const result = await client.multicall({
* contracts: [
* Actions.nonce.getNonce.call({ account: '0x...', nonceKey: 1n }),
* Actions.nonce.getNonce.call({ account: '0x...', nonceKey: 2n }),
* ],
* })
* ```
*
* @param args - Arguments.
* @returns The call.
*/
function call(args) {
const { account, nonceKey } = args;
return defineCall({
address: Addresses.nonceManager,
abi: Abis.nonce,
args: [account, nonceKey],
functionName: 'getNonce',
});
}
getNonce.call = call;
})(getNonce || (getNonce = {}));
export function watchNonceIncremented(client, parameters) {
const { onNonceIncremented, ...rest } = parameters;
return watchContractEvent(client, {
...rest,
address: Addresses.nonceManager,
abi: Abis.nonce,
eventName: 'NonceIncremented',
onLogs: (logs) => {
for (const log of logs)
onNonceIncremented(log.args, log);
},
strict: true,
});
}
//# sourceMappingURL=nonce.js.map

1
node_modules/viem/_esm/tempo/actions/nonce.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"nonce.js","sourceRoot":"","sources":["../../../tempo/actions/nonce.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAA;AAEnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAA;AAO/E,OAAO,KAAK,IAAI,MAAM,YAAY,CAAA;AAClC,OAAO,KAAK,SAAS,MAAM,iBAAiB,CAAA;AAE5C,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAEjD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAI5B,MAAyC,EACzC,UAA+B;IAE/B,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,GAAG,UAAU,CAAA;IACjD,OAAO,YAAY,CAAC,MAAM,EAAE;QAC1B,GAAG,IAAI;QACP,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;KACxC,CAAC,CAAA;AACJ,CAAC;AAED,WAAiB,QAAQ;IAgBvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACH,SAAgB,IAAI,CAAC,IAAU;QAC7B,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAA;QAClC,OAAO,UAAU,CAAC;YAChB,OAAO,EAAE,SAAS,CAAC,YAAY;YAC/B,GAAG,EAAE,IAAI,CAAC,KAAK;YACf,IAAI,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC;YACzB,YAAY,EAAE,UAAU;SACzB,CAAC,CAAA;IACJ,CAAC;IARe,aAAI,OAQnB,CAAA;AACH,CAAC,EAvDgB,QAAQ,KAAR,QAAQ,QAuDxB;AAED,MAAM,UAAU,qBAAqB,CAInC,MAAyC,EACzC,UAA4C;IAE5C,MAAM,EAAE,kBAAkB,EAAE,GAAG,IAAI,EAAE,GAAG,UAAU,CAAA;IAClD,OAAO,kBAAkB,CAAC,MAAM,EAAE;QAChC,GAAG,IAAI;QACP,OAAO,EAAE,SAAS,CAAC,YAAY;QAC/B,GAAG,EAAE,IAAI,CAAC,KAAK;QACf,SAAS,EAAE,kBAAkB;QAC7B,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;YACf,KAAK,MAAM,GAAG,IAAI,IAAI;gBAAE,kBAAkB,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;QAC3D,CAAC;QACD,MAAM,EAAE,IAAI;KACb,CAAC,CAAA;AACJ,CAAC"}

878
node_modules/viem/_esm/tempo/actions/policy.js generated vendored Normal file
View File

@@ -0,0 +1,878 @@
import { parseAccount } from '../../accounts/utils/parseAccount.js';
import { readContract } from '../../actions/public/readContract.js';
import { watchContractEvent } from '../../actions/public/watchContractEvent.js';
import { writeContract } from '../../actions/wallet/writeContract.js';
import { writeContractSync } from '../../actions/wallet/writeContractSync.js';
import { parseEventLogs } from '../../utils/abi/parseEventLogs.js';
import * as Abis from '../Abis.js';
import * as Addresses from '../Addresses.js';
import { defineCall } from '../internal/utils.js';
const policyTypeMap = {
whitelist: 0,
blacklist: 1,
};
/**
* Creates a new policy.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
* import { privateKeyToAccount } from 'viem/accounts'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* })
*
* const { hash, policyId } = await Actions.policy.create(client, {
* admin: '0x...',
* type: 'whitelist',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction hash and policy ID.
*/
export async function create(client, parameters) {
return create.inner(writeContract, client, parameters);
}
(function (create) {
/** @internal */
async function inner(action, client, parameters) {
const { account = client.account, addresses, chain = client.chain, type, ...rest } = parameters;
if (!account)
throw new Error('`account` is required');
const admin = parseAccount(account).address;
const call = create.call({ admin, type, addresses });
return action(client, {
...rest,
account,
chain,
...call,
});
}
create.inner = inner;
/**
* Defines a call to the `createPolicy` function.
*
* Can be passed as a parameter to:
* - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
* - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
* - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls
*
* @example
* ```ts
* import { createClient, http, walletActions } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(walletActions)
*
* const { result } = await client.sendCalls({
* calls: [
* actions.policy.create.call({
* admin: '0xfeed...fede',
* type: 'whitelist',
* }),
* actions.policy.create.call({
* admin: '0xfeed...fede',
* type: 'blacklist',
* addresses: ['0x20c0...beef', '0x20c0...babe'],
* }),
* ]
* })
* ```
*
* @param args - Arguments.
* @returns The call.
*/
function call(args) {
const { admin, type, addresses } = args;
const config = (() => {
if (addresses)
return {
functionName: 'createPolicyWithAccounts',
args: [admin, policyTypeMap[type], addresses],
};
return {
functionName: 'createPolicy',
args: [admin, policyTypeMap[type]],
};
})();
return defineCall({
address: Addresses.tip403Registry,
abi: Abis.tip403Registry,
...config,
});
}
create.call = call;
/**
* Extracts the `PolicyCreated` event from logs.
*
* @param logs - The logs.
* @returns The `PolicyCreated` event.
*/
function extractEvent(logs) {
const [log] = parseEventLogs({
abi: Abis.tip403Registry,
logs,
eventName: 'PolicyCreated',
strict: true,
});
if (!log)
throw new Error('`PolicyCreated` event not found.');
return log;
}
create.extractEvent = extractEvent;
})(create || (create = {}));
/**
* Creates a new policy.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
* import { privateKeyToAccount } from 'viem/accounts'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* })
*
* const result = await Actions.policy.createSync(client, {
* admin: '0x...',
* type: 'whitelist',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
export async function createSync(client, parameters) {
const { throwOnReceiptRevert = true, ...rest } = parameters;
const receipt = await create.inner(writeContractSync, client, {
...rest,
throwOnReceiptRevert,
});
const { args } = create.extractEvent(receipt.logs);
return {
...args,
receipt,
};
}
/**
* Sets the admin for a policy.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
* import { privateKeyToAccount } from 'viem/accounts'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* })
*
* const hash = await Actions.policy.setAdmin(client, {
* policyId: 2n,
* admin: '0x...',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction hash.
*/
export async function setAdmin(client, parameters) {
return setAdmin.inner(writeContract, client, parameters);
}
(function (setAdmin) {
/** @internal */
async function inner(action, client, parameters) {
const { policyId, admin, ...rest } = parameters;
const call = setAdmin.call({ policyId, admin });
return (await action(client, {
...rest,
...call,
}));
}
setAdmin.inner = inner;
/**
* Defines a call to the `setPolicyAdmin` function.
*
* Can be passed as a parameter to:
* - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
* - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
* - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls
*
* @example
* ```ts
* import { createClient, http, walletActions } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(walletActions)
*
* const { result } = await client.sendCalls({
* calls: [
* actions.policy.setAdmin.call({
* policyId: 2n,
* admin: '0xfeed...fede',
* }),
* actions.policy.setAdmin.call({
* policyId: 3n,
* admin: '0xfeed...babe',
* }),
* ]
* })
* ```
*
* @param args - Arguments.
* @returns The call.
*/
function call(args) {
const { policyId, admin } = args;
return defineCall({
address: Addresses.tip403Registry,
abi: Abis.tip403Registry,
functionName: 'setPolicyAdmin',
args: [policyId, admin],
});
}
setAdmin.call = call;
/**
* Extracts the `PolicyAdminUpdated` event from logs.
*
* @param logs - The logs.
* @returns The `PolicyAdminUpdated` event.
*/
function extractEvent(logs) {
const [log] = parseEventLogs({
abi: Abis.tip403Registry,
logs,
eventName: 'PolicyAdminUpdated',
strict: true,
});
if (!log)
throw new Error('`PolicyAdminUpdated` event not found.');
return log;
}
setAdmin.extractEvent = extractEvent;
})(setAdmin || (setAdmin = {}));
/**
* Sets the admin for a policy.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
* import { privateKeyToAccount } from 'viem/accounts'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* })
*
* const result = await Actions.policy.setAdminSync(client, {
* policyId: 2n,
* admin: '0x...',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
export async function setAdminSync(client, parameters) {
const { throwOnReceiptRevert = true, ...rest } = parameters;
const receipt = await setAdmin.inner(writeContractSync, client, {
...rest,
throwOnReceiptRevert,
});
const { args } = setAdmin.extractEvent(receipt.logs);
return {
...args,
receipt,
};
}
/**
* Modifies a policy whitelist.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
* import { privateKeyToAccount } from 'viem/accounts'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* })
*
* const hash = await Actions.policy.modifyWhitelist(client, {
* policyId: 2n,
* account: '0x...',
* allowed: true,
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction hash.
*/
export async function modifyWhitelist(client, parameters) {
return modifyWhitelist.inner(writeContract, client, parameters);
}
(function (modifyWhitelist) {
/** @internal */
async function inner(action, client, parameters) {
const { address: targetAccount, allowed, policyId, ...rest } = parameters;
const call = modifyWhitelist.call({
address: targetAccount,
allowed,
policyId,
});
return (await action(client, {
...rest,
...call,
}));
}
modifyWhitelist.inner = inner;
/**
* Defines a call to the `modifyPolicyWhitelist` function.
*
* Can be passed as a parameter to:
* - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
* - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
* - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls
*
* @example
* ```ts
* import { createClient, http, walletActions } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(walletActions)
*
* const { result } = await client.sendCalls({
* calls: [
* actions.policy.modifyWhitelist.call({
* policyId: 2n,
* address: '0x20c0...beef',
* allowed: true,
* }),
* actions.policy.modifyWhitelist.call({
* policyId: 2n,
* address: '0x20c0...babe',
* allowed: false,
* }),
* ]
* })
* ```
*
* @param args - Arguments.
* @returns The call.
*/
function call(args) {
const { policyId, address, allowed } = args;
return defineCall({
address: Addresses.tip403Registry,
abi: Abis.tip403Registry,
functionName: 'modifyPolicyWhitelist',
args: [policyId, address, allowed],
});
}
modifyWhitelist.call = call;
/**
* Extracts the `WhitelistUpdated` event from logs.
*
* @param logs - The logs.
* @returns The `WhitelistUpdated` event.
*/
function extractEvent(logs) {
const [log] = parseEventLogs({
abi: Abis.tip403Registry,
logs,
eventName: 'WhitelistUpdated',
strict: true,
});
if (!log)
throw new Error('`WhitelistUpdated` event not found.');
return log;
}
modifyWhitelist.extractEvent = extractEvent;
})(modifyWhitelist || (modifyWhitelist = {}));
/**
* Modifies a policy whitelist.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
* import { privateKeyToAccount } from 'viem/accounts'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* })
*
* const result = await Actions.policy.modifyWhitelistSync(client, {
* policyId: 2n,
* account: '0x...',
* allowed: true,
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
export async function modifyWhitelistSync(client, parameters) {
const { throwOnReceiptRevert = true, ...rest } = parameters;
const receipt = await modifyWhitelist.inner(writeContractSync, client, {
...rest,
throwOnReceiptRevert,
});
const { args } = modifyWhitelist.extractEvent(receipt.logs);
return {
...args,
receipt,
};
}
/**
* Modifies a policy blacklist.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
* import { privateKeyToAccount } from 'viem/accounts'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* })
*
* const hash = await Actions.policy.modifyBlacklist(client, {
* policyId: 2n,
* account: '0x...',
* restricted: true,
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction hash.
*/
export async function modifyBlacklist(client, parameters) {
return modifyBlacklist.inner(writeContract, client, parameters);
}
(function (modifyBlacklist) {
/** @internal */
async function inner(action, client, parameters) {
const { address: targetAccount, policyId, restricted, ...rest } = parameters;
const call = modifyBlacklist.call({
address: targetAccount,
policyId,
restricted,
});
return (await action(client, {
...rest,
...call,
}));
}
modifyBlacklist.inner = inner;
/**
* Defines a call to the `modifyPolicyBlacklist` function.
*
* Can be passed as a parameter to:
* - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
* - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
* - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls
*
* @example
* ```ts
* import { createClient, http, walletActions } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(walletActions)
*
* const { result } = await client.sendCalls({
* calls: [
* actions.policy.modifyBlacklist.call({
* policyId: 2n,
* address: '0x20c0...beef',
* restricted: true,
* }),
* actions.policy.modifyBlacklist.call({
* policyId: 2n,
* address: '0x20c0...babe',
* restricted: false,
* }),
* ]
* })
* ```
*
* @param args - Arguments.
* @returns The call.
*/
function call(args) {
const { policyId, address, restricted } = args;
return defineCall({
address: Addresses.tip403Registry,
abi: Abis.tip403Registry,
functionName: 'modifyPolicyBlacklist',
args: [policyId, address, restricted],
});
}
modifyBlacklist.call = call;
/**
* Extracts the `BlacklistUpdated` event from logs.
*
* @param logs - The logs.
* @returns The `BlacklistUpdated` event.
*/
function extractEvent(logs) {
const [log] = parseEventLogs({
abi: Abis.tip403Registry,
logs,
eventName: 'BlacklistUpdated',
strict: true,
});
if (!log)
throw new Error('`BlacklistUpdated` event not found.');
return log;
}
modifyBlacklist.extractEvent = extractEvent;
})(modifyBlacklist || (modifyBlacklist = {}));
/**
* Modifies a policy blacklist.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
* import { privateKeyToAccount } from 'viem/accounts'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* })
*
* const result = await Actions.policy.modifyBlacklistSync(client, {
* policyId: 2n,
* account: '0x...',
* restricted: true,
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
export async function modifyBlacklistSync(client, parameters) {
const { throwOnReceiptRevert = true, ...rest } = parameters;
const receipt = await modifyBlacklist.inner(writeContractSync, client, {
...rest,
throwOnReceiptRevert,
});
const { args } = modifyBlacklist.extractEvent(receipt.logs);
return {
...args,
receipt,
};
}
/**
* Gets policy data.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* })
*
* const data = await Actions.policy.getData(client, {
* policyId: 2n,
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The policy data.
*/
export async function getData(client, parameters) {
const { policyId, ...rest } = parameters;
const result = await readContract(client, {
...rest,
...getData.call({ policyId }),
});
return {
admin: result[1],
type: result[0] === 0 ? 'whitelist' : 'blacklist',
};
}
(function (getData) {
/**
* Defines a call to the `policyData` function.
*
* @param args - Arguments.
* @returns The call.
*/
function call(args) {
const { policyId } = args;
return defineCall({
address: Addresses.tip403Registry,
abi: Abis.tip403Registry,
args: [policyId],
functionName: 'policyData',
});
}
getData.call = call;
})(getData || (getData = {}));
/**
* Checks if a user is authorized by a policy.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* })
*
* const authorized = await Actions.policy.isAuthorized(client, {
* policyId: 2n,
* user: '0x...',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns Whether the user is authorized.
*/
export async function isAuthorized(client, parameters) {
const { policyId, user, ...rest } = parameters;
return readContract(client, {
...rest,
...isAuthorized.call({ policyId, user }),
});
}
(function (isAuthorized) {
/**
* Defines a call to the `isAuthorized` function.
*
* @param args - Arguments.
* @returns The call.
*/
function call(args) {
const { policyId, user } = args;
return defineCall({
address: Addresses.tip403Registry,
abi: Abis.tip403Registry,
args: [policyId, user],
functionName: 'isAuthorized',
});
}
isAuthorized.call = call;
})(isAuthorized || (isAuthorized = {}));
/**
* Watches for policy creation events.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* })
*
* const unwatch = actions.policy.watchCreate(client, {
* onPolicyCreated: (args, log) => {
* console.log('Policy created:', args)
* },
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
export function watchCreate(client, parameters) {
const { onPolicyCreated, ...rest } = parameters;
return watchContractEvent(client, {
...rest,
address: Addresses.tip403Registry,
abi: Abis.tip403Registry,
eventName: 'PolicyCreated',
onLogs: (logs) => {
for (const log of logs)
onPolicyCreated({
...log.args,
type: log.args.policyType === 0 ? 'whitelist' : 'blacklist',
}, log);
},
strict: true,
});
}
/**
* Watches for policy admin update events.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* })
*
* const unwatch = actions.policy.watchAdminUpdated(client, {
* onAdminUpdated: (args, log) => {
* console.log('Policy admin updated:', args)
* },
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
export function watchAdminUpdated(client, parameters) {
const { onAdminUpdated, ...rest } = parameters;
return watchContractEvent(client, {
...rest,
address: Addresses.tip403Registry,
abi: Abis.tip403Registry,
eventName: 'PolicyAdminUpdated',
onLogs: (logs) => {
for (const log of logs)
onAdminUpdated(log.args, log);
},
strict: true,
});
}
/**
* Watches for whitelist update events.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* })
*
* const unwatch = actions.policy.watchWhitelistUpdated(client, {
* onWhitelistUpdated: (args, log) => {
* console.log('Whitelist updated:', args)
* },
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
export function watchWhitelistUpdated(client, parameters) {
const { onWhitelistUpdated, ...rest } = parameters;
return watchContractEvent(client, {
...rest,
address: Addresses.tip403Registry,
abi: Abis.tip403Registry,
eventName: 'WhitelistUpdated',
onLogs: (logs) => {
for (const log of logs)
onWhitelistUpdated(log.args, log);
},
strict: true,
});
}
/**
* Watches for blacklist update events.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* })
*
* const unwatch = actions.policy.watchBlacklistUpdated(client, {
* onBlacklistUpdated: (args, log) => {
* console.log('Blacklist updated:', args)
* },
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
export function watchBlacklistUpdated(client, parameters) {
const { onBlacklistUpdated, ...rest } = parameters;
return watchContractEvent(client, {
...rest,
address: Addresses.tip403Registry,
abi: Abis.tip403Registry,
eventName: 'BlacklistUpdated',
onLogs: (logs) => {
for (const log of logs)
onBlacklistUpdated(log.args, log);
},
strict: true,
});
}
//# sourceMappingURL=policy.js.map

1
node_modules/viem/_esm/tempo/actions/policy.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

692
node_modules/viem/_esm/tempo/actions/reward.js generated vendored Normal file
View File

@@ -0,0 +1,692 @@
import { readContract } from '../../actions/public/readContract.js';
import { watchContractEvent } from '../../actions/public/watchContractEvent.js';
import { writeContract } from '../../actions/wallet/writeContract.js';
import { writeContractSync } from '../../actions/wallet/writeContractSync.js';
import { parseEventLogs } from '../../utils/abi/parseEventLogs.js';
import * as Abis from '../Abis.js';
import { defineCall } from '../internal/utils.js';
/**
* Claims accumulated rewards for a recipient.
*
* This function allows a reward recipient to claim their accumulated rewards
* and receive them as token transfers to their own balance.
*
* - Accrues all pending rewards up to the current block timestamp.
* - Updates the caller's reward accounting.
* - Transfers the caller's accumulated `rewardBalance` from the token contract to the caller.
* - If the contract's balance is insufficient, claims up to the available amount.
* - Returns the actual amount claimed.
*
* Notes:
* - Reverts with `Paused` if the token is paused.
* - Reverts with `PolicyForbids` if the caller is not authorized to receive tokens under TIP-403.
* - If opted in, the claimed amount is added back to `optedInSupply` since it goes to the recipient's balance.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
* import { privateKeyToAccount } from 'viem/accounts'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* })
*
* const hash = await Actions.reward.claim(client, {
* token: '0x20c0000000000000000000000000000000000001',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction hash.
*/
export async function claim(client, parameters) {
return claim.inner(writeContract, client, parameters);
}
(function (claim) {
/** @internal */
async function inner(action, client, parameters) {
const { token, ...rest } = parameters;
const call = claim.call({ token });
return (await action(client, {
...rest,
...call,
}));
}
claim.inner = inner;
/**
* Defines a call to the `claimRewards` function.
*
* Can be passed as a parameter to:
* - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
* - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
* - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls
*
* @example
* ```ts
* import { createClient, http, walletActions } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(walletActions)
*
* const hash = await client.sendTransaction({
* calls: [actions.reward.claim.call({
* token: '0x20c0000000000000000000000000000000000001',
* })],
* })
* ```
*
* @param args - Arguments.
* @returns The call.
*/
function call(args) {
const { token } = args;
return defineCall({
address: token,
abi: Abis.tip20,
args: [],
functionName: 'claimRewards',
});
}
claim.call = call;
})(claim || (claim = {}));
/**
* Claims accumulated rewards for a recipient and waits for confirmation.
*
* This function allows a reward recipient to claim their accumulated rewards
* and receive them as token transfers to their own balance.
*
* Behavior:
* - Accrues all pending rewards up to the current block timestamp.
* - Updates the caller's reward accounting.
* - Transfers the caller's accumulated `rewardBalance` from the token contract to the caller.
* - If the contract's balance is insufficient, claims up to the available amount.
*
* Notes:
* - Reverts with `Paused` if the token is paused.
* - Reverts with `PolicyForbids` if the caller is not authorized to receive tokens under TIP-403.
* - If opted in, the claimed amount is added back to `optedInSupply` since it goes to the recipient's balance.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
* import { privateKeyToAccount } from 'viem/accounts'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* })
*
* const { receipt } = await Actions.reward.claimSync(client, {
* token: '0x20c0000000000000000000000000000000000001',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The amount claimed and transaction receipt.
*/
export async function claimSync(client, parameters) {
const { throwOnReceiptRevert = true, ...rest } = parameters;
const receipt = await claim.inner(writeContractSync, client, {
...rest,
throwOnReceiptRevert,
});
return {
receipt,
};
}
/**
* Distributes rewards to opted-in token holders.
*
* This function transfers `amount` of tokens from the caller into the token contract's
* reward pool and immediately distributes them to current opted-in holders by increasing
* `globalRewardPerToken`.
*
* Notes:
* - Reverts with `InvalidAmount` if `amount == 0`.
* - The transfer from caller to pool is subject to TIP-403 policy checks.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
* import { privateKeyToAccount } from 'viem/accounts'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* })
*
* const hash = await Actions.reward.distribute(client, {
* amount: 100000000000000000000n,
* token: '0x20c0000000000000000000000000000000000001',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction hash.
*/
export async function distribute(client, parameters) {
return distribute.inner(writeContract, client, parameters);
}
/**
* Distributes rewards to opted-in token holders and waits for confirmation.
*
* This function transfers `amount` of tokens from the caller into the token contract's
* reward pool and immediately distributes them to current opted-in holders by increasing
* `globalRewardPerToken`.
*
* Notes:
* - Reverts with `InvalidAmount` if `amount == 0`.
* - The transfer from caller to pool is subject to TIP-403 policy checks.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
* import { privateKeyToAccount } from 'viem/accounts'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* })
*
* const { amount, funder, receipt } = await Actions.reward.distributeSync(client, {
* amount: 100000000000000000000n,
* token: '0x20c0000000000000000000000000000000000001',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The funder, amount, and transaction receipt.
*/
export async function distributeSync(client, parameters) {
const { throwOnReceiptRevert = true, ...rest } = parameters;
const receipt = await distribute.inner(writeContractSync, client, {
...rest,
throwOnReceiptRevert,
});
const { args } = distribute.extractEvent(receipt.logs);
return {
...args,
receipt,
};
}
(function (distribute) {
/** @internal */
async function inner(action, client, parameters) {
const { amount, token, ...rest } = parameters;
const call = distribute.call({ amount, token });
return (await action(client, {
...rest,
...call,
}));
}
distribute.inner = inner;
/**
* Defines a call to the `distributeReward` function.
*
* Can be passed as a parameter to:
* - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
* - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
* - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls
*
* @example
* ```ts
* import { createClient, http, walletActions } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(walletActions)
*
* const hash = await client.sendTransaction({
* calls: [actions.reward.distribute.call({
* amount: 100000000000000000000n,
* token: '0x20c0000000000000000000000000000000000001',
* })],
* })
* ```
*
* @param args - Arguments.
* @returns The call.
*/
function call(args) {
const { amount, token } = args;
return defineCall({
address: token,
abi: Abis.tip20,
args: [amount],
functionName: 'distributeReward',
});
}
distribute.call = call;
/**
* Extracts the `RewardDistributed` event from logs.
*
* @param logs - The logs.
* @returns The `RewardDistributed` event.
*/
function extractEvent(logs) {
const [log] = parseEventLogs({
abi: Abis.tip20,
logs,
eventName: 'RewardDistributed',
strict: true,
});
if (!log)
throw new Error('`RewardDistributed` event not found.');
return log;
}
distribute.extractEvent = extractEvent;
})(distribute || (distribute = {}));
/**
* Gets the global reward per token value.
*
* Returns the current global reward per token value scaled by `ACC_PRECISION` (1e18).
* This value increases each time rewards are distributed.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* })
*
* const rewardPerToken = await Actions.reward.getGlobalRewardPerToken(client, {
* token: '0x20c0000000000000000000000000000000000001',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The global reward per token (scaled by 1e18).
*/
export async function getGlobalRewardPerToken(client, parameters) {
return readContract(client, {
...parameters,
...getGlobalRewardPerToken.call(parameters),
});
}
(function (getGlobalRewardPerToken) {
/**
* Defines a call to the `globalRewardPerToken` function.
*
* @param args - Arguments.
* @returns The call.
*/
function call(args) {
const { token } = args;
return defineCall({
address: token,
abi: Abis.tip20,
args: [],
functionName: 'globalRewardPerToken',
});
}
getGlobalRewardPerToken.call = call;
})(getGlobalRewardPerToken || (getGlobalRewardPerToken = {}));
/**
* Calculates the pending claimable rewards for an account without modifying state.
*
* Returns the total pending claimable reward amount, including stored balance and newly accrued rewards.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* })
*
* const pending = await Actions.reward.getPendingRewards(client, {
* token: '0x20c0000000000000000000000000000000000001',
* account: '0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The total pending claimable reward amount.
*/
export async function getPendingRewards(client, parameters) {
return readContract(client, {
...parameters,
...getPendingRewards.call(parameters),
});
}
(function (getPendingRewards) {
/**
* Defines a call to the `getPendingRewards` function.
*
* @param args - Arguments.
* @returns The call.
*/
function call(args) {
const { account, token } = args;
return defineCall({
address: token,
abi: Abis.tip20,
args: [account],
functionName: 'getPendingRewards',
});
}
getPendingRewards.call = call;
})(getPendingRewards || (getPendingRewards = {}));
/**
* Gets the reward information for a specific account.
*
* Returns the reward recipient address, reward per token value, and accumulated reward balance for the specified account.
* This information includes:
* - `rewardRecipient`: The address designated to receive rewards (zero address if opted out)
* - `rewardPerToken`: The reward per token value for this account
* - `rewardBalance`: The accumulated reward balance waiting to be claimed
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* })
*
* const info = await Actions.reward.getUserRewardInfo(client, {
* token: '0x20c0000000000000000000000000000000000001',
* account: '0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The user's reward information (recipient, rewardPerToken, rewardBalance).
*/
export async function getUserRewardInfo(client, parameters) {
return readContract(client, {
...parameters,
...getUserRewardInfo.call(parameters),
});
}
(function (getUserRewardInfo) {
/**
* Defines a call to the `userRewardInfo` function.
*
* @param args - Arguments.
* @returns The call.
*/
function call(args) {
const { account, token } = args;
return defineCall({
address: token,
abi: Abis.tip20,
args: [account],
functionName: 'userRewardInfo',
});
}
getUserRewardInfo.call = call;
})(getUserRewardInfo || (getUserRewardInfo = {}));
/**
* Sets or changes the reward recipient for a token holder.
*
* This function allows a token holder to designate who should receive their share of rewards:
* - If `recipient` is the zero address, opts out from rewards distribution.
* - Otherwise, opts in and sets `recipient` as the address that will receive accrued rewards.
* - Can be called with `recipient == msg.sender` to receive rewards directly.
* - Automatically distributes any accrued rewards to the current recipient before changing.
*
* TIP-403 Policy:
* - Reverts with `PolicyForbids` if `recipient` is not the zero address and either the holder or recipient is not authorized to receive tokens under the token's transfer policy.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
* import { privateKeyToAccount } from 'viem/accounts'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* })
*
* const hash = await Actions.reward.setRecipient(client, {
* recipient: '0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC',
* token: '0x20c0000000000000000000000000000000000001',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction hash.
*/
export async function setRecipient(client, parameters) {
return setRecipient.inner(writeContract, client, parameters);
}
/**
* Sets or changes the reward recipient for a token holder and waits for confirmation.
*
* This function allows a token holder to designate who should receive their share of rewards:
* - If `recipient` is the zero address, opts out from rewards distribution.
* - Otherwise, opts in and sets `recipient` as the address that will receive accrued rewards.
* - Can be called with `recipient == msg.sender` to receive rewards directly.
* - Automatically distributes any accrued rewards to the current recipient before changing.
*
* TIP-403 Policy:
* - Reverts with `PolicyForbids` if `recipient` is not the zero address and either the holder or recipient is not authorized to receive tokens under the token's transfer policy.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
* import { privateKeyToAccount } from 'viem/accounts'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* })
*
* const { holder, recipient, receipt } = await Actions.reward.setRecipientSync(client, {
* recipient: '0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC',
* token: '0x20c0000000000000000000000000000000000001',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The holder, recipient, and transaction receipt.
*/
export async function setRecipientSync(client, parameters) {
const { throwOnReceiptRevert = true, ...rest } = parameters;
const receipt = await setRecipient.inner(writeContractSync, client, {
...rest,
throwOnReceiptRevert,
});
const { args } = setRecipient.extractEvent(receipt.logs);
return {
...args,
receipt,
};
}
(function (setRecipient) {
/** @internal */
async function inner(action, client, parameters) {
const { recipient, token, ...rest } = parameters;
const call = setRecipient.call({ recipient, token });
return (await action(client, {
...rest,
...call,
}));
}
setRecipient.inner = inner;
/**
* Defines a call to the `setRewardRecipient` function.
*
* Can be passed as a parameter to:
* - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
* - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
* - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls
*
* @example
* ```ts
* import { createClient, http, walletActions } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(walletActions)
*
* const hash = await client.sendTransaction({
* calls: [actions.reward.setRecipient.call({
* recipient: '0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC',
* token: '0x20c0000000000000000000000000000000000001',
* })],
* })
* ```
*
* @param args - Arguments.
* @returns The call.
*/
function call(args) {
const { recipient, token } = args;
return defineCall({
address: token,
abi: Abis.tip20,
args: [recipient],
functionName: 'setRewardRecipient',
});
}
setRecipient.call = call;
/**
* Extracts the `RewardRecipientSet` event from logs.
*
* @param logs - The logs.
* @returns The `RewardRecipientSet` event.
*/
function extractEvent(logs) {
const [log] = parseEventLogs({
abi: Abis.tip20,
logs,
eventName: 'RewardRecipientSet',
strict: true,
});
if (!log)
throw new Error('`RewardRecipientSet` event not found.');
return log;
}
setRecipient.extractEvent = extractEvent;
})(setRecipient || (setRecipient = {}));
/**
* Watches for reward distributed events.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* })
*
* const unwatch = Actions.reward.watchRewardDistributed(client, {
* token: '0x20c0000000000000000000000000000000000001',
* onRewardDistributed: (args, log) => {
* console.log('Reward distributed:', args)
* },
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
export function watchRewardDistributed(client, parameters) {
const { onRewardDistributed, token, ...rest } = parameters;
return watchContractEvent(client, {
...rest,
address: token,
abi: Abis.tip20,
eventName: 'RewardDistributed',
onLogs: (logs) => {
for (const log of logs)
onRewardDistributed(log.args, log);
},
strict: true,
});
}
/**
* Watches for reward recipient set events.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* })
*
* const unwatch = Actions.reward.watchRewardRecipientSet(client, {
* token: '0x20c0000000000000000000000000000000000001',
* onRewardRecipientSet: (args, log) => {
* console.log('Reward recipient set:', args)
* },
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
export function watchRewardRecipientSet(client, parameters) {
const { onRewardRecipientSet, token, ...rest } = parameters;
return watchContractEvent(client, {
...rest,
address: token,
abi: Abis.tip20,
eventName: 'RewardRecipientSet',
onLogs: (logs) => {
for (const log of logs)
onRewardRecipientSet(log.args, log);
},
strict: true,
});
}
//# sourceMappingURL=reward.js.map

1
node_modules/viem/_esm/tempo/actions/reward.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

233
node_modules/viem/_esm/tempo/actions/simulate.js generated vendored Normal file
View File

@@ -0,0 +1,233 @@
import * as BlockOverrides from 'ox/BlockOverrides';
import { parseAccount, } from '../../accounts/utils/parseAccount.js';
import { AbiDecodingZeroDataError } from '../../errors/abi.js';
import { RawContractError } from '../../errors/contract.js';
import { UnknownNodeError } from '../../errors/node.js';
import { decodeFunctionResult, } from '../../utils/abi/decodeFunctionResult.js';
import { encodeFunctionData, } from '../../utils/abi/encodeFunctionData.js';
import { concat } from '../../utils/data/concat.js';
import { numberToHex, } from '../../utils/encoding/toHex.js';
import { getContractError } from '../../utils/errors/getContractError.js';
import { getNodeError, } from '../../utils/errors/getNodeError.js';
import { formatBlock, } from '../../utils/formatters/block.js';
import { formatLog } from '../../utils/formatters/log.js';
import { formatTransactionRequest, } from '../../utils/formatters/transactionRequest.js';
import { serializeStateOverride, } from '../../utils/stateOverride.js';
import { assertRequest, } from '../../utils/transaction/assertRequest.js';
/**
* Simulates a set of calls on block(s) via `tempo_simulateV1`.
*
* Returns simulated block results and token metadata for any TIP-20
* tokens involved in the simulation.
*
* @example
* ```ts
* import { createClient, http, parseUnits } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* account: '0x...',
* chain: tempo,
* transport: http(),
* })
*
* const { blocks, tokenMetadata } = await Actions.simulate.simulateBlocks(client, {
* blocks: [{
* calls: [
* Actions.token.transfer.call({
* token: '0x20c0...01',
* to: '0x...',
* amount: parseUnits('100', 6),
* }),
* ],
* }],
* traceTransfers: true,
* })
* ```
*
* @param client - Client.
* @param parameters - {@link simulateBlocks.Parameters}
* @returns Simulated blocks and token metadata. {@link simulateBlocks.ReturnType}
*/
export async function simulateBlocks(client, parameters) {
const { blockNumber, blockTag = client.experimental_blockTag ?? 'latest', blocks, returnFullTransactions, traceTransfers, validation, } = parameters;
try {
const blockStateCalls = [];
for (const block of blocks) {
const blockOverrides = block.blockOverrides
? BlockOverrides.toRpc(block.blockOverrides)
: undefined;
const calls = block.calls.map((call_) => {
const call = call_;
const account = call.account
? parseAccount(call.account)
: client.account
? parseAccount(client.account)
: undefined;
const data = call.abi ? encodeFunctionData(call) : call.data;
const request = {
...call,
account,
data: call.dataSuffix
? concat([data || '0x', call.dataSuffix])
: data,
from: call.from ?? account?.address,
};
assertRequest(request);
return formatTransactionRequest(request);
});
const stateOverrides = block.stateOverrides
? serializeStateOverride(block.stateOverrides)
: undefined;
blockStateCalls.push({
blockOverrides,
calls,
stateOverrides,
});
}
const blockNumberHex = typeof blockNumber === 'bigint' ? numberToHex(blockNumber) : undefined;
const block = blockNumberHex || blockTag;
const result = await client.request({
method: 'tempo_simulateV1',
params: [
{
blockStateCalls,
returnFullTransactions,
traceTransfers,
validation,
},
block,
],
});
return {
blocks: result.blocks.map((block, i) => ({
...formatBlock(block),
calls: block.calls?.map((call, j) => {
const { abi, args, functionName, to } = blocks[i].calls[j];
const data = call.error?.data ?? call.returnData;
const gasUsed = BigInt(call.gasUsed);
const logs = call.logs?.map((log) => formatLog(log));
const status = call.status === '0x1' ? 'success' : 'failure';
const result = abi && status === 'success' && data !== '0x'
? decodeFunctionResult({
abi,
data,
functionName,
})
: null;
const error = (() => {
if (status === 'success')
return undefined;
let error;
if (data === '0x')
error = new AbiDecodingZeroDataError();
else if (data)
error = new RawContractError({ data });
if (!error)
return undefined;
return getContractError(error, {
abi: (abi ?? []),
address: to ?? '0x',
args,
functionName: functionName ?? '<unknown>',
});
})();
return {
data,
gasUsed,
logs,
status,
...(status === 'success'
? {
result,
}
: {
error,
}),
};
}),
})),
tokenMetadata: result.tokenMetadata ?? {},
};
}
catch (e) {
const cause = e;
const error = getNodeError(cause, {});
if (error instanceof UnknownNodeError)
throw cause;
throw error;
}
}
/**
* Simulates execution of a batch of calls via `tempo_simulateV1`.
*
* A convenience wrapper around {@link simulateBlocks} that runs all
* calls in a single block and returns flattened results.
*
* @example
* ```ts
* import { createClient, http, parseUnits } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions, Addresses } from 'viem/tempo'
*
* const client = createClient({
* account: '0x...',
* chain: tempo,
* transport: http(),
* })
*
* const { results, tokenMetadata } = await Actions.simulate.simulateCalls(client, {
* calls: [
* Actions.token.approve.call({
* token: '0x20c0...01',
* spender: Addresses.stablecoinDex,
* amount: parseUnits('100', 6),
* }),
* Actions.dex.buy.call({
* tokenIn: '0x20c0...01',
* tokenOut: '0x20c0...02',
* amountOut: parseUnits('10', 6),
* maxAmountIn: parseUnits('100', 6),
* }),
* Actions.token.transfer.call({
* token: '0x20c0...02',
* to: '0x...',
* amount: parseUnits('10', 6),
* }),
* ],
* })
* ```
*
* @param client - Client.
* @param parameters - {@link simulateCalls.Parameters}
* @returns Results, block, and token metadata. {@link simulateCalls.ReturnType}
*/
export async function simulateCalls(client, parameters) {
const { blockNumber, blockTag, calls, stateOverrides, traceTransfers, validation, } = parameters;
const account = parameters.account
? parseAccount(parameters.account)
: undefined;
const result = await simulateBlocks(client, {
blockNumber,
blockTag: blockTag,
blocks: [
{
calls: calls.map((call) => ({
...call,
from: account?.address,
})),
stateOverrides,
},
],
traceTransfers,
validation,
});
const { calls: block_calls, ...block } = result.blocks[0];
return {
block,
results: block_calls,
tokenMetadata: result.tokenMetadata,
};
}
//# sourceMappingURL=simulate.js.map

1
node_modules/viem/_esm/tempo/actions/simulate.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

2953
node_modules/viem/_esm/tempo/actions/token.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

1
node_modules/viem/_esm/tempo/actions/token.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

1017
node_modules/viem/_esm/tempo/actions/validator.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

228
node_modules/viem/_esm/tempo/actions/virtualAddress.js generated vendored Normal file
View File

@@ -0,0 +1,228 @@
import * as Hex from 'ox/Hex';
import { readContract } from '../../actions/public/readContract.js';
import { writeContract } from '../../actions/wallet/writeContract.js';
import { writeContractSync } from '../../actions/wallet/writeContractSync.js';
import { zeroAddress } from '../../constants/address.js';
import { parseEventLogs } from '../../utils/abi/parseEventLogs.js';
import * as Abis from '../Abis.js';
import * as Addresses from '../Addresses.js';
import { defineCall } from '../internal/utils.js';
/**
* Gets the master address for a given master ID.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* })
*
* const address = await Actions.virtualAddress.getMasterAddress(client, {
* masterId: '0xdeadbeef',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The master address, or null if unregistered.
*/
export async function getMasterAddress(client, parameters) {
const address = await readContract(client, {
...parameters,
...getMasterAddress.call({ masterId: parameters.masterId }),
});
if (address === zeroAddress)
return null;
return address;
}
(function (getMasterAddress) {
/**
* Defines a call to the `getMaster` function.
*
* @param args - Arguments.
* @returns The call.
*/
function call(args) {
const { masterId } = args;
return defineCall({
address: Addresses.addressRegistry,
abi: Abis.addressRegistry,
args: [masterId],
functionName: 'getMaster',
});
}
getMasterAddress.call = call;
})(getMasterAddress || (getMasterAddress = {}));
/**
* Resolves a virtual address to its master address.
*
* - Non-virtual addresses are returned unchanged.
* - Virtual addresses with a registered master return the master address.
* - Virtual addresses with an unregistered master return null.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* })
*
* const recipient = await Actions.virtualAddress.resolve(client, {
* address: '0x...',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The resolved address, or null if virtual and unregistered.
*/
export async function resolve(client, parameters) {
if (!isVirtual(parameters.address))
return parameters.address;
const masterId = Hex.slice(parameters.address, 0, 4);
return getMasterAddress(client, { ...parameters, masterId });
}
/**
* Registers a virtual master address.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
* import { privateKeyToAccount } from 'viem/accounts'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* })
*
* const hash = await Actions.virtualAddress.registerMaster(client, {
* salt: '0x...',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction hash.
*/
export async function registerMaster(client, parameters) {
return registerMaster.inner(writeContract, client, parameters);
}
(function (registerMaster) {
/** @internal */
async function inner(action, client, parameters) {
const { salt, ...rest } = parameters;
const call = registerMaster.call({ salt });
return (await action(client, {
...rest,
...call,
}));
}
registerMaster.inner = inner;
/**
* Defines a call to the `registerVirtualMaster` function.
*
* Can be passed as a parameter to:
* - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call
* - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call
* - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls
*
* @example
* ```ts
* import { createClient, http, walletActions } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(walletActions)
*
* const { result } = await client.sendCalls({
* calls: [
* Actions.virtualAddress.registerMaster.call({
* salt: '0x...',
* }),
* ]
* })
* ```
*
* @param args - Arguments.
* @returns The call.
*/
function call(args) {
const { salt } = args;
return defineCall({
address: Addresses.addressRegistry,
abi: Abis.addressRegistry,
functionName: 'registerVirtualMaster',
args: [salt],
});
}
registerMaster.call = call;
function extractEvent(logs) {
const [log] = parseEventLogs({
abi: Abis.addressRegistry,
logs,
eventName: 'MasterRegistered',
strict: true,
});
if (!log)
throw new Error('`MasterRegistered` event not found.');
return log;
}
registerMaster.extractEvent = extractEvent;
})(registerMaster || (registerMaster = {}));
/**
* Registers a virtual master address and waits for confirmation.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'viem/chains'
* import { Actions } from 'viem/tempo'
* import { privateKeyToAccount } from 'viem/accounts'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* })
*
* const { receipt, masterId, masterAddress } = await Actions.virtualAddress.registerMasterSync(client, {
* salt: '0x...',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction receipt and extracted event data.
*/
export async function registerMasterSync(client, parameters) {
const { throwOnReceiptRevert = true, ...rest } = parameters;
const receipt = await registerMaster.inner(writeContractSync, client, {
...rest,
throwOnReceiptRevert,
});
const { args } = registerMaster.extractEvent(receipt.logs);
return {
...args,
receipt,
};
}
const virtualMagic = '0xfdfdfdfdfdfdfdfdfdfd';
/** @internal */
function isVirtual(address) {
return Hex.slice(address, 4, 14).toLowerCase() === virtualMagic;
}
//# sourceMappingURL=virtualAddress.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"virtualAddress.js","sourceRoot":"","sources":["../../../tempo/actions/virtualAddress.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,QAAQ,CAAA;AAE7B,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAA;AAEnE,OAAO,EAA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AAG,CAAC,GAAG,cAAc,CAAC;YAC3B,GAAG,EAAE,IAAI,CAAC,eAAe;YACzB,IAAI;YACJ,SAAS,EAAE,kBAAkB;YAC7B,MAAM,EAAE,IAAI;SACb,CAAC,CAAA;QACF,IAAI,CAAC,GAAG;YAAE,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAA;QAChE,OAAO,GAAG,CAAA;IACZ,CAAC;IATe,2BAAY,eAS3B,CAAA;AACH,CAAC,EArFgB,cAAc,KAAd,cAAc,QAqF9B;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAItC,MAAyC,EACzC,UAAyD;IAEzD,MAAM,EAAE,oBAAoB,GAAG,IAAI,EAAE,GAAG,IAAI,EAAE,GAAG,UAAU,CAAA;IAC3D,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,KAAK,CAAC,iBAAiB,EAAE,MAAM,EAAE;QACpE,GAAG,IAAI;QACP,oBAAoB;KACZ,CAAC,CAAA;IACX,MAAM,EAAE,IAAI,EAAE,GAAG,cAAc,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IAC1D,OAAO;QACL,GAAG,IAAI;QACP,OAAO;KACC,CAAA;AACZ,CAAC;AAwBD,MAAM,YAAY,GAAG,wBAAwB,CAAA;AAE7C,gBAAgB;AAChB,SAAS,SAAS,CAAC,OAAe;IAChC,OAAO,GAAG,CAAC,KAAK,CAAC,OAAkB,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,KAAK,YAAY,CAAA;AAC5E,CAAC"}

786
node_modules/viem/_esm/tempo/actions/zone.js generated vendored Normal file
View File

@@ -0,0 +1,786 @@
import * as Bytes from 'ox/Bytes';
import * as Hex from 'ox/Hex';
import * as PublicKey from 'ox/PublicKey';
import * as Secp256k1 from 'ox/Secp256k1';
import { TokenId, ZoneId, ZoneRpcAuthentication } from 'ox/tempo';
import { parseAccount } from '../../accounts/utils/parseAccount.js';
import { readContract } from '../../actions/public/readContract.js';
import { sendTransaction, } from '../../actions/wallet/sendTransaction.js';
import { sendTransactionSync } from '../../actions/wallet/sendTransactionSync.js';
import { zeroHash } from '../../constants/bytes.js';
import { encodeAbiParameters } from '../../utils/abi/encodeAbiParameters.js';
import * as Abis from '../Abis.js';
import * as Addresses from '../Addresses.js';
import { defineCall } from '../internal/utils.js';
import * as Storage from '../Storage.js';
import * as ZoneAbis from '../zones/Abis.js';
import { getPortalAddress } from '../zones/zone.js';
/**
* Deposits tokens into a zone on the parent Tempo chain.
* Batches approve and deposit into a single transaction.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempoModerato } from 'viem/chains'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempoModerato,
* transport: http(),
* })
*
* const hash = await Actions.zone.deposit(client, {
* token: '0x20c0...0001',
* amount: 1_000_000n,
* zoneId: 7,
* })
* ```
*
* @param client - Wallet client connected to the parent Tempo chain.
* @param parameters - Deposit parameters.
* @returns The transaction hash.
*/
export async function deposit(client, parameters) {
const chainId = client.chain?.id;
if (!chainId)
throw new Error('`chain` is required.');
const { account = client.account, ...rest } = parameters;
const account_ = account ? parseAccount(account) : undefined;
if (!account)
throw new Error('`account` is required.');
const recipient = parameters.recipient ?? account_?.address;
if (!recipient)
throw new Error('`recipient` is required.');
const args = { ...parameters, chainId, recipient };
return sendTransaction(client, {
...rest,
calls: deposit.calls(args),
});
}
(function (deposit) {
/**
* Defines the calls to approve and deposit tokens into a zone.
*
* @param args - Arguments.
* @returns The calls.
*/
function calls(args) {
const { amount, chainId, memo = zeroHash, recipient, token, zoneId } = args;
const portalAddress = getPortalAddress(chainId, zoneId);
return [
defineCall({
address: TokenId.toAddress(token),
abi: Abis.tip20,
functionName: 'approve',
args: [portalAddress, amount],
}),
defineCall({
address: portalAddress,
abi: ZoneAbis.zonePortal,
functionName: 'deposit',
args: [TokenId.toAddress(token), recipient, amount, memo],
}),
];
}
deposit.calls = calls;
})(deposit || (deposit = {}));
/**
* Deposits tokens into a zone on the parent Tempo chain and waits for the
* transaction receipt.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempoModerato } from 'viem/chains'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempoModerato,
* transport: http(),
* })
*
* const result = await Actions.zone.depositSync(client, {
* token: '0x20c0...0001',
* amount: 1_000_000n,
* zoneId: 7,
* })
* ```
*
* @param client - Wallet client connected to the parent Tempo chain.
* @param parameters - Deposit parameters.
* @returns The transaction receipt.
*/
export async function depositSync(client, parameters) {
const chainId = client.chain?.id;
if (!chainId)
throw new Error('`chain` is required.');
const { account = client.account, throwOnReceiptRevert = true, ...rest } = parameters;
const account_ = account ? parseAccount(account) : undefined;
if (!account)
throw new Error('`account` is required.');
const recipient = parameters.recipient ?? account_?.address;
if (!recipient)
throw new Error('`recipient` is required.');
const args = { ...parameters, chainId, recipient };
const receipt = await sendTransactionSync(client, {
...rest,
throwOnReceiptRevert,
calls: deposit.calls(args),
});
return { receipt };
}
/**
* Deposits tokens into a zone on the parent Tempo chain with encrypted
* recipient and memo. Batches approve and depositEncrypted into a single
* transaction.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempoModerato } from 'viem/chains'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempoModerato,
* transport: http(),
* })
*
* const hash = await Actions.zone.encryptedDeposit(client, {
* token: '0x20c0...0001',
* amount: 1_000_000n,
* zoneId: 7,
* })
* ```
*
* @param client - Wallet client connected to the parent Tempo chain.
* @param parameters - Encrypted deposit parameters.
* @returns The transaction hash.
*/
export async function encryptedDeposit(client, parameters) {
const chainId = client.chain?.id;
if (!chainId)
throw new Error('`chain` is required.');
const { account = client.account, ...rest } = parameters;
const account_ = account ? parseAccount(account) : undefined;
if (!account)
throw new Error('`account` is required.');
const recipient = parameters.recipient ?? account_?.address;
if (!recipient)
throw new Error('`recipient` is required.');
const portalAddress = getPortalAddress(chainId, parameters.zoneId);
const [publicKey, keyIndex] = await Promise.all([
readContract(client, {
address: portalAddress,
abi: ZoneAbis.zonePortal,
functionName: 'sequencerEncryptionKey',
}),
readContract(client, {
address: portalAddress,
abi: ZoneAbis.zonePortal,
functionName: 'encryptionKeyCount',
}),
]);
if (keyIndex === 0n) {
throw new Error('No sequencer encryption key configured.');
}
const encrypted = await encryptDepositPayload({ x: publicKey[0], yParity: publicKey[1] }, recipient, parameters.memo);
const args = {
...parameters,
chainId,
encrypted,
keyIndex: keyIndex - 1n,
recipient,
};
return sendTransaction(client, {
...rest,
calls: encryptedDeposit.calls(args),
});
}
(function (encryptedDeposit) {
/**
* Defines the calls to approve and deposit tokens into a zone (encrypted).
*
* @param args - Arguments.
* @returns The calls.
*/
function calls(args) {
const { amount, chainId, encrypted, keyIndex, token, zoneId } = args;
const portalAddress = getPortalAddress(chainId, zoneId);
return [
defineCall({
address: TokenId.toAddress(token),
abi: Abis.tip20,
functionName: 'approve',
args: [portalAddress, amount],
}),
defineCall({
address: portalAddress,
abi: ZoneAbis.zonePortal,
functionName: 'depositEncrypted',
args: [
TokenId.toAddress(token),
amount,
keyIndex,
{
ephemeralPubkeyX: encrypted.ephemeralPubkeyX,
ephemeralPubkeyYParity: encrypted.ephemeralPubkeyYParity,
ciphertext: encrypted.ciphertext,
nonce: encrypted.nonce,
tag: encrypted.tag,
},
],
}),
];
}
encryptedDeposit.calls = calls;
})(encryptedDeposit || (encryptedDeposit = {}));
/**
* Deposits tokens into a zone on the parent Tempo chain with encrypted
* recipient and memo, and waits for the transaction receipt.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempoModerato } from 'viem/chains'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempoModerato,
* transport: http(),
* })
*
* const result = await Actions.zone.encryptedDepositSync(client, {
* token: '0x20c0...0001',
* amount: 1_000_000n,
* zoneId: 7,
* })
* ```
*
* @param client - Wallet client connected to the parent Tempo chain.
* @param parameters - Encrypted deposit parameters.
* @returns The transaction receipt.
*/
export async function encryptedDepositSync(client, parameters) {
const chainId = client.chain?.id;
if (!chainId)
throw new Error('`chain` is required.');
const { account = client.account, throwOnReceiptRevert = true, ...rest } = parameters;
const account_ = account ? parseAccount(account) : undefined;
if (!account)
throw new Error('`account` is required.');
const recipient = parameters.recipient ?? account_?.address;
if (!recipient)
throw new Error('`recipient` is required.');
const portalAddress = getPortalAddress(chainId, parameters.zoneId);
const [publicKey, keyIndex] = await Promise.all([
readContract(client, {
address: portalAddress,
abi: ZoneAbis.zonePortal,
functionName: 'sequencerEncryptionKey',
}),
readContract(client, {
address: portalAddress,
abi: ZoneAbis.zonePortal,
functionName: 'encryptionKeyCount',
}),
]);
if (keyIndex === 0n) {
throw new Error('No sequencer encryption key configured.');
}
const encrypted = await encryptDepositPayload({ x: publicKey[0], yParity: publicKey[1] }, recipient, parameters.memo);
const args = {
...parameters,
chainId,
encrypted,
keyIndex: keyIndex - 1n,
recipient,
};
const receipt = await sendTransactionSync(client, {
...rest,
throwOnReceiptRevert,
calls: encryptedDeposit.calls(args),
});
return { receipt };
}
/**
* Returns the authenticated account address and authorization token expiry.
*
* @example
* ```ts
* import { createClient } from 'viem'
* import { http, zoneModerato } from 'viem/tempo/zones'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* chain: zoneModerato(7),
* transport: http(),
* })
*
* const info = await Actions.zone.getAuthorizationTokenInfo(client)
* ```
*
* @param client - Zone client.
* @returns Authorization token info.
*/
export async function getAuthorizationTokenInfo(client) {
const info = await client.request({
method: 'zone_getAuthorizationTokenInfo',
params: [],
});
return {
account: info.account,
expiresAt: Hex.toBigInt(info.expiresAt),
};
}
/**
* Returns deposit processing status for a given Tempo block number.
*
* @example
* ```ts
* import { createClient } from 'viem'
* import { http, zoneModerato } from 'viem/tempo/zones'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* chain: zoneModerato(7),
* transport: http(),
* })
*
* const status = await Actions.zone.getDepositStatus(client, {
* tempoBlockNumber: 42n,
* })
* ```
*
* @param client - Zone client.
* @param parameters - Parameters including the Tempo block number.
* @returns Deposit status.
*/
export async function getDepositStatus(client, parameters) {
const { tempoBlockNumber } = parameters;
const status = await client.request({
method: 'zone_getDepositStatus',
params: [Hex.fromNumber(tempoBlockNumber)],
});
return {
deposits: status.deposits.map((deposit) => ({
amount: Hex.toBigInt(deposit.amount),
depositHash: deposit.depositHash,
kind: deposit.kind,
memo: deposit.memo,
recipient: deposit.recipient,
sender: deposit.sender,
status: deposit.status,
token: deposit.token,
})),
processed: status.processed,
tempoBlockNumber: Hex.toBigInt(status.tempoBlockNumber),
zoneProcessedThrough: Hex.toBigInt(status.zoneProcessedThrough),
};
}
/**
* Returns the fee required for a withdrawal from a zone, given a gas limit.
*
* The client must be connected to the **zone chain**.
*
* @example
* ```ts
* import { createClient } from 'viem'
* import { http, zoneModerato } from 'viem/tempo/zones'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* chain: zoneModerato(7),
* transport: http(),
* })
*
* const fee = await Actions.zone.getWithdrawalFee(client)
* ```
*
* @param client - Zone client.
* @param parameters - Optional gas limit parameter.
* @returns The withdrawal fee as a bigint.
*/
export async function getWithdrawalFee(client, parameters = {}) {
const { gas = 0n, ...rest } = parameters;
return readContract(client, {
...rest,
address: Addresses.zoneOutbox,
abi: ZoneAbis.zoneOutbox,
functionName: 'calculateWithdrawalFee',
args: [gas],
});
}
/**
* Returns the current zone metadata.
*
* @example
* ```ts
* import { createClient } from 'viem'
* import { http, zoneModerato } from 'viem/tempo/zones'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* chain: zoneModerato(7),
* transport: http(),
* })
*
* const info = await Actions.zone.getZoneInfo(client)
* ```
*
* @param client - Zone client.
* @returns Zone metadata.
*/
export async function getZoneInfo(client) {
const info = await client.request({
method: 'zone_getZoneInfo',
params: [],
});
return {
chainId: Hex.toNumber(info.chainId),
sequencer: info.sequencer,
zoneId: Hex.toNumber(info.zoneId),
zoneTokens: info.zoneTokens,
};
}
/**
* Requests a withdrawal from a zone to the parent Tempo chain via the
* ZoneOutbox contract.
*
* The client must be connected to the **zone chain**.
*
* @example
* ```ts
* import { createClient } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { http, zoneModerato } from 'viem/tempo/zones'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: zoneModerato(7),
* transport: http(),
* })
*
* const hash = await Actions.zone.requestWithdrawal(client, {
* token: '0x20c0...0001',
* amount: 1_000_000n,
* })
* ```
*
* @param client - Wallet client connected to the zone chain.
* @param parameters - Withdrawal parameters.
* @returns The transaction hash.
*/
export async function requestWithdrawal(client, parameters) {
const { account = client.account, ...rest } = parameters;
const account_ = account ? parseAccount(account) : undefined;
if (!account)
throw new Error('`account` is required.');
const to = parameters.to ?? account_?.address;
if (!to)
throw new Error('`to` is required.');
const args = { ...parameters, to };
return sendTransaction(client, {
...rest,
calls: requestWithdrawal.calls(args),
});
}
(function (requestWithdrawal) {
/**
* Defines the calls to approve and request a withdrawal from a zone.
*
* @param args - Arguments.
* @returns The calls.
*/
function calls(args) {
const { amount, data = '0x', fallbackRecipient = args.to, gas = 0n, memo = zeroHash, to, token, } = args;
return [
defineCall({
address: TokenId.toAddress(token),
abi: Abis.tip20,
functionName: 'approve',
args: [Addresses.zoneOutbox, amount],
}),
defineCall({
address: Addresses.zoneOutbox,
abi: ZoneAbis.zoneOutbox,
functionName: 'requestWithdrawal',
args: [
TokenId.toAddress(token),
to,
amount,
memo,
gas,
fallbackRecipient,
data,
'0x',
],
}),
];
}
requestWithdrawal.calls = calls;
})(requestWithdrawal || (requestWithdrawal = {}));
/**
* Requests a withdrawal from a zone to the parent Tempo chain and waits for
* the transaction receipt.
*
* @example
* ```ts
* import { createClient } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { http, zoneModerato } from 'viem/tempo/zones'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: zoneModerato(7),
* transport: http(),
* })
*
* const result = await Actions.zone.requestWithdrawalSync(client, {
* token: '0x20c0...0001',
* amount: 1_000_000n,
* })
* ```
*
* @param client - Wallet client connected to the zone chain.
* @param parameters - Withdrawal parameters.
* @returns The transaction receipt.
*/
export async function requestWithdrawalSync(client, parameters) {
const { account = client.account, throwOnReceiptRevert = true, ...rest } = parameters;
const account_ = account ? parseAccount(account) : undefined;
if (!account)
throw new Error('`account` is required.');
const to = parameters.to ?? account_?.address;
if (!to)
throw new Error('`to` is required.');
const args = { ...parameters, to };
const receipt = await sendTransactionSync(client, {
...rest,
calls: requestWithdrawal.calls(args),
throwOnReceiptRevert,
});
return { receipt };
}
/**
* Requests a verifiable withdrawal from a zone to the parent Tempo chain via
* the ZoneOutbox contract. Includes a `revealTo` public key so the sequencer
* can encrypt the withdrawal details.
*
* The client must be connected to the **zone chain**.
*
* @example
* ```ts
* import { createClient } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { http, zoneModerato } from 'viem/tempo/zones'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: zoneModerato(7),
* transport: http(),
* })
*
* const hash = await Actions.zone.requestVerifiableWithdrawal(client, {
* token: '0x20c0...0001',
* amount: 1_000_000n,
* revealTo: '0x02abc...def',
* })
* ```
*
* @param client - Wallet client connected to the zone chain.
* @param parameters - Verifiable withdrawal parameters.
* @returns The transaction hash.
*/
export async function requestVerifiableWithdrawal(client, parameters) {
const { account = client.account, ...rest } = parameters;
const account_ = account ? parseAccount(account) : undefined;
if (!account)
throw new Error('`account` is required.');
const to = parameters.to ?? account_?.address;
if (!to)
throw new Error('`to` is required.');
const args = { ...parameters, to };
return sendTransaction(client, {
...rest,
calls: requestVerifiableWithdrawal.calls(args),
});
}
(function (requestVerifiableWithdrawal) {
/**
* Defines the calls to approve and request a verifiable withdrawal from a zone.
*
* @param args - Arguments.
* @returns The calls.
*/
function calls(args) {
const { amount, data = '0x', fallbackRecipient = args.to, gas = 0n, memo = zeroHash, revealTo, to, token, } = args;
return [
defineCall({
address: TokenId.toAddress(token),
abi: Abis.tip20,
functionName: 'approve',
args: [Addresses.zoneOutbox, amount],
}),
defineCall({
address: Addresses.zoneOutbox,
abi: ZoneAbis.zoneOutbox,
functionName: 'requestWithdrawal',
args: [
TokenId.toAddress(token),
to,
amount,
memo,
gas,
fallbackRecipient,
data,
revealTo,
],
}),
];
}
requestVerifiableWithdrawal.calls = calls;
})(requestVerifiableWithdrawal || (requestVerifiableWithdrawal = {}));
/**
* Requests a verifiable withdrawal from a zone to the parent Tempo chain and
* waits for the transaction receipt.
*
* @example
* ```ts
* import { createClient } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { http, zoneModerato } from 'viem/tempo/zones'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: zoneModerato(7),
* transport: http(),
* })
*
* const result = await Actions.zone.requestVerifiableWithdrawalSync(client, {
* token: '0x20c0...0001',
* amount: 1_000_000n,
* revealTo: '0x02abc...def',
* })
* ```
*
* @param client - Wallet client connected to the zone chain.
* @param parameters - Verifiable withdrawal parameters.
* @returns The transaction receipt.
*/
export async function requestVerifiableWithdrawalSync(client, parameters) {
const { account = client.account, throwOnReceiptRevert = true, ...rest } = parameters;
const account_ = account ? parseAccount(account) : undefined;
if (!account)
throw new Error('`account` is required.');
const to = parameters.to ?? account_?.address;
if (!to)
throw new Error('`to` is required.');
const args = { ...parameters, to };
const receipt = await sendTransactionSync(client, {
...rest,
calls: requestVerifiableWithdrawal.calls(args),
throwOnReceiptRevert,
});
return { receipt };
}
/**
* Signs a zone authorization token and stores it for the zone HTTP transport.
*
* Zone chains should define `contracts.zonePortal` with the portal address.
* The `zoneId` is derived from `ZoneId.fromChainId(chain.id)` and can be overridden.
*
* @example
* ```ts
* import { createClient } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { http, zoneModerato } from 'viem/tempo/zones'
* import { Actions } from 'viem/tempo'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: zoneModerato(7),
* transport: http(),
* })
*
* const result = await Actions.zone.signAuthorizationToken(client)
* ```
*
* @param client - Zone wallet client.
* @param parameters - Options including optional storage override.
* @returns The authentication object and serialized token.
*/
export async function signAuthorizationToken(client, parameters = {}) {
const { account = client.account, issuedAt = Math.floor(Date.now() / 1000), expiresAt = issuedAt + 86_400, storage = Storage.defaultStorage(), } = parameters;
const chain = parameters.chain ?? client.chain;
if (!chain)
throw new Error('`signAuthorizationToken` requires a chain.');
const account_ = account ? parseAccount(account) : undefined;
if (!account_ || !account_.sign)
throw new Error('`account` with `sign` is required.');
const storageKey = `auth:${account_.address.toLowerCase()}:${chain.id}`;
const authentication = ZoneRpcAuthentication.from({
chainId: chain.id,
expiresAt,
issuedAt,
zoneId: ZoneId.fromChainId(chain.id),
});
const payload = ZoneRpcAuthentication.getSignPayload(authentication);
const signature = await account_.sign({ hash: payload });
const token = ZoneRpcAuthentication.serialize(authentication, {
signature,
});
await storage.setItem(storageKey, token);
await storage.setItem(`auth:token:${chain.id}`, token);
return { authentication, token };
}
/**
* Encrypts a deposit payload (recipient + memo) using ECIES with AES-256-GCM.
*
* @internal
*/
async function encryptDepositPayload(publicKey, recipient, memo = zeroHash) {
const sequencerPublicKey = PublicKey.from({
prefix: publicKey.yParity,
x: Hex.toBigInt(publicKey.x),
});
const { privateKey: ephemeralPrivateKey, publicKey: ephemeralPublicKey } = Secp256k1.createKeyPair();
const sharedSecret = Secp256k1.getSharedSecret({
privateKey: ephemeralPrivateKey,
publicKey: sequencerPublicKey,
as: 'Bytes',
});
const hkdfKey = await globalThis.crypto.subtle.importKey('raw', sharedSecret.buffer, 'HKDF', false, ['deriveKey']);
const aesKey = await globalThis.crypto.subtle.deriveKey({
name: 'HKDF',
hash: 'SHA-256',
salt: new Uint8Array(12),
info: new TextEncoder().encode('ecies-aes-key'),
}, hkdfKey, { name: 'AES-GCM', length: 256 }, false, ['encrypt']);
const nonce = Bytes.random(12);
const plaintext = encodeAbiParameters([{ type: 'address' }, { type: 'bytes32' }], [recipient, memo]);
const ciphertextWithTag = new Uint8Array(await globalThis.crypto.subtle.encrypt({ name: 'AES-GCM', iv: nonce, tagLength: 128 }, aesKey, Bytes.from(plaintext)));
const ciphertext = ciphertextWithTag.slice(0, -16);
const tag = ciphertextWithTag.slice(-16);
const compressedEphemeral = PublicKey.compress(ephemeralPublicKey);
return {
ciphertext: Hex.fromBytes(ciphertext),
ephemeralPubkeyX: Hex.fromNumber(compressedEphemeral.x, { size: 32 }),
ephemeralPubkeyYParity: compressedEphemeral.prefix,
nonce: Hex.fromBytes(nonce),
tag: Hex.fromBytes(tag),
};
}
//# sourceMappingURL=zone.js.map

1
node_modules/viem/_esm/tempo/actions/zone.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

144
node_modules/viem/_esm/tempo/chainConfig.js generated vendored Normal file
View File

@@ -0,0 +1,144 @@
import * as Address from 'ox/Address';
import * as Hex from 'ox/Hex';
import * as PublicKey from 'ox/PublicKey';
import { SignatureEnvelope } from 'ox/tempo';
import { getCode } from '../actions/public/getCode.js';
import { verifyHash } from '../actions/public/verifyHash.js';
import { maxUint256 } from '../constants/number.js';
import { extendSchema } from '../utils/chain/defineChain.js';
import { defineTransaction } from '../utils/formatters/transaction.js';
import { defineTransactionReceipt } from '../utils/formatters/transactionReceipt.js';
import { defineTransactionRequest } from '../utils/formatters/transactionRequest.js';
import { getAction } from '../utils/getAction.js';
import { keccak256 } from '../utils/hash/keccak256.js';
import { getMetadata } from './actions/accessKey.js';
import * as Formatters from './Formatters.js';
import * as Concurrent from './internal/concurrent.js';
import * as Transaction from './Transaction.js';
const maxExpirySecs = 25;
export const chainConfig = {
blockTime: 1_000,
extendSchema: extendSchema(),
formatters: {
transaction: defineTransaction({
exclude: ['aaAuthorizationList'],
format: Formatters.formatTransaction,
}),
transactionReceipt: defineTransactionReceipt({
format: Formatters.formatTransactionReceipt,
}),
transactionRequest: defineTransactionRequest({
format: Formatters.formatTransactionRequest,
}),
},
prepareTransactionRequest: [
async (r, { phase }) => {
const request = r;
// FIXME: node estimates gas with secp256k1 dummy sig + null feePayerSignature.
// Actual tx has larger keychain/webAuthn sigs + real fee payer sig, costing more intrinsic gas.
if (phase === 'afterFillParameters') {
if (request.feePayer) {
if (request.keyAuthorization?.signature.type === 'webAuthn')
request.gas = (request.gas ?? 0n) + 20000n;
else if (request.account?.source === 'accessKey')
request.gas = (request.gas ?? 0n) + 10000n;
}
return request;
}
// Use expiring nonces for concurrent transactions (TIP-1009).
// When nonceKey is 'expiring', feePayer is specified, or concurrent requests
// are detected, we use expiring nonces (nonceKey = uint256.max) with a
// validBefore timestamp.
const useExpiringNonce = await (async () => {
if (request.nonceKey === 'expiring')
return true;
if (request.feePayer && typeof request.nonceKey === 'undefined')
return true;
const address = request.account?.address;
if (address && typeof request.nonceKey === 'undefined')
return await Concurrent.detect(address);
return false;
})();
if (useExpiringNonce) {
request.nonceKey = maxUint256;
request.nonce = 0;
if (typeof request.validBefore === 'undefined')
request.validBefore = Math.floor(Date.now() / 1000) + maxExpirySecs;
}
else if (typeof request.nonceKey !== 'undefined') {
// Explicit nonceKey provided (2D nonce mode)
request.nonce = typeof request.nonce === 'number' ? request.nonce : 0;
}
if (!request.feeToken && request.chain?.feeToken)
request.feeToken = request.chain.feeToken;
return request;
},
{ runAt: ['beforeFillTransaction', 'afterFillParameters'] },
],
serializers: {
// TODO: casting to satisfy viem viem v3 to have more flexible serializer type.
transaction: ((transaction, signature) => Transaction.serialize(transaction, signature)),
},
async verifyHash(client, parameters) {
const { address, hash, signature, mode } = parameters;
const envelope = (() => {
if (typeof signature !== 'string')
return;
try {
return SignatureEnvelope.deserialize(signature);
}
catch {
return undefined;
}
})();
// `verifyHash` supports "signature envelopes" (a Tempo proposal) to natively verify arbitrary
// envelope-compatible (WebAuthn, P256, etc.) signatures.
if (envelope) {
// Access key (keychain) signature verification: check the key is
// authorized, not expired, and not revoked on the AccountKeychain.
if (envelope?.type === 'keychain' && mode === 'allowAccessKey') {
const accessKeyAddress = Address.fromPublicKey(PublicKey.from(envelope.inner.publicKey));
const keyInfo = await getMetadata(client, {
account: address,
accessKey: accessKeyAddress,
blockNumber: parameters.blockNumber,
blockTag: parameters.blockTag,
});
if (keyInfo.isRevoked)
return false;
if (keyInfo.expiry <= BigInt(Math.floor(Date.now() / 1000)))
return false;
// For v2 keychain envelopes, the inner signature signs
// keccak256(0x04 || hash || userAddress).
const innerPayload = envelope.version === 'v2'
? keccak256(Hex.concat('0x04', hash, address))
: hash;
return SignatureEnvelope.verify(envelope.inner, {
address: accessKeyAddress,
payload: innerPayload,
});
}
// Stateless, non-keychain signature envelopes (P256, WebAuthn) can be
// verified directly without a network request.
if (envelope.type === 'p256' || envelope.type === 'webAuthn') {
const code = await getCode(client, {
address,
blockNumber: parameters.blockNumber,
blockTag: parameters.blockTag,
});
// Check if EOA, if not, we want to go down the ERC-1271 flow.
if (
// not a contract (EOA)
!code ||
// default delegation (tempo EOA)
code === '0xef01007702c00000000000000000000000000000000000')
return SignatureEnvelope.verify(envelope, {
address,
payload: hash,
});
}
}
return await getAction(client, verifyHash, 'verifyHash')({ ...parameters, chain: null });
},
};
//# sourceMappingURL=chainConfig.js.map

1
node_modules/viem/_esm/tempo/chainConfig.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"chainConfig.js","sourceRoot":"","sources":["../../tempo/chainConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,YAAY,CAAA;AACrC,OAAO,KAAK,GAAG,MAAM,QAAQ,CAAA;AAC7B,OAAO,KAAK,SAAS,MAAM,cAAc,CAA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AAE,UAAU,CAAC,QAAQ;iBACrB,CAAC,CAAA;gBACX,8DAA8D;gBAC9D;gBACE,uBAAuB;gBACvB,CAAC,IAAI;oBACL,iCAAiC;oBACjC,IAAI,KAAK,kDAAkD;oBAE3D,OAAO,iBAAiB,CAAC,MAAM,CAAC,QAAQ,EAAE;wBACxC,OAAO;wBACP,OAAO,EAAE,IAAI;qBACd,CAAC,CAAA;YACN,CAAC;QACH,CAAC;QAED,OAAO,MAAM,SAAS,CACpB,MAAM,EACN,UAAU,EACV,YAAY,CACb,CAAC,EAAE,GAAG,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;IACnC,CAAC;CAC0D,CAAA"}

21
node_modules/viem/_esm/tempo/index.js generated vendored Normal file
View File

@@ -0,0 +1,21 @@
// biome-ignore lint/performance/noBarrelFile: entrypoint module
export { Bytes, PublicKey, Secp256k1 } from 'ox';
export { Period, TempoAddress, Tick, TokenId, VirtualAddress, VirtualMaster, } from 'ox/tempo';
export * as Abis from './Abis.js';
export * as Account from './Account.js';
export * as Addresses from './Addresses.js';
export * as Actions from './actions/index.js';
export * as Capabilities from './Capabilities.js';
export { decorator as tempoActions, } from './Decorator.js';
export * as Expiry from './Expiry.js';
export * as Formatters from './Formatters.js';
export * as Hardfork from './Hardfork.js';
export * as P256 from './P256.js';
export * as Storage from './Storage.js';
export * as TokenIds from './TokenIds.js';
export * as Transaction from './Transaction.js';
export * as Transport from './Transport.js';
export { walletNamespaceCompat, withFeePayer, withRelay } from './Transport.js';
export * as WebAuthnP256 from './WebAuthnP256.js';
export * as WebCryptoP256 from './WebCryptoP256.js';
//# sourceMappingURL=index.js.map

1
node_modules/viem/_esm/tempo/index.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../tempo/index.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,IAAI,CAAA;AAYhD,OAAO,EACL,MAAM,EACN,YAAY,EACZ,IAAI,EACJ,OAAO,EACP,cAAc,EACd,aAAa,GACd,MAAM,UAAU,CAAA;AACjB,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAC3C,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAA;AAC7C,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAEL,SAAS,IAAI,YAAY,GAC1B,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAK,MAAM,MAAM,aAAa,CAAA;AACrC,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAC7C,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AACzC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AA8BzC,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAA;AAC/C,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC/E,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAA;AACjD,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAA"}

26
node_modules/viem/_esm/tempo/internal/concurrent.js generated vendored Normal file
View File

@@ -0,0 +1,26 @@
const concurrentCounts = new Map();
/**
* Detects if there are concurrent tasks occuring for a given key
* within the same event loop tick. Registers the request, yields to allow
* other concurrent calls to register, then returns whether multiple requests
* were detected.
*
* @example
* ```ts
* const isConcurrent = await Concurrent.detect(address)
* ```
*/
export async function detect(key) {
concurrentCounts.set(key, (concurrentCounts.get(key) ?? 0) + 1);
await Promise.resolve();
const isConcurrent = (concurrentCounts.get(key) ?? 0) > 1;
queueMicrotask(() => {
const count = concurrentCounts.get(key) ?? 0;
if (count <= 1)
concurrentCounts.delete(key);
else
concurrentCounts.set(key, count - 1);
});
return isConcurrent;
}
//# sourceMappingURL=concurrent.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"concurrent.js","sourceRoot":"","sources":["../../../tempo/internal/concurrent.ts"],"names":[],"mappings":"AAAA,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAAkB,CAAA;AAElD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,GAAW;IACtC,gBAAgB,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;IAC/D,MAAM,OAAO,CAAC,OAAO,EAAE,CAAA;IACvB,MAAM,YAAY,GAAG,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAA;IACzD,cAAc,CAAC,GAAG,EAAE;QAClB,MAAM,KAAK,GAAG,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QAC5C,IAAI,KAAK,IAAI,CAAC;YAAE,gBAAgB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;;YACvC,gBAAgB,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,GAAG,CAAC,CAAC,CAAA;IAC3C,CAAC,CAAC,CAAA;IACF,OAAO,YAAY,CAAA;AACrB,CAAC"}

2
node_modules/viem/_esm/tempo/internal/types.js generated vendored Normal file
View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=types.js.map

1
node_modules/viem/_esm/tempo/internal/types.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../tempo/internal/types.ts"],"names":[],"mappings":""}

34
node_modules/viem/_esm/tempo/internal/utils.js generated vendored Normal file
View File

@@ -0,0 +1,34 @@
import { encodeFunctionData } from '../../utils/index.js';
export function defineCall(call) {
return {
...call,
data: encodeFunctionData(call),
to: call.address,
};
}
/**
* Normalizes a value into a structured-clone compatible format.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/Window/structuredClone
* @internal
*/
export function normalizeValue(value) {
if (Array.isArray(value))
return value.map(normalizeValue);
if (typeof value === 'function')
return undefined;
if (typeof value !== 'object' || value === null)
return value;
if (Object.getPrototypeOf(value) !== Object.prototype)
try {
return structuredClone(value);
}
catch {
return undefined;
}
const normalized = {};
for (const [k, v] of Object.entries(value))
normalized[k] = normalizeValue(v);
return normalized;
}
//# sourceMappingURL=utils.js.map

1
node_modules/viem/_esm/tempo/internal/utils.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../tempo/internal/utils.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAEzD,MAAM,UAAU,UAAU,CASxB,IAEqE;IASrE,OAAO;QACL,GAAI,IAAY;QAChB,IAAI,EAAE,kBAAkB,CAAC,IAAa,CAAC;QACvC,EAAE,EAAE,IAAI,CAAC,OAAO;KACR,CAAA;AACZ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAO,KAAW;IAC9C,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,GAAG,CAAC,cAAc,CAAU,CAAA;IACnE,IAAI,OAAO,KAAK,KAAK,UAAU;QAAE,OAAO,SAAkB,CAAA;IAC1D,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,KAAK,CAAA;IAC7D,IAAI,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,MAAM,CAAC,SAAS;QACnD,IAAI,CAAC;YACH,OAAO,eAAe,CAAC,KAAK,CAAC,CAAA;QAC/B,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,SAAkB,CAAA;QAC3B,CAAC;IAEH,MAAM,UAAU,GAA4B,EAAE,CAAA;IAC9C,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,UAAU,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAAA;IAC7E,OAAO,UAAmB,CAAA;AAC5B,CAAC"}

79
node_modules/viem/_esm/tempo/zones/Abis.js generated vendored Normal file
View File

@@ -0,0 +1,79 @@
export const zonePortal = [
{
name: 'deposit',
type: 'function',
stateMutability: 'nonpayable',
inputs: [
{ name: '_token', type: 'address' },
{ name: 'to', type: 'address' },
{ name: 'amount', type: 'uint128' },
{ name: 'memo', type: 'bytes32' },
],
outputs: [{ name: '', type: 'bytes32' }],
},
{
name: 'depositEncrypted',
type: 'function',
stateMutability: 'nonpayable',
inputs: [
{ name: 'token', type: 'address' },
{ name: 'amount', type: 'uint128' },
{ name: 'keyIndex', type: 'uint256' },
{
name: 'encrypted',
type: 'tuple',
components: [
{ name: 'ephemeralPubkeyX', type: 'bytes32' },
{ name: 'ephemeralPubkeyYParity', type: 'uint8' },
{ name: 'ciphertext', type: 'bytes' },
{ name: 'nonce', type: 'bytes12' },
{ name: 'tag', type: 'bytes16' },
],
},
],
outputs: [{ name: '', type: 'bytes32' }],
},
{
name: 'sequencerEncryptionKey',
type: 'function',
stateMutability: 'view',
inputs: [],
outputs: [
{ name: 'x', type: 'bytes32' },
{ name: 'yParity', type: 'uint8' },
],
},
{
name: 'encryptionKeyCount',
type: 'function',
stateMutability: 'view',
inputs: [],
outputs: [{ name: '', type: 'uint256' }],
},
];
export const zoneOutbox = [
{
name: 'requestWithdrawal',
type: 'function',
stateMutability: 'nonpayable',
inputs: [
{ name: 'token', type: 'address' },
{ name: 'to', type: 'address' },
{ name: 'amount', type: 'uint128' },
{ name: 'memo', type: 'bytes32' },
{ name: 'gasLimit', type: 'uint64' },
{ name: 'fallbackRecipient', type: 'address' },
{ name: 'data', type: 'bytes' },
{ name: 'revealTo', type: 'bytes' },
],
outputs: [],
},
{
name: 'calculateWithdrawalFee',
type: 'function',
stateMutability: 'view',
inputs: [{ name: 'gasLimit', type: 'uint64' }],
outputs: [{ name: 'fee', type: 'uint128' }],
},
];
//# sourceMappingURL=Abis.js.map

1
node_modules/viem/_esm/tempo/zones/Abis.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"Abis.js","sourceRoot":"","sources":["../../../tempo/zones/Abis.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB;QACE,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,UAAU;QAChB,eAAe,EAAE,YAAY;QAC7B,MAAM,EAAE;YACN,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE;YACnC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE;YAC/B,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE;YACnC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE;SAClC;QACD,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;KACzC;IACD;QACE,IAAI,EAAE,kBAAkB;QACxB,IAAI,EAAE,UAAU;QAChB,eAAe,EAAE,YAAY;QAC7B,MAAM,EAAE;YACN,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE;YAClC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE;YACnC,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE;YACrC;gBACE,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,OAAO;gBACb,UAAU,EAAE;oBACV,EAAE,IAAI,EAAE,kBAAkB,EAAE,IAAI,EAAE,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E,IAAI,EAAE,QAAQ,EAAE;YACpC,EAAE,IAAI,EAAE,mBAAmB,EAAE,IAAI,EAAE,SAAS,EAAE;YAC9C,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE;YAC/B,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE;SACpC;QACD,OAAO,EAAE,EAAE;KACZ;IACD;QACE,IAAI,EAAE,wBAAwB;QAC9B,IAAI,EAAE,UAAU;QAChB,eAAe,EAAE,MAAM;QACvB,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;QAC9C,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;KAC5C;CACO,CAAA"}

5
node_modules/viem/_esm/tempo/zones/index.js generated vendored Normal file
View File

@@ -0,0 +1,5 @@
// biome-ignore lint/performance/noBarrelFile: entrypoint module
export * as Abis from './Abis.js';
export { http } from './transport.js';
export { from, getPortalAddress, portalAddresses, zone, zoneModerato, } from './zone.js';
//# sourceMappingURL=index.js.map

1
node_modules/viem/_esm/tempo/zones/index.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../tempo/zones/index.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AACjC,OAAO,EAAE,IAAI,EAAuB,MAAM,gBAAgB,CAAA;AAC1D,OAAO,EACL,IAAI,EACJ,gBAAgB,EAChB,eAAe,EACf,IAAI,EACJ,YAAY,GACb,MAAM,WAAW,CAAA"}

39
node_modules/viem/_esm/tempo/zones/transport.js generated vendored Normal file
View File

@@ -0,0 +1,39 @@
import { http as http_, } from '../../clients/transports/http.js';
import * as Storage_ from '../Storage.js';
/**
* Creates an HTTP transport with support for Zone authentication tokens.
*
* Reads the authorization token from Storage and injects the
* `X-Authorization-Token` header on every request. Batching is disabled
* by default because zone tokens are account-scoped.
*
* @example
* ```ts
* import { createPublicClient } from 'viem'
* import { http, zone } from 'viem/tempo/zones' // or zoneModerato
*
* const client = createPublicClient({
* chain: zone(6),
* transport: http(),
* })
* ```
*/
export function http(url, config = {}) {
const { storage: storage_, onFetchRequest, ...rest } = config;
const storage = storage_ ?? Storage_.defaultStorage();
return (config) => http_(url, {
...rest,
async onFetchRequest(request, init) {
const next = (await onFetchRequest?.(request, init)) ?? init;
const headers = new Headers(next.headers);
const chainId = config.chain?.id;
if (chainId) {
const token = (await storage.getItem(`auth:token:${chainId}`)) ?? null;
if (token)
headers.set('X-Authorization-Token', token);
}
return { ...next, headers };
},
})(config);
}
//# sourceMappingURL=transport.js.map

1
node_modules/viem/_esm/tempo/zones/transport.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../../tempo/zones/transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,IAAI,IAAI,KAAK,GACd,MAAM,kCAAkC,CAAA;AAEzC,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AAUzC;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,IAAI,CAClB,GAAwB,EACxB,SAAyB,EAAE;IAE3B,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAA;IAC7D,MAAM,OAAO,GAAG,QAAQ,IAAI,QAAQ,CAAC,cAAc,EAAE,CAAA;IAErD,OAAO,CAAC,MAAM,EAAE,EAAE,CAChB,KAAK,CAAC,GAAG,EAAE;QACT,GAAG,IAAI;QACP,KAAK,CAAC,cAAc,CAAC,OAAO,EAAE,IAAI;YAChC,MAAM,IAAI,GAAG,CAAC,MAAM,cAAc,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,IAAI,IAAI,CAAA;YAC5D,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;YAEzC,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,EAAE,EAAE,CAAA;YAChC,IAAI,OAAO,EAAE,CAAC;gBACZ,MAAM,KAAK,GAAG,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,cAAc,OAAO,EAAE,CAAC,CAAC,IAAI,IAAI,CAAA;gBACtE,IAAI,KAAK;oBAAE,OAAO,CAAC,GAAG,CAAC,uBAAuB,EAAE,KAAK,CAAC,CAAA;YACxD,CAAC;YAED,OAAO,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,CAAA;QAC7B,CAAC;KACF,CAAC,CAAC,MAAM,CAAC,CAAA;AACd,CAAC"}

49
node_modules/viem/_esm/tempo/zones/zone.js generated vendored Normal file
View File

@@ -0,0 +1,49 @@
import { ZoneId } from 'ox/tempo';
import { tempo } from '../../chains/definitions/tempo.js';
import { tempoModerato } from '../../chains/definitions/tempoModerato.js';
import { defineChain } from '../../utils/chain/defineChain.js';
import { chainConfig } from '../chainConfig.js';
export const portalAddresses = {
[tempoModerato.id]: {
6: '0x7069DeC4E64Fd07334A0933eDe836C17259c9B23',
7: '0x3F5296303400B56271b476F5A0B9cBF74350D6Ac',
},
};
export function getPortalAddress(chainId, zoneId) {
const address = portalAddresses[chainId]?.[zoneId];
if (!address)
throw new Error(`No portal address configured for zone ${zoneId} on chain ${chainId}.`);
return address;
}
export const zone = /*#__PURE__*/ from({
sourceId: tempo.id,
rpcHost: 'tempo.xyz',
});
export const zoneModerato = /*#__PURE__*/ from({
sourceId: tempoModerato.id,
rpcHost: 'tempoxyz.dev',
});
/** Creates a zone chain factory for a given Tempo network. */
export function from(options) {
return (id) => {
const chainId = ZoneId.toChainId(id);
const paddedId = String(id).padStart(3, '0');
return defineChain({
...chainConfig,
id: chainId,
name: `Tempo Zone ${paddedId}`,
nativeCurrency: {
name: 'USD',
symbol: 'USD',
decimals: 6,
},
rpcUrls: {
default: {
http: [`https://rpc-zone-${paddedId}.${options.rpcHost}`],
},
},
sourceId: options.sourceId,
});
};
}
//# sourceMappingURL=zone.js.map

1
node_modules/viem/_esm/tempo/zones/zone.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"zone.js","sourceRoot":"","sources":["../../../tempo/zones/zone.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAA;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAA;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAA;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAE/C,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,CAAC,aAAa,CAAC,EAAE,CAAC,EAAE;QAClB,CAAC,EAAE,4CAA4C;QAC/C,CAAC,EAAE,4CAA4C;KAChD;CAC+D,CAAA;AAElE,MAAM,UAAU,gBAAgB,CAC9B,OAAe,EACf,MAAc;IAEd,MAAM,OAAO,GACX,eACD,CAAC,OAAO,CAAC,EAAE,CAAC,MAAM,CAAC,CAAA;IACpB,IAAI,CAAC,OAAO;QACV,MAAM,IAAI,KAAK,CACb,yCAAyC,MAAM,aAAa,OAAO,GAAG,CACvE,CAAA;IACH,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,MAAM,CAAC,MAAM,IAAI,GAAG,aAAa,CAAC,IAAI,CAAC;IACrC,QAAQ,EAAE,KAAK,CAAC,EAAE;IAClB,OAAO,EAAE,WAAW;CACrB,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAAC,IAAI,CAAC;IAC7C,QAAQ,EAAE,aAAa,CAAC,EAAE;IAC1B,OAAO,EAAE,cAAc;CACxB,CAAC,CAAA;AAEF,8DAA8D;AAC9D,MAAM,UAAU,IAAI,CAAC,OAAqB;IACxC,OAAO,CAAC,EAAU,EAAE,EAAE;QACp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