@wagmi/core
Version:
VanillaJS library for Ethereum
1,717 lines • 44.5 kB
JavaScript
import { Actions } from 'viem/tempo';
import { getConnectorClient } from '../../actions/getConnectorClient.js';
/**
* Approves a spender to transfer TIP20 tokens on behalf of the caller.
*
* @example
* ```ts
* import { createConfig, http } from '@wagmi/core'
* import { Actions } from '@wagmi/core/tempo'
* import { tempo } from '@wagmi/core/chains'
*
* const config = createConfig({
* chains: [tempo],
* transports: {
* [tempo.id]: http(),
* },
* })
*
* const hash = await Actions.token.approve(config, {
* spender: '0x...',
* amount: 100n,
* })
* ```
*
* @param config - Config.
* @param parameters - Parameters.
* @returns Transaction hash.
*/
export async function approve(config, parameters) {
const { account, chainId, connector } = parameters;
const client = await getConnectorClient(config, {
account,
assertChainId: false,
chainId,
connector,
});
return Actions.token.approve(client, parameters);
}
/**
* Approves a spender to transfer TIP20 tokens on behalf of the caller.
*
* Note: This is a synchronous action that waits for the transaction to
* be included on a block before returning a response.
*
* @example
* ```ts
* import { createConfig, http } from '@wagmi/core'
* import { tempo } from '@wagmi/core/chains'
* import { Actions } from '@wagmi/core/tempo'
*
* const config = createConfig({
* chains: [tempo],
* transports: {
* [tempo.id]: http(),
* },
* })
*
* const result = await Actions.token.approveSync(config, {
* spender: '0x...',
* amount: 100n,
* })
* ```
*
* @param config - Config.
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
export async function approveSync(config, parameters) {
const { account, chainId, connector } = parameters;
const client = await getConnectorClient(config, {
account,
assertChainId: false,
chainId,
connector,
});
return Actions.token.approveSync(client, parameters);
}
/**
* Burns TIP20 tokens from the caller's balance.
*
* @example
* ```ts
* import { createConfig, http } from '@wagmi/core'
* import { tempo } from '@wagmi/core/chains'
* import { Actions } from '@wagmi/core/tempo'
*
* const config = createConfig({
* chains: [tempo],
* transports: {
* [tempo.id]: http(),
* },
* })
*
* const hash = await Actions.token.burn(config, {
* amount: 100n,
* token: '0x...',
* })
* ```
*
* @param config - Config.
* @param parameters - Parameters.
* @returns Transaction hash.
*/
export async function burn(config, parameters) {
const { account, chainId, connector } = parameters;
const client = await getConnectorClient(config, {
account,
assertChainId: false,
chainId,
connector,
});
return Actions.token.burn(client, parameters);
}
/**
* Burns TIP20 tokens from a blocked address.
*
* @example
* ```ts
* import { createConfig, http } from '@wagmi/core'
* import { tempo } from '@wagmi/core/chains'
* import { Actions } from '@wagmi/core/tempo'
*
* const config = createConfig({
* chains: [tempo],
* transports: {
* [tempo.id]: http(),
* },
* })
*
* const hash = await Actions.token.burnBlocked(config, {
* from: '0x...',
* amount: 100n,
* token: '0x...',
* })
* ```
*
* @param config - Config.
* @param parameters - Parameters.
* @returns Transaction hash.
*/
export async function burnBlocked(config, parameters) {
const { account, chainId, connector } = parameters;
const client = await getConnectorClient(config, {
account,
assertChainId: false,
chainId,
connector,
});
return await Actions.token.burnBlocked(client, parameters);
}
/**
* Burns TIP20 tokens from a blocked address.
*
* Note: This is a synchronous action that waits for the transaction to
* be included on a block before returning a response.
*
* @example
* ```ts
* import { createConfig, http } from '@wagmi/core'
* import { tempo } from '@wagmi/core/chains'
* import { Actions } from '@wagmi/core/tempo'
*
* const config = createConfig({
* chains: [tempo],
* transports: {
* [tempo.id]: http(),
* },
* })
*
* const result = await Actions.token.burnBlockedSync(config, {
* from: '0x...',
* amount: 100n,
* token: '0x...',
* })
* ```
*
* @param config - Config.
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
export async function burnBlockedSync(config, parameters) {
const { account, chainId, connector } = parameters;
const client = await getConnectorClient(config, {
account,
assertChainId: false,
chainId,
connector,
});
return Actions.token.burnBlockedSync(client, parameters);
}
/**
* Burns TIP20 tokens from the caller's balance.
*
* Note: This is a synchronous action that waits for the transaction to
* be included on a block before returning a response.
*
* @example
* ```ts
* import { createConfig, http } from '@wagmi/core'
* import { tempo } from '@wagmi/core/chains'
* import { Actions } from '@wagmi/core/tempo'
*
* const config = createConfig({
* chains: [tempo],
* transports: {
* [tempo.id]: http(),
* },
* })
*
* const result = await Actions.token.burnSync(config, {
* amount: 100n,
* token: '0x...',
* })
* ```
*
* @param config - Config.
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
export async function burnSync(config, parameters) {
const { account, chainId, connector } = parameters;
const client = await getConnectorClient(config, {
account,
assertChainId: false,
chainId,
connector,
});
return Actions.token.burnSync(client, parameters);
}
/**
* Changes the transfer policy ID for a TIP20 token.
*
* @example
* ```ts
* import { createConfig, http } from '@wagmi/core'
* import { tempo } from '@wagmi/core/chains'
* import { Actions } from '@wagmi/core/tempo'
*
* const config = createConfig({
* chains: [tempo],
* transports: {
* [tempo.id]: http(),
* },
* })
*
* const hash = await Actions.token.changeTransferPolicy(config, {
* token: '0x...',
* policyId: 1n,
* })
* ```
*
* @param config - Config.
* @param parameters - Parameters.
* @returns Transaction hash.
*/
export async function changeTransferPolicy(config, parameters) {
const { account, chainId, connector } = parameters;
const client = await getConnectorClient(config, {
account,
assertChainId: false,
chainId,
connector,
});
return Actions.token.changeTransferPolicy(client, parameters);
}
/**
* Changes the transfer policy ID for a TIP20 token.
*
* Note: This is a synchronous action that waits for the transaction to
* be included on a block before returning a response.
*
* @example
* ```ts
* import { createConfig, http } from '@wagmi/core'
* import { tempo } from '@wagmi/core/chains'
* import { Actions } from '@wagmi/core/tempo'
*
* const config = createConfig({
* chains: [tempo],
* transports: {
* [tempo.id]: http(),
* },
* })
*
* const result = await Actions.token.changeTransferPolicySync(config, {
* token: '0x...',
* policyId: 1n,
* })
* ```
*
* @param config - Config.
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
export async function changeTransferPolicySync(config, parameters) {
const { account, chainId, connector } = parameters;
const client = await getConnectorClient(config, {
account,
assertChainId: false,
chainId,
connector,
});
return Actions.token.changeTransferPolicySync(client, parameters);
}
/**
* Creates a new TIP20 token.
*
* @example
* ```ts
* import { createConfig, http } from '@wagmi/core'
* import { tempo } from '@wagmi/core/chains'
* import { Actions } from '@wagmi/core/tempo'
*
* const config = createConfig({
* chains: [tempo],
* transports: {
* [tempo.id]: http(),
* },
* })
*
* const hash = await Actions.token.create(config, {
* name: 'My Token',
* symbol: 'MTK',
* currency: 'USD',
* })
* ```
*
* @param config - Config.
* @param parameters - Parameters.
* @returns Transaction hash.
*/
export async function create(config, parameters) {
const { account, chainId, connector } = parameters;
const client = await getConnectorClient(config, {
account,
assertChainId: false,
chainId,
connector,
});
return Actions.token.create(client, parameters);
}
/**
* Creates a new TIP20 token.
*
* Note: This is a synchronous action that waits for the transaction to
* be included on a block before returning a response.
*
* @example
* ```ts
* import { createConfig, http } from '@wagmi/core'
* import { tempo } from '@wagmi/core/chains'
* import { Actions } from '@wagmi/core/tempo'
*
* const config = createConfig({
* chains: [tempo],
* transports: {
* [tempo.id]: http(),
* },
* })
*
* const result = await Actions.token.createSync(config, {
* name: 'My Token',
* symbol: 'MTK',
* currency: 'USD',
* })
* ```
*
* @param config - Config.
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
export async function createSync(config, parameters) {
const { account, chainId, connector } = parameters;
const client = await getConnectorClient(config, {
account,
assertChainId: false,
chainId,
connector,
});
return Actions.token.createSync(client, parameters);
}
/**
* Updates the quote token for a TIP20 token.
*
* @example
* ```ts
* import { createConfig, http } from '@wagmi/core'
* import { tempo } from '@wagmi/core/chains'
* import { Actions } from '@wagmi/core/tempo'
*
* const config = createConfig({
* chains: [tempo],
* transports: {
* [tempo.id]: http(),
* },
* })
*
* const hash = await Actions.token.updateQuoteToken(config, {
* token: '0x...',
* })
* ```
*
* @param config - Config.
* @param parameters - Parameters.
* @returns Transaction hash.
*/
export async function updateQuoteToken(config, parameters) {
const { account, chainId, connector } = parameters;
const client = await getConnectorClient(config, {
account,
assertChainId: false,
chainId,
connector,
});
return Actions.token.updateQuoteToken(client, parameters);
}
/**
* Updates the quote token for a TIP20 token.
*
* Note: This is a synchronous action that waits for the transaction to
* be included on a block before returning a response.
*
* @example
* ```ts
* import { createConfig, http } from '@wagmi/core'
* import { tempo } from '@wagmi/core/chains'
* import { Actions } from '@wagmi/core/tempo'
*
* const config = createConfig({
* chains: [tempo],
* transports: {
* [tempo.id]: http(),
* },
* })
*
* const result = await Actions.token.updateQuoteTokenSync(config, {
* token: '0x...',
* })
* ```
*
* @param config - Config.
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
export async function updateQuoteTokenSync(config, parameters) {
const { account, chainId, connector } = parameters;
const client = await getConnectorClient(config, {
account,
assertChainId: false,
chainId,
connector,
});
return Actions.token.updateQuoteTokenSync(client, parameters);
}
/**
* Gets TIP20 token allowance.
*
* @example
* ```ts
* import { createConfig, http } from '@wagmi/core'
* import { tempo } from '@wagmi/core/chains'
* import { Actions } from '@wagmi/core/tempo'
*
* const config = createConfig({
* chains: [tempo],
* transports: {
* [tempo.id]: http(),
* },
* })
*
* const allowance = await Actions.token.getAllowance(config, {
* account: '0x...',
* spender: '0x...',
* })
* ```
*
* @param config - Config.
* @param parameters - Parameters.
* @returns The token allowance.
*/
export function getAllowance(config, parameters) {
const { chainId, ...rest } = parameters;
const client = config.getClient({ chainId });
return Actions.token.getAllowance(client, rest);
}
(function (getAllowance) {
function queryKey(parameters) {
return ['getAllowance', parameters];
}
getAllowance.queryKey = queryKey;
function queryOptions(config, parameters) {
const { query, ...rest } = parameters;
return {
...query,
enabled: Boolean(rest.account && rest.spender && rest.token && (query?.enabled ?? true)),
queryKey: queryKey(rest),
async queryFn(context) {
const [, parameters] = context.queryKey;
return await getAllowance(config, parameters);
},
};
}
getAllowance.queryOptions = queryOptions;
})(getAllowance || (getAllowance = {}));
/**
* Gets TIP20 token balance for an address.
*
* @example
* ```ts
* import { createConfig, http } from '@wagmi/core'
* import { tempo } from '@wagmi/core/chains'
* import { Actions } from '@wagmi/core/tempo'
*
* const config = createConfig({
* chains: [tempo],
* transports: {
* [tempo.id]: http(),
* },
* })
*
* const balance = await Actions.token.getBalance(config, {
* account: '0x...',
* })
* ```
*
* @param config - Config.
* @param parameters - Parameters.
* @returns The token balance.
*/
export function getBalance(config, parameters) {
const { chainId, ...rest } = parameters;
const client = config.getClient({ chainId });
return Actions.token.getBalance(client, rest);
}
(function (getBalance) {
function queryKey(parameters) {
return ['getBalance', parameters];
}
getBalance.queryKey = queryKey;
function queryOptions(config, parameters) {
const { query, ...rest } = parameters;
return {
...query,
enabled: Boolean(rest.account && rest.token && (query?.enabled ?? true)),
queryKey: queryKey(rest),
async queryFn(context) {
const [, parameters] = context.queryKey;
return (await getBalance(config, parameters)) ?? null;
},
};
}
getBalance.queryOptions = queryOptions;
})(getBalance || (getBalance = {}));
/**
* Gets TIP20 token metadata.
*
* @example
* ```ts
* import { createConfig, http } from '@wagmi/core'
* import { tempo } from '@wagmi/core/chains'
* import { Actions } from '@wagmi/core/tempo'
*
* const config = createConfig({
* chains: [tempo],
* transports: {
* [tempo.id]: http(),
* },
* })
*
* const metadata = await Actions.token.getMetadata(config, {
* token: '0x...',
* })
* ```
*
* @param config - Config.
* @param parameters - Parameters.
* @returns The token metadata.
*/
export function getMetadata(config, parameters) {
const { chainId, ...rest } = parameters;
const client = config.getClient({ chainId });
return Actions.token.getMetadata(client, rest);
}
(function (getMetadata) {
function queryKey(parameters) {
return ['getMetadata', parameters];
}
getMetadata.queryKey = queryKey;
function queryOptions(config, parameters) {
const { query, ...rest } = parameters;
return {
...query,
enabled: Boolean(rest.token && (query?.enabled ?? true)),
queryKey: queryKey(rest),
async queryFn(context) {
const [, parameters] = context.queryKey;
return await getMetadata(config, parameters);
},
};
}
getMetadata.queryOptions = queryOptions;
})(getMetadata || (getMetadata = {}));
/**
* Gets the admin role for a specific role in a TIP20 token.
*
* @example
* ```ts
* import { createConfig, http } from '@wagmi/core'
* import { tempo } from '@wagmi/core/chains'
* import { Actions } from '@wagmi/core/tempo'
*
* const config = createConfig({
* chains: [tempo],
* transports: {
* [tempo.id]: http(),
* },
* })
*
* const adminRole = await Actions.token.getRoleAdmin(config, {
* role: 'issuer',
* token: '0x...',
* })
* ```
*
* @param config - Config.
* @param parameters - Parameters.
* @returns The admin role hash.
*/
export function getRoleAdmin(config, parameters) {
const { chainId, ...rest } = parameters;
const client = config.getClient({ chainId });
return Actions.token.getRoleAdmin(client, rest);
}
(function (getRoleAdmin) {
function queryKey(parameters) {
return ['getRoleAdmin', parameters];
}
getRoleAdmin.queryKey = queryKey;
function queryOptions(config, parameters) {
const { query, ...rest } = parameters;
return {
...query,
enabled: Boolean(rest.token && rest.role && (query?.enabled ?? true)),
queryKey: queryKey(rest),
async queryFn(context) {
const [, parameters] = context.queryKey;
return await getRoleAdmin(config, parameters);
},
};
}
getRoleAdmin.queryOptions = queryOptions;
})(getRoleAdmin || (getRoleAdmin = {}));
/**
* Grants a role for a TIP20 token.
*
* @example
* ```ts
* import { createConfig, http } from '@wagmi/core'
* import { tempo } from '@wagmi/core/chains'
* import { Actions } from '@wagmi/core/tempo'
*
* const config = createConfig({
* chains: [tempo],
* transports: {
* [tempo.id]: http(),
* },
* })
*
* const hash = await Actions.token.grantRoles(config, {
* token: '0x...',
* to: '0x...',
* roles: ['issuer'],
* })
* ```
*
* @param config - Config.
* @param parameters - Parameters.
* @returns Transaction hash.
*/
export async function grantRoles(config, parameters) {
const { account, chainId, connector } = parameters;
const client = await getConnectorClient(config, {
account,
assertChainId: false,
chainId,
connector,
});
return Actions.token.grantRoles(client, parameters);
}
/**
* Grants a role for a TIP20 token.
*
* Note: This is a synchronous action that waits for the transaction to
* be included on a block before returning a response.
*
* @example
* ```ts
* import { createConfig, http } from '@wagmi/core'
* import { tempo } from '@wagmi/core/chains'
* import { Actions } from '@wagmi/core/tempo'
*
* const config = createConfig({
* chains: [tempo],
* transports: {
* [tempo.id]: http(),
* },
* })
*
* const result = await Actions.token.grantRolesSync(config, {
* token: '0x...',
* to: '0x...',
* roles: ['issuer'],
* })
* ```
*
* @param config - Config.
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
export async function grantRolesSync(config, parameters) {
const { account, chainId, connector } = parameters;
const client = await getConnectorClient(config, {
account,
assertChainId: false,
chainId,
connector,
});
return Actions.token.grantRolesSync(client, parameters);
}
/**
* Checks if an account has a specific role for a TIP20 token.
*
* @example
* ```ts
* import { createConfig, http } from '@wagmi/core'
* import { tempo } from '@wagmi/core/chains'
* import { Actions } from '@wagmi/core/tempo'
*
* const config = createConfig({
* chains: [tempo],
* transports: {
* [tempo.id]: http(),
* },
* })
*
* const hasRole = await Actions.token.hasRole(config, {
* account: '0x...',
* role: 'issuer',
* token: '0x...',
* })
* ```
*
* @param config - Config.
* @param parameters - Parameters.
* @returns Whether the account has the role.
*/
export function hasRole(config, parameters) {
const { chainId, ...rest } = parameters;
const client = config.getClient({ chainId });
return Actions.token.hasRole(client, rest);
}
(function (hasRole) {
function queryKey(parameters) {
return ['hasRole', parameters];
}
hasRole.queryKey = queryKey;
function queryOptions(config, parameters) {
const { query, ...rest } = parameters;
return {
...query,
enabled: Boolean(rest.token && rest.role && rest.account && (query?.enabled ?? true)),
queryKey: queryKey(rest),
async queryFn(context) {
const [, parameters] = context.queryKey;
return await hasRole(config, parameters);
},
};
}
hasRole.queryOptions = queryOptions;
})(hasRole || (hasRole = {}));
/**
* Mints TIP20 tokens to an address.
*
* @example
* ```ts
* import { createConfig, http } from '@wagmi/core'
* import { tempo } from '@wagmi/core/chains'
* import { Actions } from '@wagmi/core/tempo'
*
* const config = createConfig({
* chains: [tempo],
* transports: {
* [tempo.id]: http(),
* },
* })
*
* const hash = await Actions.token.mint(config, {
* to: '0x...',
* amount: 100n,
* token: '0x...',
* })
* ```
*
* @param config - Config.
* @param parameters - Parameters.
* @returns Transaction hash.
*/
export async function mint(config, parameters) {
const { account, chainId, connector } = parameters;
const client = await getConnectorClient(config, {
account,
assertChainId: false,
chainId,
connector,
});
return Actions.token.mint(client, parameters);
}
/**
* Mints TIP20 tokens to an address.
*
* Note: This is a synchronous action that waits for the transaction to
* be included on a block before returning a response.
*
* @example
* ```ts
* import { createConfig, http } from '@wagmi/core'
* import { tempo } from '@wagmi/core/chains'
* import { Actions } from '@wagmi/core/tempo'
*
* const config = createConfig({
* chains: [tempo],
* transports: {
* [tempo.id]: http(),
* },
* })
*
* const result = await Actions.token.mintSync(config, {
* to: '0x...',
* amount: 100n,
* token: '0x...',
* })
* ```
*
* @param config - Config.
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
export async function mintSync(config, parameters) {
const { account, chainId, connector } = parameters;
const client = await getConnectorClient(config, {
account,
assertChainId: false,
chainId,
connector,
});
return Actions.token.mintSync(client, parameters);
}
/**
* Pauses a TIP20 token.
*
* @example
* ```ts
* import { createConfig, http } from '@wagmi/core'
* import { tempo } from '@wagmi/core/chains'
* import { Actions } from '@wagmi/core/tempo'
*
* const config = createConfig({
* chains: [tempo],
* transports: {
* [tempo.id]: http(),
* },
* })
*
* const hash = await Actions.token.pause(config, {
* token: '0x...',
* })
* ```
*
* @param config - Config.
* @param parameters - Parameters.
* @returns Transaction hash.
*/
export async function pause(config, parameters) {
const { account, chainId, connector } = parameters;
const client = await getConnectorClient(config, {
account,
assertChainId: false,
chainId,
connector,
});
return Actions.token.pause(client, parameters);
}
/**
* Pauses a TIP20 token.
*
* Note: This is a synchronous action that waits for the transaction to
* be included on a block before returning a response.
*
* @example
* ```ts
* import { createConfig, http } from '@wagmi/core'
* import { tempo } from '@wagmi/core/chains'
* import { Actions } from '@wagmi/core/tempo'
*
* const config = createConfig({
* chains: [tempo],
* transports: {
* [tempo.id]: http(),
* },
* })
*
* const result = await Actions.token.pauseSync(config, {
* token: '0x...',
* })
* ```
*
* @param config - Config.
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
export async function pauseSync(config, parameters) {
const { account, chainId, connector } = parameters;
const client = await getConnectorClient(config, {
account,
assertChainId: false,
chainId,
connector,
});
return Actions.token.pauseSync(client, parameters);
}
/**
* Renounces a role for a TIP20 token.
*
* @example
* ```ts
* import { createConfig, http } from '@wagmi/core'
* import { tempo } from '@wagmi/core/chains'
* import { Actions } from '@wagmi/core/tempo'
*
* const config = createConfig({
* chains: [tempo],
* transports: {
* [tempo.id]: http(),
* },
* })
*
* const hash = await Actions.token.renounceRoles(config, {
* token: '0x...',
* roles: ['issuer'],
* })
* ```
*
* @param config - Config.
* @param parameters - Parameters.
* @returns Transaction hash.
*/
export async function renounceRoles(config, parameters) {
const { account, chainId, connector } = parameters;
const client = await getConnectorClient(config, {
account,
assertChainId: false,
chainId,
connector,
});
return Actions.token.renounceRoles(client, parameters);
}
/**
* Renounces a role for a TIP20 token.
*
* Note: This is a synchronous action that waits for the transaction to
* be included on a block before returning a response.
*
* @example
* ```ts
* import { createConfig, http } from '@wagmi/core'
* import { tempo } from '@wagmi/core/chains'
* import { Actions } from '@wagmi/core/tempo'
*
* const config = createConfig({
* chains: [tempo],
* transports: {
* [tempo.id]: http(),
* },
* })
*
* const result = await Actions.token.renounceRolesSync(config, {
* token: '0x...',
* roles: ['issuer'],
* })
* ```
*
* @param config - Config.
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
export async function renounceRolesSync(config, parameters) {
const { account, chainId, connector } = parameters;
const client = await getConnectorClient(config, {
account,
assertChainId: false,
chainId,
connector,
});
return Actions.token.renounceRolesSync(client, parameters);
}
/**
* Revokes a role for a TIP20 token.
*
* @example
* ```ts
* import { createConfig, http } from '@wagmi/core'
* import { tempo } from '@wagmi/core/chains'
* import { Actions } from '@wagmi/core/tempo'
*
* const config = createConfig({
* chains: [tempo],
* transports: {
* [tempo.id]: http(),
* },
* })
*
* const hash = await Actions.token.revokeRoles(config, {
* token: '0x...',
* from: '0x...',
* roles: ['issuer'],
* })
* ```
*
* @param config - Config.
* @param parameters - Parameters.
* @returns Transaction hash.
*/
export async function revokeRoles(config, parameters) {
const { account, chainId, connector } = parameters;
const client = await getConnectorClient(config, {
account,
assertChainId: false,
chainId,
connector,
});
return Actions.token.revokeRoles(client, parameters);
}
/**
* Revokes a role for a TIP20 token.
*
* Note: This is a synchronous action that waits for the transaction to
* be included on a block before returning a response.
*
* @example
* ```ts
* import { createConfig, http } from '@wagmi/core'
* import { tempo } from '@wagmi/core/chains'
* import { Actions } from '@wagmi/core/tempo'
*
* const config = createConfig({
* chains: [tempo],
* transports: {
* [tempo.id]: http(),
* },
* })
*
* const result = await Actions.token.revokeRolesSync(config, {
* token: '0x...',
* from: '0x...',
* roles: ['issuer'],
* })
* ```
*
* @param config - Config.
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
export async function revokeRolesSync(config, parameters) {
const { account, chainId, connector } = parameters;
const client = await getConnectorClient(config, {
account,
assertChainId: false,
chainId,
connector,
});
return Actions.token.revokeRolesSync(client, parameters);
}
/**
* Sets the admin role for a specific role in a TIP20 token.
*
* @example
* ```ts
* import { createConfig, http } from '@wagmi/core'
* import { tempo } from '@wagmi/core/chains'
* import { Actions } from '@wagmi/core/tempo'
*
* const config = createConfig({
* chains: [tempo],
* transports: {
* [tempo.id]: http(),
* },
* })
*
* const hash = await Actions.token.setRoleAdmin(config, {
* token: '0x...',
* role: 'issuer',
* adminRole: 'pause',
* })
* ```
*
* @param config - Config.
* @param parameters - Parameters.
* @returns Transaction hash.
*/
export async function setRoleAdmin(config, parameters) {
const { account, chainId, connector } = parameters;
const client = await getConnectorClient(config, {
account,
assertChainId: false,
chainId,
connector,
});
return Actions.token.setRoleAdmin(client, parameters);
}
/**
* Sets the admin role for a specific role in a TIP20 token.
*
* Note: This is a synchronous action that waits for the transaction to
* be included on a block before returning a response.
*
* @example
* ```ts
* import { createConfig, http } from '@wagmi/core'
* import { tempo } from '@wagmi/core/chains'
* import { Actions } from '@wagmi/core/tempo'
*
* const config = createConfig({
* chains: [tempo],
* transports: {
* [tempo.id]: http(),
* },
* })
*
* const result = await Actions.token.setRoleAdminSync(config, {
* token: '0x...',
* role: 'issuer',
* adminRole: 'pause',
* })
* ```
*
* @param config - Config.
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
export async function setRoleAdminSync(config, parameters) {
const { account, chainId, connector } = parameters;
const client = await getConnectorClient(config, {
account,
assertChainId: false,
chainId,
connector,
});
return Actions.token.setRoleAdminSync(client, parameters);
}
/**
* Sets the supply cap for a TIP20 token.
*
* @example
* ```ts
* import { createConfig, http } from '@wagmi/core'
* import { tempo } from '@wagmi/core/chains'
* import { Actions } from '@wagmi/core/tempo'
*
* const config = createConfig({
* chains: [tempo],
* transports: {
* [tempo.id]: http(),
* },
* })
*
* const hash = await Actions.token.setSupplyCap(config, {
* token: '0x...',
* supplyCap: 1000000n,
* })
* ```
*
* @param config - Config.
* @param parameters - Parameters.
* @returns Transaction hash.
*/
export async function setSupplyCap(config, parameters) {
const { account, chainId, connector } = parameters;
const client = await getConnectorClient(config, {
account,
assertChainId: false,
chainId,
connector,
});
return Actions.token.setSupplyCap(client, parameters);
}
/**
* Sets the supply cap for a TIP20 token.
*
* Note: This is a synchronous action that waits for the transaction to
* be included on a block before returning a response.
*
* @example
* ```ts
* import { createConfig, http } from '@wagmi/core'
* import { tempo } from '@wagmi/core/chains'
* import { Actions } from '@wagmi/core/tempo'
*
* const config = createConfig({
* chains: [tempo],
* transports: {
* [tempo.id]: http(),
* },
* })
*
* const result = await Actions.token.setSupplyCapSync(config, {
* token: '0x...',
* supplyCap: 1000000n,
* })
* ```
*
* @param config - Config.
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
export async function setSupplyCapSync(config, parameters) {
const { account, chainId, connector } = parameters;
const client = await getConnectorClient(config, {
account,
assertChainId: false,
chainId,
connector,
});
return Actions.token.setSupplyCapSync(client, parameters);
}
/**
* Transfers TIP20 tokens to another address.
*
* @example
* ```ts
* import { createConfig, http } from '@wagmi/core'
* import { tempo } from '@wagmi/core/chains'
* import { Actions } from '@wagmi/core/tempo'
*
* const config = createConfig({
* chains: [tempo],
* transports: {
* [tempo.id]: http(),
* },
* })
*
* const hash = await Actions.token.transfer(config, {
* to: '0x...',
* amount: 100n,
* })
* ```
*
* @param config - Config.
* @param parameters - Parameters.
* @returns Transaction hash.
*/
export async function transfer(config, parameters) {
const { account, chainId, connector } = parameters;
const client = await getConnectorClient(config, {
account,
assertChainId: false,
chainId,
connector,
});
return Actions.token.transfer(client, parameters);
}
/**
* Transfers TIP20 tokens to another address.
*
* Note: This is a synchronous action that waits for the transaction to
* be included on a block before returning a response.
*
* @example
* ```ts
* import { createConfig, http } from '@wagmi/core'
* import { tempo } from '@wagmi/core/chains'
* import { Actions } from '@wagmi/core/tempo'
*
* const config = createConfig({
* chains: [tempo],
* transports: {
* [tempo.id]: http(),
* },
* })
*
* const result = await Actions.token.transferSync(config, {
* to: '0x...',
* amount: 100n,
* })
* ```
*
* @param config - Config.
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
export async function transferSync(config, parameters) {
const { account, chainId, connector } = parameters;
const client = await getConnectorClient(config, {
account,
assertChainId: false,
chainId,
connector,
});
return Actions.token.transferSync(client, parameters);
}
/**
* Unpauses a TIP20 token.
*
* @example
* ```ts
* import { createConfig, http } from '@wagmi/core'
* import { tempo } from '@wagmi/core/chains'
* import { Actions } from '@wagmi/core/tempo'
*
* const config = createConfig({
* chains: [tempo],
* transports: {
* [tempo.id]: http(),
* },
* })
*
* const hash = await Actions.token.unpause(config, {
* token: '0x...',
* })
* ```
*
* @param config - Config.
* @param parameters - Parameters.
* @returns Transaction hash.
*/
export async function unpause(config, parameters) {
const { account, chainId, connector } = parameters;
const client = await getConnectorClient(config, {
account,
assertChainId: false,
chainId,
connector,
});
return Actions.token.unpause(client, parameters);
}
/**
* Unpauses a TIP20 token.
*
* Note: This is a synchronous action that waits for the transaction to
* be included on a block before returning a response.
*
* @example
* ```ts
* import { createConfig, http } from '@wagmi/core'
* import { tempo } from '@wagmi/core/chains'
* import { Actions } from '@wagmi/core/tempo'
*
* const config = createConfig({
* chains: [tempo],
* transports: {
* [tempo.id]: http(),
* },
* })
*
* const result = await Actions.token.unpauseSync(config, {
* token: '0x...',
* })
* ```
*
* @param config - Config.
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
export async function unpauseSync(config, parameters) {
const { account, chainId, connector } = parameters;
const client = await getConnectorClient(config, {
account,
assertChainId: false,
chainId,
connector,
});
return Actions.token.unpauseSync(client, parameters);
}
/**
* Prepares the quote token update for a TIP20 token.
*
* @example
* ```ts
* import { createConfig, http } from '@wagmi/core'
* import { tempo } from '@wagmi/core/chains'
* import { Actions } from '@wagmi/core/tempo'
*
* const config = createConfig({
* chains: [tempo],
* transports: {
* [tempo.id]: http(),
* },
* })
*
* const hash = await Actions.token.prepareUpdateQuoteToken(config, {
* token: '0x...',
* quoteToken: '0x...',
* })
* ```
*
* @param config - Config.
* @param parameters - Parameters.
* @returns Transaction hash.
*/
export async function prepareUpdateQuoteToken(config, parameters) {
const { account, chainId, connector } = parameters;
const client = await getConnectorClient(config, {
account,
assertChainId: false,
chainId,
connector,
});
return Actions.token.prepareUpdateQuoteToken(client, parameters);
}
/**
* Prepares the quote token update for a TIP20 token.
*
* Note: This is a synchronous action that waits for the transaction to
* be included on a block before returning a response.
*
* @example
* ```ts
* import { createConfig, http } from '@wagmi/core'
* import { tempo } from '@wagmi/core/chains'
* import { Actions } from '@wagmi/core/tempo'
*
* const config = createConfig({
* chains: [tempo],
* transports: {
* [tempo.id]: http(),
* },
* })
*
* const result = await Actions.token.prepareUpdateQuoteTokenSync(config, {
* token: '0x...',
* quoteToken: '0x...',
* })
* ```
*
* @param config - Config.
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
export async function prepareUpdateQuoteTokenSync(config, parameters) {
const { account, chainId, connector } = parameters;
const client = await getConnectorClient(config, {
account,
assertChainId: false,
chainId,
connector,
});
return Actions.token.prepareUpdateQuoteTokenSync(client, parameters);
}
/**
* Watches for TIP20 token role admin updates.
*
* @example
* ```ts
* import { createConfig, http } from '@wagmi/core'
* import { tempo } from '@wagmi/core/chains'
* import { Actions } from '@wagmi/core/tempo'
*
* const config = createConfig({
* chains: [tempo],
* transports: {
* [tempo.id]: http(),
* },
* })
*
* const unwatch = Actions.token.watchAdminRole(config, {
* onRoleAdminUpdated: (args, log) => {
* console.log('Role admin updated:', args)
* },
* })
* ```
*
* @param config - Config.
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
export function watchAdminRole(config, parameters) {
const { chainId, ...rest } = parameters;
const client = config.getClient({ chainId });
return Actions.token.watchAdminRole(client, rest);
}
/**
* Watches for TIP20 token approval events.
*
* @example
* ```ts
* import { createConfig, http } from '@wagmi/core'
* import { tempo } from '@wagmi/core/chains'
* import { Actions } from '@wagmi/core/tempo'
*
* const config = createConfig({
* chains: [tempo],
* transports: {
* [tempo.id]: http(),
* },
* })
*
* const unwatch = Actions.token.watchApprove(config, {
* onApproval: (args, log) => {
* console.log('Approval:', args)
* },
* })
* ```
*
* @param config - Config.
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
export function watchApprove(config, parameters) {
const { chainId, ...rest } = parameters;
const client = config.getClient({ chainId });
return Actions.token.watchApprove(client, rest);
}
/**
* Watches for TIP20 token burn events.
*
* @example
* ```ts
* import { createConfig, http } from '@wagmi/core'
* import { tempo } from '@wagmi/core/chains'
* import { Actions } from '@wagmi/core/tempo'
*
* const config = createConfig({
* chains: [tempo],
* transports: {
* [tempo.id]: http(),
* },
* })
*
* const unwatch = Actions.token.watchBurn(config, {
* onBurn: (args, log) => {
* console.log('Burn:', args)
* },
* })
* ```
*
* @param config - Config.
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
export function watchBurn(config, parameters) {
const { chainId, ...rest } = parameters;
const client = config.getClient({ chainId });
return Actions.token.watchBurn(client, rest);
}
/**
* Watches for new TIP20 tokens created.
*
* @example
* ```ts
* import { createConfig, http } from '@wagmi/core'
* import { tempo } from '@wagmi/core/chains'
* import { Actions } from '@wagmi/core/tempo'
*
* const config = createConfig({
* chains: [tempo],
* transports: {
* [tempo.id]: http(),
* },
* })
*
* const unwatch = Actions.token.watchCreate(config, {
* onTokenCreated: (args, log) => {
* console.log('Token created:', args)
* },
* })
* ```
*
* @param config - Config.
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
export function watchCreate(config, parameters) {
const { chainId, ...rest } = parameters;
const client = config.getClient({ chainId });
return Actions.token.watchCreate(client, rest);
}
/**
* Watches for TIP20 token mint events.
*
* @example
* ```ts
* import { createConfig, http } from '@wagmi/core'
* import { tempo } from '@wagmi/core/chains'
* import { Actions } from '@wagmi/core/tempo'
*
* const config = createConfig({
* chains: [tempo],
* transports: {
* [tempo.id]: http(),
* },
* })
*
* const unwatch = Actions.token.watchMint(config, {
* onMint: (args, log) => {
* console.log('Mint:', args)
* },
* })
* ```
*
* @param config - Config.
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
export function watchMint(config, parameters) {
const { chainId, ...rest } = parameters;
const client = config.getClient({ chainId });
return Actions.token.watchMint(client, rest);
}
/**
* Watches for TIP20 token role membership updates.
*
* @example
* ```ts
* import { createConfig, http } from '@wagmi/core'
* import { tempo } from '@wagmi/core/chains'
* import { Actions } from '@wagmi/core/tempo'
*
* const config = createConfig({
* chains: [tempo],
* transports: {
* [tempo.id]: http(),
* },
* })
*
* const unwatch = Actions.token.watchRole(config, {
* onRoleUpdated: (args, log) => {
* console.log('Role updated:', args)
* },
* })
* ```
*
* @param config - Config.
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
export function watchRole(config, parameters) {
const { chainId, ...rest } = parameters;
const client = config.getClient({ chainId });
return Actions.token.watchRole(client, rest);
}
/**
* Watches for TIP20 token transfer events.
*
* @example
* ```ts
* import { createConfig, http } from '@wagmi/core'
* import { tempo } from '@wagmi/core/chains'
* import { Actions } from '@wagmi/core/tempo'
*
* const config = createConfig({
* chains: [tempo],
* transports: {
* [tempo.id]: http(),
* },
* })
*
* const unwatch = Actions.token.watchTransfer(config, {
* onTransfer: (args, log) => {
* console.log('Transfer:', args)
* },
* })
* ```
*
* @param config - Config.
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
export function watchTransfer(config, parameters) {
const { chainId, ...rest } = parameters;
const client = config.getClient({ chainId });
return Actions.token.watchTransfer(client, rest);
}
/**
* Watches for TIP20 token quote token update events.
*
* @example
* ```ts
* import { createConfig, http } from '@wagmi/core'
* import { tempo } from '@wagmi/core/chains'
* import { Actions } from '@wagmi/core/tempo'
*
* const config = createConfig({
* chains: [tempo],
* transports: {
* [tempo.id]: http(),
* },
* })
*
* const unwatch = Actions.token.watchUpdateQuoteToken(config, {
* onUpdateQuoteToken: (args, log) => {
* if (args.completed)
* console.log('quote token update completed:', args.newQuoteToken)
* else
* console.log('quote token update proposed:', args.newQuoteToken)
* },
* })
* ```
*
* @param config - Config.
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
export function watchUpdateQuoteToken(config, parameters) {
const { chainId, ...rest } = parameters;
const client = config.getClient({ chainId });
return Actions.token.watchUpdateQuoteToken(client, rest);
}
//# sourceMappingURL=token.js.map