@tokenbound/sdk
Advanced tools
Comparing version 0.3.12 to 0.4.0
export * from './tokenboundAddresses'; | ||
export * from './interfaces'; | ||
export * from './eip1167Implementation'; | ||
export * from './multicall'; |
@@ -1,2 +0,9 @@ | ||
export declare const erc6551RegistryAddressV1: `0x${string}`; | ||
export declare const erc6551AccountImplementationAddressV1: `0x${string}`; | ||
import { ContractABIPair } from '../types'; | ||
type Standard6551Deployment = { | ||
IMPLEMENTATION: ContractABIPair; | ||
REGISTRY: ContractABIPair; | ||
ACCOUNT_PROXY?: ContractABIPair; | ||
}; | ||
export declare const ERC_6551_LEGACY_V2: Standard6551Deployment; | ||
export declare const ERC_6551_DEFAULT: Standard6551Deployment; | ||
export {}; |
@@ -1,1 +0,2 @@ | ||
export * from './viem'; | ||
export * from './viemV2'; | ||
export * from './viemV3'; |
@@ -1,6 +0,6 @@ | ||
import { erc6551AccountAbi, erc6551RegistryAbi } from '../abis'; | ||
import { erc6551AccountAbiV2, erc6551RegistryAbiV2 } from '../abis'; | ||
import { getAccount, computeAccount, createAccount, getCreationCode, prepareExecuteCall, executeCall, prepareCreateAccount } from './functions'; | ||
import { TokenboundAccountNFT, TokenboundClientOptions, GetAccountParams, TBAccountParams, PrepareCreateAccountParams, CreateAccountParams, PrepareExecuteCallParams, ExecuteCallParams, SignMessageParams, ComputeAccountParams, GetCreationCodeParams, ERC20TransferParams, ETHTransferParams, NFTTransferParams, BytecodeParams } from './types'; | ||
import { TokenboundClient } from './TokenboundClient'; | ||
export { TokenboundClient, erc6551AccountAbi, erc6551RegistryAbi, getAccount, computeAccount, prepareCreateAccount, createAccount, getCreationCode, prepareExecuteCall, executeCall, }; | ||
export type { TokenboundClientOptions, TokenboundAccountNFT, GetAccountParams, TBAccountParams, PrepareCreateAccountParams, CreateAccountParams, PrepareExecuteCallParams, ExecuteCallParams, ComputeAccountParams, GetCreationCodeParams, BytecodeParams, SignMessageParams, ERC20TransferParams, ETHTransferParams, NFTTransferParams, }; | ||
import { TokenboundAccountNFT, TokenboundClientOptions, GetAccountParams, TBAccountParams, PrepareCreateAccountParams, CreateAccountParams, PrepareExecuteCallParams, ExecuteCallParams, SignMessageParams, ComputeAccountParams, GetCreationCodeParams, ERC20TransferParams, ETHTransferParams, NFTTransferParams, BytecodeParams, TBImplementationVersion, TBVersion } from './types'; | ||
import { TokenboundClient, erc6551AccountAbiV3, erc6551AccountProxyAbiV3, erc6551RegistryAbiV3 } from './TokenboundClient'; | ||
export { TokenboundClient, TBVersion, erc6551AccountAbiV2, erc6551RegistryAbiV2, erc6551AccountAbiV3, erc6551AccountProxyAbiV3, erc6551RegistryAbiV3, getAccount, computeAccount, prepareCreateAccount, createAccount, getCreationCode, prepareExecuteCall, executeCall, }; | ||
export type { TokenboundClientOptions, TokenboundAccountNFT, GetAccountParams, TBAccountParams, PrepareCreateAccountParams, CreateAccountParams, PrepareExecuteCallParams, ExecuteCallParams, ComputeAccountParams, GetCreationCodeParams, BytecodeParams, SignMessageParams, ERC20TransferParams, ETHTransferParams, NFTTransferParams, TBImplementationVersion, }; |
import { PublicClient } from 'viem'; | ||
import { erc6551AccountAbi, erc6551RegistryAbi } from '../abis'; | ||
import { getAccount, computeAccount, createAccount, getCreationCode, prepareExecuteCall, executeCall } from './functions'; | ||
import { BytecodeParams, CreateAccountParams, ERC20TransferParams, SignMessageParams, ETHTransferParams, ExecuteCallParams, GetAccountParams, NFTTransferParams, PrepareCreateAccountParams, PrepareExecuteCallParams, SegmentedERC6551Bytecode, TokenboundAccountNFT, TokenboundClientOptions } from './types'; | ||
import { BytecodeParams, CreateAccountParams, ERC20TransferParams, SignMessageParams, ETHTransferParams, ExecuteCallParams, GetAccountParams, NFTTransferParams, PrepareCreateAccountParams, PrepareExecuteCallParams, SegmentedERC6551Bytecode, TokenboundAccountNFT, TokenboundClientOptions, ExecuteParams, PrepareExecutionParams, ValidSignerParams } from './types'; | ||
declare global { | ||
@@ -14,2 +13,3 @@ interface Window { | ||
publicClient: PublicClient; | ||
private supportsV3; | ||
private signer?; | ||
@@ -24,4 +24,2 @@ private walletClient?; | ||
* @param {string} params.tokenId The token ID. | ||
* @param {`0x${string}`} [params.implementationAddress] The address of the implementation contract. | ||
* @param {`0x${string}`} [params.registryAddress] The address of the registry contract. | ||
* @returns The tokenbound account address. | ||
@@ -34,4 +32,2 @@ */ | ||
* @param {string} params.tokenId The token ID. | ||
* @param {`0x${string}`} [params.implementationAddress] The address of the implementation contract. | ||
* @param {`0x${string}`} [params.registryAddress] The address of the registry contract. | ||
* @returns The prepared transaction to create a tokenbound account. Can be sent via `sendTransaction` on an Ethers signer or viem WalletClient. | ||
@@ -50,5 +46,8 @@ */ | ||
* @param {`0x${string}`} [params.registryAddress] The address of the registry contract. | ||
* @returns a Promise that resolves to the account address of the created token bound account. | ||
* @returns a Promise that resolves to the account address of the created tokenbound account. | ||
*/ | ||
createAccount(params: CreateAccountParams): Promise<`0x${string}`>; | ||
createAccount(params: CreateAccountParams): Promise<{ | ||
account: `0x${string}`; | ||
txHash: `0x${string}`; | ||
}>; | ||
/** | ||
@@ -61,2 +60,3 @@ * Returns prepared transaction to execute a call on a tokenbound account | ||
* @returns a Promise with prepared transaction to execute a call on a tokenbound account. Can be sent via `sendTransaction` on a viem WalletClient or Ethers signer. | ||
* @deprecated this method is deprecated, but still available for use with legacy V2 deployments. Use prepareExecute() instead. | ||
*/ | ||
@@ -75,5 +75,34 @@ prepareExecuteCall(params: PrepareExecuteCallParams): Promise<{ | ||
* @returns a Promise that resolves to the transaction hash of the executed call | ||
* @deprecated this method is deprecated, but still available for use with legacy V2 deployments. Use execute() instead. | ||
*/ | ||
executeCall(params: ExecuteCallParams): Promise<`0x${string}`>; | ||
/** | ||
* Returns prepared transaction to execute on a tokenbound account | ||
* @param {string} params.account The tokenbound account address | ||
* @param {string} params.to The recipient address | ||
* @param {bigint} params.value The value to send, in wei | ||
* @param {string} params.data The encoded operation calldata to send | ||
* @returns a Promise with prepared transaction to execute on a tokenbound account. Can be sent via `sendTransaction` on a viem WalletClient or Ethers signer. | ||
*/ | ||
prepareExecution(params: PrepareExecutionParams): Promise<{ | ||
to: `0x${string}`; | ||
value: bigint; | ||
data: `0x${string}`; | ||
}>; | ||
/** | ||
* Executes a transaction call on a tokenbound account | ||
* @param {string} params.account The tokenbound account address | ||
* @param {string} params.to The recipient contract address | ||
* @param {bigint} params.value The value to send, in wei | ||
* @param {string} params.data The encoded operation calldata to send | ||
* @returns a Promise that resolves to the transaction hash of the executed call | ||
*/ | ||
execute(params: ExecuteParams): Promise<`0x${string}`>; | ||
/** | ||
* Check if a tokenbound account is a valid signer for a transaction | ||
* @param {string} params.account The tokenbound account address | ||
* @returns a Promise that resolves to true if the account is a valid signer, otherwise false | ||
*/ | ||
isValidSigner({ account }: ValidSignerParams): Promise<boolean>; | ||
/** | ||
* Check if a tokenbound account has been deployed | ||
@@ -103,3 +132,3 @@ * @param {string} params.accountAddress The tokenbound account address | ||
* @param {string} params.recipientAddress The address to which the token should be transferred | ||
* @param {string} params.amount The amount of tokens to transfer, (eg. 1 NFT = 1) | ||
* @param {string} params.amount The amount of tokens to transfer, (eg. 1 NFT = 1). Defaults to 1. 1155 only. | ||
* @returns a Promise that resolves to the transaction hash of the executed call | ||
@@ -133,2 +162,7 @@ */ | ||
} | ||
export { TokenboundClient, erc6551AccountAbi, erc6551RegistryAbi, getAccount, createAccount, getCreationCode, computeAccount, prepareExecuteCall, executeCall, }; | ||
declare const erc6551AccountAbiV2: import("viem").Abi; | ||
declare const erc6551RegistryAbiV2: import("viem").Abi; | ||
declare const erc6551AccountAbiV3: import("viem").Abi; | ||
declare const erc6551AccountProxyAbiV3: import("viem").Abi; | ||
declare const erc6551RegistryAbiV3: import("viem").Abi; | ||
export { TokenboundClient, erc6551AccountAbiV2, erc6551RegistryAbiV2, erc6551AccountAbiV3, erc6551AccountProxyAbiV3, erc6551RegistryAbiV3, getAccount, createAccount, getCreationCode, computeAccount, prepareExecuteCall, executeCall, }; |
@@ -6,5 +6,8 @@ export * from './abstractBigNumber'; | ||
export * from './anvilAccount'; | ||
export * from './contractABIPair'; | ||
export * from './operations'; | ||
export * from './erc1155Bytecode'; | ||
export * from './messages'; | ||
export * from './multicall'; | ||
export * from './params'; | ||
export * from './prettify'; |
import { WalletClient, PublicClient, Chain } from 'viem'; | ||
import { Prettify } from './prettify'; | ||
import { UniversalSignableMessage } from './messages'; | ||
import { UniversalSignableMessage, CallOperation } from '.'; | ||
import { PossibleENSAddress } from './addresses'; | ||
import { ERC_6551_LEGACY_V2 } from '../constants'; | ||
export declare const NFTTokenType: { | ||
@@ -9,2 +10,7 @@ readonly ERC721: "ERC721"; | ||
}; | ||
export declare const TBVersion: { | ||
readonly V2: 2; | ||
readonly V3: 3; | ||
}; | ||
export type TBImplementationVersion = (typeof TBVersion)[keyof typeof TBVersion]; | ||
type TokenType = (typeof NFTTokenType)[keyof typeof NFTTokenType]; | ||
@@ -38,2 +44,3 @@ type NFTParams = Prettify<{ | ||
}>; | ||
type ImplementationAddress = `0x${string}` | typeof ERC_6551_LEGACY_V2.IMPLEMENTATION.ADDRESS; | ||
export type TokenboundClientOptions = Prettify<{ | ||
@@ -46,8 +53,8 @@ chainId?: number; | ||
publicClientRPCUrl?: string; | ||
implementationAddress?: `0x${string}`; | ||
implementationAddress?: ImplementationAddress; | ||
registryAddress?: `0x${string}`; | ||
version?: TBImplementationVersion; | ||
}>; | ||
type Custom6551Implementation = Prettify<{ | ||
implementationAddress: `0x${string}`; | ||
registryAddress?: `0x${string}`; | ||
salt?: number; | ||
}>; | ||
@@ -65,2 +72,10 @@ export type TBAccountParams = NFTParams; | ||
export type PrepareExecuteCallParams = ExecuteCallParams; | ||
export type ExecuteParams = Prettify<ExecuteCallParams & { | ||
operation?: CallOperation; | ||
}>; | ||
export type PrepareExecutionParams = ExecuteParams; | ||
export type ValidSignerParams = Prettify<{ | ||
account: `0x${string}`; | ||
data?: string; | ||
}>; | ||
export type ComputeAccountParams = Prettify<TBAccountParams & { | ||
@@ -67,0 +82,0 @@ chainId: number; |
export * from './addressToUint8Array'; | ||
export * from './isAbstractBigNumber'; | ||
export * from './chainIdToChain'; | ||
export * from './segmentBytecode'; | ||
export * from './ethersAdaptors'; | ||
export * from './getImplementationName'; | ||
export * from './isAbstractBigNumber'; | ||
export * from './messageTypeguards'; | ||
export * from './normalizeEthersMessage'; | ||
export * from './messageTypeguards'; | ||
export * from './resolvePossibleENS'; | ||
export * from './segmentBytecode'; |
@@ -1,2 +0,2 @@ | ||
import { AbstractBigNumber } from "../types"; | ||
import { AbstractBigNumber } from '../types'; | ||
export declare function isAbstractBigNumber(value: any): value is AbstractBigNumber; |
@@ -5,3 +5,3 @@ /** | ||
* @param input - The input string to split into segments. | ||
* @param lengths - The lengths of the segments to extract, in bytes. The sum of lengths should not exceed the input string's length. | ||
* @param lengths - The lengths of the segments to extract, in bytes. | ||
* @returns An array containing the extracted segments in the order they were specified. | ||
@@ -12,4 +12,4 @@ * | ||
* const segments = segmentBytecode(bytecode, 2, 4, 8); | ||
* console.log(segmetns); // ["0x", "1234", "567890ab"] | ||
* console.log(segments); // ["0x", "1234", "567890ab"] | ||
*/ | ||
export declare function segmentBytecode(input: string, ...lengths: number[]): string[]; |
{ | ||
"name": "@tokenbound/sdk", | ||
"version": "0.3.12", | ||
"version": "0.4.0", | ||
"type": "module", | ||
@@ -19,3 +19,3 @@ "files": [ | ||
"dependencies": { | ||
"viem": "^1.16.2" | ||
"viem": "^1.17.1" | ||
}, | ||
@@ -31,3 +31,3 @@ "devDependencies": { | ||
"@vitest/coverage-c8": "^0.33.0", | ||
"@wagmi/cli": "^1.5.0", | ||
"@wagmi/cli": "^1.5.2", | ||
"connectkit": "^1.5.3", | ||
@@ -40,3 +40,4 @@ "ethers": "^5.7.2", | ||
"typescript": "^5.2.2", | ||
"viem": "^1.16.2", | ||
"viem": "^1.17.1", | ||
"wagmi": "^1.4.5", | ||
"@viem/anvil": "^0.0.6", | ||
@@ -46,3 +47,2 @@ "vite": "^4.4.9", | ||
"vitest": "^0.34.2", | ||
"wagmi": "^1.4.3", | ||
"eslint": "^8.50.0", | ||
@@ -56,3 +56,3 @@ "eslint-config-prettier": "^9.0.0", | ||
"forge-std": "1.1.2", | ||
"@tokenbound/sdk": "^0.3.12" | ||
"@tokenbound/sdk": "^0.4.0" | ||
}, | ||
@@ -59,0 +59,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
296882
39
4169
Updatedviem@^1.17.1