damm-sdk 1.1.31-alpha.5 → 1.1.31-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.map
CHANGED
|
@@ -334,7 +334,7 @@
|
|
|
334
334
|
"export default [\n {\n inputs: [\n { internalType: \"uint32\", name: \"_localDomain\", type: \"uint32\" },\n { internalType: \"uint32\", name: \"_version\", type: \"uint32\" },\n ],\n stateMutability: \"nonpayable\",\n type: \"constructor\",\n },\n {\n anonymous: false,\n inputs: [{ indexed: true, internalType: \"address\", name: \"attester\", type: \"address\" }],\n name: \"AttesterDisabled\",\n type: \"event\",\n },\n {\n anonymous: false,\n inputs: [{ indexed: true, internalType: \"address\", name: \"attester\", type: \"address\" }],\n name: \"AttesterEnabled\",\n type: \"event\",\n },\n {\n anonymous: false,\n inputs: [\n { indexed: true, internalType: \"address\", name: \"previousAttesterManager\", type: \"address\" },\n { indexed: true, internalType: \"address\", name: \"newAttesterManager\", type: \"address\" },\n ],\n name: \"AttesterManagerUpdated\",\n type: \"event\",\n },\n {\n anonymous: false,\n inputs: [{ indexed: false, internalType: \"uint64\", name: \"version\", type: \"uint64\" }],\n name: \"Initialized\",\n type: \"event\",\n },\n {\n anonymous: false,\n inputs: [{ indexed: false, internalType: \"uint256\", name: \"newMaxMessageBodySize\", type: \"uint256\" }],\n name: \"MaxMessageBodySizeUpdated\",\n type: \"event\",\n },\n {\n anonymous: false,\n inputs: [\n { indexed: true, internalType: \"address\", name: \"caller\", type: \"address\" },\n { indexed: false, internalType: \"uint32\", name: \"sourceDomain\", type: \"uint32\" },\n { indexed: true, internalType: \"bytes32\", name: \"nonce\", type: \"bytes32\" },\n { indexed: false, internalType: \"bytes32\", name: \"sender\", type: \"bytes32\" },\n { indexed: true, internalType: \"uint32\", name: \"finalityThresholdExecuted\", type: \"uint32\" },\n { indexed: false, internalType: \"bytes\", name: \"messageBody\", type: \"bytes\" },\n ],\n name: \"MessageReceived\",\n type: \"event\",\n },\n {\n anonymous: false,\n inputs: [{ indexed: false, internalType: \"bytes\", name: \"message\", type: \"bytes\" }],\n name: \"MessageSent\",\n type: \"event\",\n },\n {\n anonymous: false,\n inputs: [\n { indexed: true, internalType: \"address\", name: \"previousOwner\", type: \"address\" },\n { indexed: true, internalType: \"address\", name: \"newOwner\", type: \"address\" },\n ],\n name: \"OwnershipTransferStarted\",\n type: \"event\",\n },\n {\n anonymous: false,\n inputs: [\n { indexed: true, internalType: \"address\", name: \"previousOwner\", type: \"address\" },\n { indexed: true, internalType: \"address\", name: \"newOwner\", type: \"address\" },\n ],\n name: \"OwnershipTransferred\",\n type: \"event\",\n },\n { anonymous: false, inputs: [], name: \"Pause\", type: \"event\" },\n {\n anonymous: false,\n inputs: [{ indexed: true, internalType: \"address\", name: \"newAddress\", type: \"address\" }],\n name: \"PauserChanged\",\n type: \"event\",\n },\n {\n anonymous: false,\n inputs: [{ indexed: true, internalType: \"address\", name: \"newRescuer\", type: \"address\" }],\n name: \"RescuerChanged\",\n type: \"event\",\n },\n {\n anonymous: false,\n inputs: [\n { indexed: false, internalType: \"uint256\", name: \"oldSignatureThreshold\", type: \"uint256\" },\n { indexed: false, internalType: \"uint256\", name: \"newSignatureThreshold\", type: \"uint256\" },\n ],\n name: \"SignatureThresholdUpdated\",\n type: \"event\",\n },\n { anonymous: false, inputs: [], name: \"Unpause\", type: \"event\" },\n {\n inputs: [],\n name: \"NONCE_USED\",\n outputs: [{ internalType: \"uint256\", name: \"\", type: \"uint256\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n { inputs: [], name: \"acceptOwnership\", outputs: [], stateMutability: \"nonpayable\", type: \"function\" },\n {\n inputs: [],\n name: \"attesterManager\",\n outputs: [{ internalType: \"address\", name: \"\", type: \"address\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [{ internalType: \"address\", name: \"attester\", type: \"address\" }],\n name: \"disableAttester\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [{ internalType: \"address\", name: \"newAttester\", type: \"address\" }],\n name: \"enableAttester\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [{ internalType: \"uint256\", name: \"index\", type: \"uint256\" }],\n name: \"getEnabledAttester\",\n outputs: [{ internalType: \"address\", name: \"\", type: \"address\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [],\n name: \"getNumEnabledAttesters\",\n outputs: [{ internalType: \"uint256\", name: \"\", type: \"uint256\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [\n { internalType: \"address\", name: \"owner_\", type: \"address\" },\n { internalType: \"address\", name: \"pauser_\", type: \"address\" },\n { internalType: \"address\", name: \"rescuer_\", type: \"address\" },\n { internalType: \"address\", name: \"attesterManager_\", type: \"address\" },\n { internalType: \"address[]\", name: \"attesters_\", type: \"address[]\" },\n { internalType: \"uint256\", name: \"signatureThreshold_\", type: \"uint256\" },\n { internalType: \"uint256\", name: \"maxMessageBodySize_\", type: \"uint256\" },\n ],\n name: \"initialize\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [],\n name: \"initializedVersion\",\n outputs: [{ internalType: \"uint64\", name: \"\", type: \"uint64\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [{ internalType: \"address\", name: \"attester\", type: \"address\" }],\n name: \"isEnabledAttester\",\n outputs: [{ internalType: \"bool\", name: \"\", type: \"bool\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [],\n name: \"localDomain\",\n outputs: [{ internalType: \"uint32\", name: \"\", type: \"uint32\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [],\n name: \"maxMessageBodySize\",\n outputs: [{ internalType: \"uint256\", name: \"\", type: \"uint256\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [],\n name: \"owner\",\n outputs: [{ internalType: \"address\", name: \"\", type: \"address\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n { inputs: [], name: \"pause\", outputs: [], stateMutability: \"nonpayable\", type: \"function\" },\n {\n inputs: [],\n name: \"paused\",\n outputs: [{ internalType: \"bool\", name: \"\", type: \"bool\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [],\n name: \"pauser\",\n outputs: [{ internalType: \"address\", name: \"\", type: \"address\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [],\n name: \"pendingOwner\",\n outputs: [{ internalType: \"address\", name: \"\", type: \"address\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [\n { internalType: \"bytes\", name: \"message\", type: \"bytes\" },\n { internalType: \"bytes\", name: \"attestation\", type: \"bytes\" },\n ],\n name: \"receiveMessage\",\n outputs: [{ internalType: \"bool\", name: \"success\", type: \"bool\" }],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [\n { internalType: \"contract IERC20\", name: \"tokenContract\", type: \"address\" },\n { internalType: \"address\", name: \"to\", type: \"address\" },\n { internalType: \"uint256\", name: \"amount\", type: \"uint256\" },\n ],\n name: \"rescueERC20\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [],\n name: \"rescuer\",\n outputs: [{ internalType: \"address\", name: \"\", type: \"address\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [\n { internalType: \"uint32\", name: \"destinationDomain\", type: \"uint32\" },\n { internalType: \"bytes32\", name: \"recipient\", type: \"bytes32\" },\n { internalType: \"bytes32\", name: \"destinationCaller\", type: \"bytes32\" },\n { internalType: \"uint32\", name: \"minFinalityThreshold\", type: \"uint32\" },\n { internalType: \"bytes\", name: \"messageBody\", type: \"bytes\" },\n ],\n name: \"sendMessage\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [{ internalType: \"uint256\", name: \"newMaxMessageBodySize\", type: \"uint256\" }],\n name: \"setMaxMessageBodySize\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [{ internalType: \"uint256\", name: \"newSignatureThreshold\", type: \"uint256\" }],\n name: \"setSignatureThreshold\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [],\n name: \"signatureThreshold\",\n outputs: [{ internalType: \"uint256\", name: \"\", type: \"uint256\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [{ internalType: \"address\", name: \"newOwner\", type: \"address\" }],\n name: \"transferOwnership\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n { inputs: [], name: \"unpause\", outputs: [], stateMutability: \"nonpayable\", type: \"function\" },\n {\n inputs: [{ internalType: \"address\", name: \"newAttesterManager\", type: \"address\" }],\n name: \"updateAttesterManager\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [{ internalType: \"address\", name: \"_newPauser\", type: \"address\" }],\n name: \"updatePauser\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [{ internalType: \"address\", name: \"newRescuer\", type: \"address\" }],\n name: \"updateRescuer\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [{ internalType: \"bytes32\", name: \"\", type: \"bytes32\" }],\n name: \"usedNonces\",\n outputs: [{ internalType: \"uint256\", name: \"\", type: \"uint256\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [],\n name: \"version\",\n outputs: [{ internalType: \"uint32\", name: \"\", type: \"uint32\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n] as const;\n",
|
|
335
335
|
"import { ethers } from \"ethers\";\nimport CctpMessageTransmitterV2Abi from \"./message.transmitter.v2.abi\";\nimport CctpTokenMessengerV2Abi from \"./token.messenger.v2.abi\";\nimport type { HexString } from \"../../types\";\nimport { createCall, type Unwrapable } from \"../../types\";\nimport type { Address } from \"viem\";\nimport type { Call } from \"../../types\";\n\nconst messageTransmitterAbi = new ethers.utils.Interface(CctpMessageTransmitterV2Abi);\nconst tokenMessengerAbi = new ethers.utils.Interface(CctpTokenMessengerV2Abi);\n\n// function depositForBurn(\n// uint256 amount,\n// uint32 destinationDomain,\n// bytes32 mintRecipient,\n// address burnToken,\n// bytes32 destinationCaller,\n// uint256 maxFee,\n// uint32 minFinalityThreshold\n// ) external\n\n// function receiveMessage(\n// bytes calldata message,\n// bytes calldata attestation\n// ) external\n\nexport type DepositForBurnArgs = {\n amount: bigint;\n destinationDomain: number;\n mintRecipient: string;\n burnToken: string;\n destinationCaller: string;\n maxFee: bigint;\n minFinalityThreshold: number;\n};\n\nexport const DepositForBurnCalldata = ({\n amount,\n destinationDomain,\n mintRecipient,\n burnToken,\n destinationCaller,\n maxFee,\n minFinalityThreshold,\n}: DepositForBurnArgs): HexString => {\n return tokenMessengerAbi.encodeFunctionData(\"depositForBurn\", [\n amount,\n destinationDomain,\n mintRecipient,\n burnToken,\n destinationCaller,\n maxFee,\n minFinalityThreshold,\n ]) as HexString;\n};\n\nexport const depositForBurnToCctpTrx = ({\n args,\n tokenMessengerAddress,\n}: {\n args: DepositForBurnArgs;\n tokenMessengerAddress: Address;\n}): Unwrapable<Call> => {\n return createCall({\n operation: 0,\n to: tokenMessengerAddress,\n value: 0n,\n data: DepositForBurnCalldata(args),\n });\n};\n\nexport type ReceiveMessageArgs = {\n message: string;\n attestation: string;\n};\n\nexport const ReceiveMessageCalldata = ({ message, attestation }: ReceiveMessageArgs): HexString => {\n return messageTransmitterAbi.encodeFunctionData(\"receiveMessage\", [message, attestation]) as HexString;\n};\n\nexport const receiveMessageFromCctpTrx = ({\n args,\n messageTransmitterAddress,\n}: {\n args: ReceiveMessageArgs;\n messageTransmitterAddress: Address;\n}): Unwrapable<Call> => {\n return createCall({\n operation: 0,\n to: messageTransmitterAddress,\n value: 0n,\n data: ReceiveMessageCalldata(args),\n });\n};\n",
|
|
336
336
|
"export default [\n {\n name: \"Approval\",\n type: \"event\",\n inputs: [\n {\n name: \"owner\",\n type: \"address\",\n indexed: true,\n internalType: \"address\",\n },\n {\n name: \"approved\",\n type: \"address\",\n indexed: true,\n internalType: \"address\",\n },\n {\n name: \"tokenId\",\n type: \"uint256\",\n indexed: true,\n internalType: \"uint256\",\n },\n ],\n anonymous: false,\n },\n {\n name: \"ApprovalForAll\",\n type: \"event\",\n inputs: [\n {\n name: \"owner\",\n type: \"address\",\n indexed: true,\n internalType: \"address\",\n },\n {\n name: \"operator\",\n type: \"address\",\n indexed: true,\n internalType: \"address\",\n },\n {\n name: \"approved\",\n type: \"bool\",\n indexed: false,\n internalType: \"bool\",\n },\n ],\n anonymous: false,\n },\n {\n name: \"Transfer\",\n type: \"event\",\n inputs: [\n {\n name: \"from\",\n type: \"address\",\n indexed: true,\n internalType: \"address\",\n },\n {\n name: \"to\",\n type: \"address\",\n indexed: true,\n internalType: \"address\",\n },\n {\n name: \"tokenId\",\n type: \"uint256\",\n indexed: true,\n internalType: \"uint256\",\n },\n ],\n anonymous: false,\n },\n {\n name: \"approve\",\n type: \"function\",\n inputs: [\n { name: \"to\", type: \"address\", internalType: \"address\" },\n { name: \"tokenId\", type: \"uint256\", internalType: \"uint256\" },\n ],\n outputs: [],\n stateMutability: \"nonpayable\",\n },\n {\n name: \"balanceOf\",\n type: \"function\",\n inputs: [{ name: \"owner\", type: \"address\", internalType: \"address\" }],\n outputs: [{ name: \"\", type: \"uint256\", internalType: \"uint256\" }],\n stateMutability: \"view\",\n },\n {\n name: \"getApproved\",\n type: \"function\",\n inputs: [{ name: \"tokenId\", type: \"uint256\", internalType: \"uint256\" }],\n outputs: [{ name: \"\", type: \"address\", internalType: \"address\" }],\n stateMutability: \"view\",\n },\n {\n name: \"isApprovedForAll\",\n type: \"function\",\n inputs: [\n { name: \"owner\", type: \"address\", internalType: \"address\" },\n { name: \"operator\", type: \"address\", internalType: \"address\" },\n ],\n outputs: [{ name: \"\", type: \"bool\", internalType: \"bool\" }],\n stateMutability: \"view\",\n },\n {\n name: \"name\",\n type: \"function\",\n inputs: [],\n outputs: [{ name: \"\", type: \"string\", internalType: \"string\" }],\n stateMutability: \"view\",\n },\n {\n name: \"ownerOf\",\n type: \"function\",\n inputs: [{ name: \"tokenId\", type: \"uint256\", internalType: \"uint256\" }],\n outputs: [{ name: \"\", type: \"address\", internalType: \"address\" }],\n stateMutability: \"view\",\n },\n {\n name: \"safeTransferFrom\",\n type: \"function\",\n inputs: [\n { name: \"from\", type: \"address\", internalType: \"address\" },\n { name: \"to\", type: \"address\", internalType: \"address\" },\n { name: \"tokenId\", type: \"uint256\", internalType: \"uint256\" },\n ],\n outputs: [],\n stateMutability: \"nonpayable\",\n },\n {\n name: \"safeTransferFrom\",\n type: \"function\",\n inputs: [\n { name: \"from\", type: \"address\", internalType: \"address\" },\n { name: \"to\", type: \"address\", internalType: \"address\" },\n { name: \"tokenId\", type: \"uint256\", internalType: \"uint256\" },\n { name: \"_data\", type: \"bytes\", internalType: \"bytes\" },\n ],\n outputs: [],\n stateMutability: \"nonpayable\",\n },\n {\n name: \"setApprovalForAll\",\n type: \"function\",\n inputs: [\n {\n name: \"operator\",\n type: \"address\",\n internalType: \"address\",\n },\n { name: \"approved\", type: \"bool\", internalType: \"bool\" },\n ],\n outputs: [],\n stateMutability: \"nonpayable\",\n },\n {\n name: \"supportsInterface\",\n type: \"function\",\n inputs: [\n {\n name: \"interfaceId\",\n type: \"bytes4\",\n internalType: \"bytes4\",\n },\n ],\n outputs: [{ name: \"\", type: \"bool\", internalType: \"bool\" }],\n stateMutability: \"view\",\n },\n {\n name: \"symbol\",\n type: \"function\",\n inputs: [],\n outputs: [{ name: \"\", type: \"string\", internalType: \"string\" }],\n stateMutability: \"view\",\n },\n {\n name: \"tokenURI\",\n type: \"function\",\n inputs: [{ name: \"tokenId\", type: \"uint256\", internalType: \"uint256\" }],\n outputs: [{ name: \"\", type: \"string\", internalType: \"string\" }],\n stateMutability: \"view\",\n },\n {\n name: \"transferFrom\",\n type: \"function\",\n inputs: [\n { name: \"from\", type: \"address\", internalType: \"address\" },\n { name: \"to\", type: \"address\", internalType: \"address\" },\n { name: \"tokenId\", type: \"uint256\", internalType: \"uint256\" },\n ],\n outputs: [],\n stateMutability: \"nonpayable\",\n },\n] as const;\n",
|
|
337
|
-
"import type { Address } from \"viem\";\nimport
|
|
337
|
+
"import type { Address } from \"viem\";\nimport Erc721Abi from \"./erc721.abi\";\nimport { ethers } from \"ethers\";\nimport { createCall, type Call, type HexString, type Unwrapable } from \"../../types\";\n\nconst erc721Interface = new ethers.utils.Interface(Erc721Abi);\n\nexport type ApproveErc721Args = Readonly<{\n tokenId: bigint;\n spender: Address;\n token: Address;\n}>;\n\nexport const ApproveErc721CallData = ({ tokenId, spender }: Omit<ApproveErc721Args, \"token\">): HexString => {\n return erc721Interface.encodeFunctionData(\"approve\", [spender, tokenId]) as HexString;\n};\n\nexport const approveErc721Trx = ({ tokenId, spender, token }: ApproveErc721Args): Unwrapable<Call> => {\n return createCall({\n to: token as `0x${string}`,\n data: ApproveErc721CallData({ tokenId, spender }),\n value: 0n,\n operation: 0,\n });\n};\n\nexport type TransferFromErc721Args = Readonly<{\n from: Address;\n to: Address;\n tokenId: bigint;\n token: Address;\n}>;\n\nexport const TransferFromErc721CallData = ({ from, to, tokenId }: Omit<TransferFromErc721Args, \"token\">): HexString => {\n return erc721Interface.encodeFunctionData(\"transferFrom\", [from, to, tokenId]) as HexString;\n};\n\nexport const transferFromErc721Trx = ({ from, to, tokenId, token }: TransferFromErc721Args): Unwrapable<Call> => {\n return createCall({\n to: token as `0x${string}`,\n data: TransferFromErc721CallData({ from, to, tokenId }),\n value: 0n,\n operation: 0,\n });\n};\n\nexport type SafeTransferFromWithDataErc721Args = Readonly<{\n from: Address;\n to: Address;\n tokenId: bigint;\n data: HexString;\n token: Address;\n}>;\n\nexport const SafeTransferFromWithDataErc721CallData = ({\n from,\n to,\n tokenId,\n data,\n}: Omit<SafeTransferFromWithDataErc721Args, \"token\">): HexString => {\n return erc721Interface.encodeFunctionData(\"safeTransferFrom\", [from, to, tokenId, data]) as HexString;\n};\n\nexport const safeTransferFromWithDataErc721Trx = ({\n from,\n to,\n tokenId,\n data,\n token,\n}: SafeTransferFromWithDataErc721Args): Unwrapable<Call> => {\n return createCall({\n to: token as `0x${string}`,\n data: SafeTransferFromWithDataErc721CallData({ from, to, tokenId, data }),\n value: 0n,\n operation: 0,\n });\n};\n\nexport type SafeTransferFromErc721Args = Readonly<{\n from: Address;\n to: Address;\n tokenId: bigint;\n token: Address;\n}>;\n\nexport const SafeTransferFromErc721CallData = ({\n from,\n to,\n tokenId,\n}: Omit<SafeTransferFromErc721Args, \"token\">): HexString => {\n return erc721Interface.encodeFunctionData(\"safeTransferFrom\", [from, to, tokenId]) as HexString;\n};\n\nexport const safeTransferFromErc721Trx = ({\n from,\n to,\n tokenId,\n token,\n}: SafeTransferFromErc721Args): Unwrapable<Call> => {\n return createCall({\n to: token as `0x${string}`,\n data: SafeTransferFromErc721CallData({ from, to, tokenId }),\n value: 0n,\n operation: 0,\n });\n};\n\nexport type SetApprovalForAllErc721Args = Readonly<{\n operator: Address;\n approved: boolean;\n token: Address;\n}>;\n\nexport const SetApprovalForAllErc721CallData = ({\n operator,\n approved,\n}: Omit<SetApprovalForAllErc721Args, \"token\">): HexString => {\n return erc721Interface.encodeFunctionData(\"setApprovalForAll\", [operator, approved]) as HexString;\n};\n\nexport const setApprovalForAllErc721Trx = ({\n operator,\n approved,\n token,\n}: SetApprovalForAllErc721Args): Unwrapable<Call> => {\n return createCall({\n to: token as `0x${string}`,\n data: SetApprovalForAllErc721CallData({ operator, approved }),\n value: 0n,\n operation: 0,\n });\n};\n",
|
|
338
338
|
"import { Wallet } from \"ethers\";\nimport type { WalletClient, Address, Chain } from \"viem\";\nimport type { Call } from \"..\";\n\nexport const executeTrx = ({\n client,\n call,\n sender,\n gas,\n chain,\n}: Readonly<{\n client: WalletClient;\n call: Call;\n sender: Address | Wallet;\n gas: bigint;\n chain?: Chain;\n}>) => {\n const _sender: Address = sender instanceof Wallet ? (sender.address as Address) : sender;\n\n return client.sendTransaction({\n to: call.to,\n value: call.value,\n data: call.data,\n account: _sender,\n chain,\n gas,\n });\n};\n",
|
|
339
339
|
"import type { Address } from \"viem\";\nimport { type Call, type Unwrapable, createCall } from \"../types\";\n\nexport const transferNativeEth = ({ to, amount }: { to: Address; amount: bigint }): Unwrapable<Call> => {\n return createCall({\n to,\n operation: 0,\n value: amount,\n data: \"0x\",\n });\n};\n",
|
|
340
340
|
"import { hexToNumber, type Hex } from \"viem\";\nimport type { Call } from \"../types\";\n\nexport type SimulationEnvironment = Readonly<{\n tenderlyConfig: {\n accountSlug: string;\n projectSlug: string;\n accessKey: string;\n };\n network_id: string;\n from: string;\n trx: Call;\n gas?: number;\n gas_price?: number;\n block_number?: number;\n simulationType?: \"full\" | \"abi\" | \"quick\";\n verbose?: boolean;\n}>;\n\nexport type SimulationResult = Readonly<{\n result: boolean;\n blockNumber: number;\n networkId: string;\n baseFeePerGas?: number;\n gasLimit?: number;\n timestamp?: number;\n gasUsed?: number;\n errorMessage?: string;\n}>;\n\ntype SimulationRequestResponse = Readonly<{\n simulation?: {\n network_id: string;\n block_number: number;\n error_message: string;\n status: boolean;\n block_header: {\n baseFeePerGas: Hex;\n gasLimit: Hex;\n timestamp: Hex;\n gasUsed: Hex;\n };\n };\n}>;\n\nconst simulate = (env: SimulationEnvironment) => {\n const { tenderlyConfig, network_id, from, trx, gas, gas_price, block_number, simulationType, verbose } = env;\n\n const url = `https://api.tenderly.co/api/v1/account/${tenderlyConfig.accountSlug}/project/${tenderlyConfig.projectSlug}/simulate`;\n\n const body = {\n /* Simulation Configuration */\n save: false, // if true simulation is saved and shows up in the dashboard\n save_if_fails: false, // if true, reverting simulations show up in the dashboard\n simulation_type: simulationType || \"full\", // full, abi or quick (full is default)\n network_id, // network to simulate on\n /* Standard EVM Transaction object */\n from,\n to: trx.to,\n input: trx.data,\n gas,\n gas_price,\n value: trx.value.toString(),\n block_number,\n };\n\n const headers = {\n headers: {\n \"content-type\": \"application/JSON\",\n \"X-Access-Key\": tenderlyConfig.accessKey,\n },\n };\n\n if (verbose) {\n console.log(`Simulation Request: body:${JSON.stringify(body)}`);\n }\n\n return fetch(url, {\n method: \"POST\",\n body: JSON.stringify(body),\n headers: headers.headers,\n });\n};\n\nexport const simulateOrThrow = async (env: SimulationEnvironment): Promise<SimulationResult> => {\n const resp = await simulate(env);\n\n if (!resp.ok) {\n // Get the error response body if possible\n let errorBody = \"\";\n try {\n errorBody = await resp.text();\n } catch (e) {\n errorBody = \"Could not read error response body\";\n }\n\n throw new Error(\n `Simulation request failed:\n Status: ${resp.status}\n Status Text: ${resp.statusText}\n URL: ${resp.url}\n Response Body: ${errorBody}\n Network ID: ${env.network_id}\n From Address: ${env.from}\n To Address: ${env.trx.to}`,\n );\n }\n\n const payload: SimulationRequestResponse = (await resp.json()) as SimulationRequestResponse;\n\n // Add validation for expected payload structure\n if (!payload.simulation) {\n throw new Error(`Invalid simulation response: ${JSON.stringify(payload)}`);\n }\n\n const { network_id, block_number, error_message, status, block_header } = payload.simulation;\n\n return {\n result: status,\n blockNumber: block_number,\n networkId: network_id,\n errorMessage: error_message,\n baseFeePerGas: hexToNumber(block_header.baseFeePerGas),\n gasLimit: hexToNumber(block_header.gasLimit),\n timestamp: hexToNumber(block_header.timestamp),\n gasUsed: hexToNumber(block_header.gasUsed),\n };\n};\n"
|
package/dist/index.js.map
CHANGED
|
@@ -270,7 +270,7 @@
|
|
|
270
270
|
"export default [\n {\n inputs: [\n { internalType: \"uint32\", name: \"_localDomain\", type: \"uint32\" },\n { internalType: \"uint32\", name: \"_version\", type: \"uint32\" },\n ],\n stateMutability: \"nonpayable\",\n type: \"constructor\",\n },\n {\n anonymous: false,\n inputs: [{ indexed: true, internalType: \"address\", name: \"attester\", type: \"address\" }],\n name: \"AttesterDisabled\",\n type: \"event\",\n },\n {\n anonymous: false,\n inputs: [{ indexed: true, internalType: \"address\", name: \"attester\", type: \"address\" }],\n name: \"AttesterEnabled\",\n type: \"event\",\n },\n {\n anonymous: false,\n inputs: [\n { indexed: true, internalType: \"address\", name: \"previousAttesterManager\", type: \"address\" },\n { indexed: true, internalType: \"address\", name: \"newAttesterManager\", type: \"address\" },\n ],\n name: \"AttesterManagerUpdated\",\n type: \"event\",\n },\n {\n anonymous: false,\n inputs: [{ indexed: false, internalType: \"uint64\", name: \"version\", type: \"uint64\" }],\n name: \"Initialized\",\n type: \"event\",\n },\n {\n anonymous: false,\n inputs: [{ indexed: false, internalType: \"uint256\", name: \"newMaxMessageBodySize\", type: \"uint256\" }],\n name: \"MaxMessageBodySizeUpdated\",\n type: \"event\",\n },\n {\n anonymous: false,\n inputs: [\n { indexed: true, internalType: \"address\", name: \"caller\", type: \"address\" },\n { indexed: false, internalType: \"uint32\", name: \"sourceDomain\", type: \"uint32\" },\n { indexed: true, internalType: \"bytes32\", name: \"nonce\", type: \"bytes32\" },\n { indexed: false, internalType: \"bytes32\", name: \"sender\", type: \"bytes32\" },\n { indexed: true, internalType: \"uint32\", name: \"finalityThresholdExecuted\", type: \"uint32\" },\n { indexed: false, internalType: \"bytes\", name: \"messageBody\", type: \"bytes\" },\n ],\n name: \"MessageReceived\",\n type: \"event\",\n },\n {\n anonymous: false,\n inputs: [{ indexed: false, internalType: \"bytes\", name: \"message\", type: \"bytes\" }],\n name: \"MessageSent\",\n type: \"event\",\n },\n {\n anonymous: false,\n inputs: [\n { indexed: true, internalType: \"address\", name: \"previousOwner\", type: \"address\" },\n { indexed: true, internalType: \"address\", name: \"newOwner\", type: \"address\" },\n ],\n name: \"OwnershipTransferStarted\",\n type: \"event\",\n },\n {\n anonymous: false,\n inputs: [\n { indexed: true, internalType: \"address\", name: \"previousOwner\", type: \"address\" },\n { indexed: true, internalType: \"address\", name: \"newOwner\", type: \"address\" },\n ],\n name: \"OwnershipTransferred\",\n type: \"event\",\n },\n { anonymous: false, inputs: [], name: \"Pause\", type: \"event\" },\n {\n anonymous: false,\n inputs: [{ indexed: true, internalType: \"address\", name: \"newAddress\", type: \"address\" }],\n name: \"PauserChanged\",\n type: \"event\",\n },\n {\n anonymous: false,\n inputs: [{ indexed: true, internalType: \"address\", name: \"newRescuer\", type: \"address\" }],\n name: \"RescuerChanged\",\n type: \"event\",\n },\n {\n anonymous: false,\n inputs: [\n { indexed: false, internalType: \"uint256\", name: \"oldSignatureThreshold\", type: \"uint256\" },\n { indexed: false, internalType: \"uint256\", name: \"newSignatureThreshold\", type: \"uint256\" },\n ],\n name: \"SignatureThresholdUpdated\",\n type: \"event\",\n },\n { anonymous: false, inputs: [], name: \"Unpause\", type: \"event\" },\n {\n inputs: [],\n name: \"NONCE_USED\",\n outputs: [{ internalType: \"uint256\", name: \"\", type: \"uint256\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n { inputs: [], name: \"acceptOwnership\", outputs: [], stateMutability: \"nonpayable\", type: \"function\" },\n {\n inputs: [],\n name: \"attesterManager\",\n outputs: [{ internalType: \"address\", name: \"\", type: \"address\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [{ internalType: \"address\", name: \"attester\", type: \"address\" }],\n name: \"disableAttester\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [{ internalType: \"address\", name: \"newAttester\", type: \"address\" }],\n name: \"enableAttester\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [{ internalType: \"uint256\", name: \"index\", type: \"uint256\" }],\n name: \"getEnabledAttester\",\n outputs: [{ internalType: \"address\", name: \"\", type: \"address\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [],\n name: \"getNumEnabledAttesters\",\n outputs: [{ internalType: \"uint256\", name: \"\", type: \"uint256\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [\n { internalType: \"address\", name: \"owner_\", type: \"address\" },\n { internalType: \"address\", name: \"pauser_\", type: \"address\" },\n { internalType: \"address\", name: \"rescuer_\", type: \"address\" },\n { internalType: \"address\", name: \"attesterManager_\", type: \"address\" },\n { internalType: \"address[]\", name: \"attesters_\", type: \"address[]\" },\n { internalType: \"uint256\", name: \"signatureThreshold_\", type: \"uint256\" },\n { internalType: \"uint256\", name: \"maxMessageBodySize_\", type: \"uint256\" },\n ],\n name: \"initialize\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [],\n name: \"initializedVersion\",\n outputs: [{ internalType: \"uint64\", name: \"\", type: \"uint64\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [{ internalType: \"address\", name: \"attester\", type: \"address\" }],\n name: \"isEnabledAttester\",\n outputs: [{ internalType: \"bool\", name: \"\", type: \"bool\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [],\n name: \"localDomain\",\n outputs: [{ internalType: \"uint32\", name: \"\", type: \"uint32\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [],\n name: \"maxMessageBodySize\",\n outputs: [{ internalType: \"uint256\", name: \"\", type: \"uint256\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [],\n name: \"owner\",\n outputs: [{ internalType: \"address\", name: \"\", type: \"address\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n { inputs: [], name: \"pause\", outputs: [], stateMutability: \"nonpayable\", type: \"function\" },\n {\n inputs: [],\n name: \"paused\",\n outputs: [{ internalType: \"bool\", name: \"\", type: \"bool\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [],\n name: \"pauser\",\n outputs: [{ internalType: \"address\", name: \"\", type: \"address\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [],\n name: \"pendingOwner\",\n outputs: [{ internalType: \"address\", name: \"\", type: \"address\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [\n { internalType: \"bytes\", name: \"message\", type: \"bytes\" },\n { internalType: \"bytes\", name: \"attestation\", type: \"bytes\" },\n ],\n name: \"receiveMessage\",\n outputs: [{ internalType: \"bool\", name: \"success\", type: \"bool\" }],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [\n { internalType: \"contract IERC20\", name: \"tokenContract\", type: \"address\" },\n { internalType: \"address\", name: \"to\", type: \"address\" },\n { internalType: \"uint256\", name: \"amount\", type: \"uint256\" },\n ],\n name: \"rescueERC20\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [],\n name: \"rescuer\",\n outputs: [{ internalType: \"address\", name: \"\", type: \"address\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [\n { internalType: \"uint32\", name: \"destinationDomain\", type: \"uint32\" },\n { internalType: \"bytes32\", name: \"recipient\", type: \"bytes32\" },\n { internalType: \"bytes32\", name: \"destinationCaller\", type: \"bytes32\" },\n { internalType: \"uint32\", name: \"minFinalityThreshold\", type: \"uint32\" },\n { internalType: \"bytes\", name: \"messageBody\", type: \"bytes\" },\n ],\n name: \"sendMessage\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [{ internalType: \"uint256\", name: \"newMaxMessageBodySize\", type: \"uint256\" }],\n name: \"setMaxMessageBodySize\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [{ internalType: \"uint256\", name: \"newSignatureThreshold\", type: \"uint256\" }],\n name: \"setSignatureThreshold\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [],\n name: \"signatureThreshold\",\n outputs: [{ internalType: \"uint256\", name: \"\", type: \"uint256\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [{ internalType: \"address\", name: \"newOwner\", type: \"address\" }],\n name: \"transferOwnership\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n { inputs: [], name: \"unpause\", outputs: [], stateMutability: \"nonpayable\", type: \"function\" },\n {\n inputs: [{ internalType: \"address\", name: \"newAttesterManager\", type: \"address\" }],\n name: \"updateAttesterManager\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [{ internalType: \"address\", name: \"_newPauser\", type: \"address\" }],\n name: \"updatePauser\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [{ internalType: \"address\", name: \"newRescuer\", type: \"address\" }],\n name: \"updateRescuer\",\n outputs: [],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n inputs: [{ internalType: \"bytes32\", name: \"\", type: \"bytes32\" }],\n name: \"usedNonces\",\n outputs: [{ internalType: \"uint256\", name: \"\", type: \"uint256\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n inputs: [],\n name: \"version\",\n outputs: [{ internalType: \"uint32\", name: \"\", type: \"uint32\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n] as const;\n",
|
|
271
271
|
"import { ethers } from \"ethers\";\nimport CctpMessageTransmitterV2Abi from \"./message.transmitter.v2.abi\";\nimport CctpTokenMessengerV2Abi from \"./token.messenger.v2.abi\";\nimport type { HexString } from \"../../types\";\nimport { createCall, type Unwrapable } from \"../../types\";\nimport type { Address } from \"viem\";\nimport type { Call } from \"../../types\";\n\nconst messageTransmitterAbi = new ethers.utils.Interface(CctpMessageTransmitterV2Abi);\nconst tokenMessengerAbi = new ethers.utils.Interface(CctpTokenMessengerV2Abi);\n\n// function depositForBurn(\n// uint256 amount,\n// uint32 destinationDomain,\n// bytes32 mintRecipient,\n// address burnToken,\n// bytes32 destinationCaller,\n// uint256 maxFee,\n// uint32 minFinalityThreshold\n// ) external\n\n// function receiveMessage(\n// bytes calldata message,\n// bytes calldata attestation\n// ) external\n\nexport type DepositForBurnArgs = {\n amount: bigint;\n destinationDomain: number;\n mintRecipient: string;\n burnToken: string;\n destinationCaller: string;\n maxFee: bigint;\n minFinalityThreshold: number;\n};\n\nexport const DepositForBurnCalldata = ({\n amount,\n destinationDomain,\n mintRecipient,\n burnToken,\n destinationCaller,\n maxFee,\n minFinalityThreshold,\n}: DepositForBurnArgs): HexString => {\n return tokenMessengerAbi.encodeFunctionData(\"depositForBurn\", [\n amount,\n destinationDomain,\n mintRecipient,\n burnToken,\n destinationCaller,\n maxFee,\n minFinalityThreshold,\n ]) as HexString;\n};\n\nexport const depositForBurnToCctpTrx = ({\n args,\n tokenMessengerAddress,\n}: {\n args: DepositForBurnArgs;\n tokenMessengerAddress: Address;\n}): Unwrapable<Call> => {\n return createCall({\n operation: 0,\n to: tokenMessengerAddress,\n value: 0n,\n data: DepositForBurnCalldata(args),\n });\n};\n\nexport type ReceiveMessageArgs = {\n message: string;\n attestation: string;\n};\n\nexport const ReceiveMessageCalldata = ({ message, attestation }: ReceiveMessageArgs): HexString => {\n return messageTransmitterAbi.encodeFunctionData(\"receiveMessage\", [message, attestation]) as HexString;\n};\n\nexport const receiveMessageFromCctpTrx = ({\n args,\n messageTransmitterAddress,\n}: {\n args: ReceiveMessageArgs;\n messageTransmitterAddress: Address;\n}): Unwrapable<Call> => {\n return createCall({\n operation: 0,\n to: messageTransmitterAddress,\n value: 0n,\n data: ReceiveMessageCalldata(args),\n });\n};\n",
|
|
272
272
|
"export default [\n {\n name: \"Approval\",\n type: \"event\",\n inputs: [\n {\n name: \"owner\",\n type: \"address\",\n indexed: true,\n internalType: \"address\",\n },\n {\n name: \"approved\",\n type: \"address\",\n indexed: true,\n internalType: \"address\",\n },\n {\n name: \"tokenId\",\n type: \"uint256\",\n indexed: true,\n internalType: \"uint256\",\n },\n ],\n anonymous: false,\n },\n {\n name: \"ApprovalForAll\",\n type: \"event\",\n inputs: [\n {\n name: \"owner\",\n type: \"address\",\n indexed: true,\n internalType: \"address\",\n },\n {\n name: \"operator\",\n type: \"address\",\n indexed: true,\n internalType: \"address\",\n },\n {\n name: \"approved\",\n type: \"bool\",\n indexed: false,\n internalType: \"bool\",\n },\n ],\n anonymous: false,\n },\n {\n name: \"Transfer\",\n type: \"event\",\n inputs: [\n {\n name: \"from\",\n type: \"address\",\n indexed: true,\n internalType: \"address\",\n },\n {\n name: \"to\",\n type: \"address\",\n indexed: true,\n internalType: \"address\",\n },\n {\n name: \"tokenId\",\n type: \"uint256\",\n indexed: true,\n internalType: \"uint256\",\n },\n ],\n anonymous: false,\n },\n {\n name: \"approve\",\n type: \"function\",\n inputs: [\n { name: \"to\", type: \"address\", internalType: \"address\" },\n { name: \"tokenId\", type: \"uint256\", internalType: \"uint256\" },\n ],\n outputs: [],\n stateMutability: \"nonpayable\",\n },\n {\n name: \"balanceOf\",\n type: \"function\",\n inputs: [{ name: \"owner\", type: \"address\", internalType: \"address\" }],\n outputs: [{ name: \"\", type: \"uint256\", internalType: \"uint256\" }],\n stateMutability: \"view\",\n },\n {\n name: \"getApproved\",\n type: \"function\",\n inputs: [{ name: \"tokenId\", type: \"uint256\", internalType: \"uint256\" }],\n outputs: [{ name: \"\", type: \"address\", internalType: \"address\" }],\n stateMutability: \"view\",\n },\n {\n name: \"isApprovedForAll\",\n type: \"function\",\n inputs: [\n { name: \"owner\", type: \"address\", internalType: \"address\" },\n { name: \"operator\", type: \"address\", internalType: \"address\" },\n ],\n outputs: [{ name: \"\", type: \"bool\", internalType: \"bool\" }],\n stateMutability: \"view\",\n },\n {\n name: \"name\",\n type: \"function\",\n inputs: [],\n outputs: [{ name: \"\", type: \"string\", internalType: \"string\" }],\n stateMutability: \"view\",\n },\n {\n name: \"ownerOf\",\n type: \"function\",\n inputs: [{ name: \"tokenId\", type: \"uint256\", internalType: \"uint256\" }],\n outputs: [{ name: \"\", type: \"address\", internalType: \"address\" }],\n stateMutability: \"view\",\n },\n {\n name: \"safeTransferFrom\",\n type: \"function\",\n inputs: [\n { name: \"from\", type: \"address\", internalType: \"address\" },\n { name: \"to\", type: \"address\", internalType: \"address\" },\n { name: \"tokenId\", type: \"uint256\", internalType: \"uint256\" },\n ],\n outputs: [],\n stateMutability: \"nonpayable\",\n },\n {\n name: \"safeTransferFrom\",\n type: \"function\",\n inputs: [\n { name: \"from\", type: \"address\", internalType: \"address\" },\n { name: \"to\", type: \"address\", internalType: \"address\" },\n { name: \"tokenId\", type: \"uint256\", internalType: \"uint256\" },\n { name: \"_data\", type: \"bytes\", internalType: \"bytes\" },\n ],\n outputs: [],\n stateMutability: \"nonpayable\",\n },\n {\n name: \"setApprovalForAll\",\n type: \"function\",\n inputs: [\n {\n name: \"operator\",\n type: \"address\",\n internalType: \"address\",\n },\n { name: \"approved\", type: \"bool\", internalType: \"bool\" },\n ],\n outputs: [],\n stateMutability: \"nonpayable\",\n },\n {\n name: \"supportsInterface\",\n type: \"function\",\n inputs: [\n {\n name: \"interfaceId\",\n type: \"bytes4\",\n internalType: \"bytes4\",\n },\n ],\n outputs: [{ name: \"\", type: \"bool\", internalType: \"bool\" }],\n stateMutability: \"view\",\n },\n {\n name: \"symbol\",\n type: \"function\",\n inputs: [],\n outputs: [{ name: \"\", type: \"string\", internalType: \"string\" }],\n stateMutability: \"view\",\n },\n {\n name: \"tokenURI\",\n type: \"function\",\n inputs: [{ name: \"tokenId\", type: \"uint256\", internalType: \"uint256\" }],\n outputs: [{ name: \"\", type: \"string\", internalType: \"string\" }],\n stateMutability: \"view\",\n },\n {\n name: \"transferFrom\",\n type: \"function\",\n inputs: [\n { name: \"from\", type: \"address\", internalType: \"address\" },\n { name: \"to\", type: \"address\", internalType: \"address\" },\n { name: \"tokenId\", type: \"uint256\", internalType: \"uint256\" },\n ],\n outputs: [],\n stateMutability: \"nonpayable\",\n },\n] as const;\n",
|
|
273
|
-
"import type { Address } from \"viem\";\nimport
|
|
273
|
+
"import type { Address } from \"viem\";\nimport Erc721Abi from \"./erc721.abi\";\nimport { ethers } from \"ethers\";\nimport { createCall, type Call, type HexString, type Unwrapable } from \"../../types\";\n\nconst erc721Interface = new ethers.utils.Interface(Erc721Abi);\n\nexport type ApproveErc721Args = Readonly<{\n tokenId: bigint;\n spender: Address;\n token: Address;\n}>;\n\nexport const ApproveErc721CallData = ({ tokenId, spender }: Omit<ApproveErc721Args, \"token\">): HexString => {\n return erc721Interface.encodeFunctionData(\"approve\", [spender, tokenId]) as HexString;\n};\n\nexport const approveErc721Trx = ({ tokenId, spender, token }: ApproveErc721Args): Unwrapable<Call> => {\n return createCall({\n to: token as `0x${string}`,\n data: ApproveErc721CallData({ tokenId, spender }),\n value: 0n,\n operation: 0,\n });\n};\n\nexport type TransferFromErc721Args = Readonly<{\n from: Address;\n to: Address;\n tokenId: bigint;\n token: Address;\n}>;\n\nexport const TransferFromErc721CallData = ({ from, to, tokenId }: Omit<TransferFromErc721Args, \"token\">): HexString => {\n return erc721Interface.encodeFunctionData(\"transferFrom\", [from, to, tokenId]) as HexString;\n};\n\nexport const transferFromErc721Trx = ({ from, to, tokenId, token }: TransferFromErc721Args): Unwrapable<Call> => {\n return createCall({\n to: token as `0x${string}`,\n data: TransferFromErc721CallData({ from, to, tokenId }),\n value: 0n,\n operation: 0,\n });\n};\n\nexport type SafeTransferFromWithDataErc721Args = Readonly<{\n from: Address;\n to: Address;\n tokenId: bigint;\n data: HexString;\n token: Address;\n}>;\n\nexport const SafeTransferFromWithDataErc721CallData = ({\n from,\n to,\n tokenId,\n data,\n}: Omit<SafeTransferFromWithDataErc721Args, \"token\">): HexString => {\n return erc721Interface.encodeFunctionData(\"safeTransferFrom\", [from, to, tokenId, data]) as HexString;\n};\n\nexport const safeTransferFromWithDataErc721Trx = ({\n from,\n to,\n tokenId,\n data,\n token,\n}: SafeTransferFromWithDataErc721Args): Unwrapable<Call> => {\n return createCall({\n to: token as `0x${string}`,\n data: SafeTransferFromWithDataErc721CallData({ from, to, tokenId, data }),\n value: 0n,\n operation: 0,\n });\n};\n\nexport type SafeTransferFromErc721Args = Readonly<{\n from: Address;\n to: Address;\n tokenId: bigint;\n token: Address;\n}>;\n\nexport const SafeTransferFromErc721CallData = ({\n from,\n to,\n tokenId,\n}: Omit<SafeTransferFromErc721Args, \"token\">): HexString => {\n return erc721Interface.encodeFunctionData(\"safeTransferFrom\", [from, to, tokenId]) as HexString;\n};\n\nexport const safeTransferFromErc721Trx = ({\n from,\n to,\n tokenId,\n token,\n}: SafeTransferFromErc721Args): Unwrapable<Call> => {\n return createCall({\n to: token as `0x${string}`,\n data: SafeTransferFromErc721CallData({ from, to, tokenId }),\n value: 0n,\n operation: 0,\n });\n};\n\nexport type SetApprovalForAllErc721Args = Readonly<{\n operator: Address;\n approved: boolean;\n token: Address;\n}>;\n\nexport const SetApprovalForAllErc721CallData = ({\n operator,\n approved,\n}: Omit<SetApprovalForAllErc721Args, \"token\">): HexString => {\n return erc721Interface.encodeFunctionData(\"setApprovalForAll\", [operator, approved]) as HexString;\n};\n\nexport const setApprovalForAllErc721Trx = ({\n operator,\n approved,\n token,\n}: SetApprovalForAllErc721Args): Unwrapable<Call> => {\n return createCall({\n to: token as `0x${string}`,\n data: SetApprovalForAllErc721CallData({ operator, approved }),\n value: 0n,\n operation: 0,\n });\n};\n",
|
|
274
274
|
"import { Wallet } from \"ethers\";\nimport type { WalletClient, Address, Chain } from \"viem\";\nimport type { Call } from \"..\";\n\nexport const executeTrx = ({\n client,\n call,\n sender,\n gas,\n chain,\n}: Readonly<{\n client: WalletClient;\n call: Call;\n sender: Address | Wallet;\n gas: bigint;\n chain?: Chain;\n}>) => {\n const _sender: Address = sender instanceof Wallet ? (sender.address as Address) : sender;\n\n return client.sendTransaction({\n to: call.to,\n value: call.value,\n data: call.data,\n account: _sender,\n chain,\n gas,\n });\n};\n",
|
|
275
275
|
"import type { Address } from \"viem\";\nimport { type Call, type Unwrapable, createCall } from \"../types\";\n\nexport const transferNativeEth = ({ to, amount }: { to: Address; amount: bigint }): Unwrapable<Call> => {\n return createCall({\n to,\n operation: 0,\n value: amount,\n data: \"0x\",\n });\n};\n",
|
|
276
276
|
"import { hexToNumber, type Hex } from \"viem\";\nimport type { Call } from \"../types\";\n\nexport type SimulationEnvironment = Readonly<{\n tenderlyConfig: {\n accountSlug: string;\n projectSlug: string;\n accessKey: string;\n };\n network_id: string;\n from: string;\n trx: Call;\n gas?: number;\n gas_price?: number;\n block_number?: number;\n simulationType?: \"full\" | \"abi\" | \"quick\";\n verbose?: boolean;\n}>;\n\nexport type SimulationResult = Readonly<{\n result: boolean;\n blockNumber: number;\n networkId: string;\n baseFeePerGas?: number;\n gasLimit?: number;\n timestamp?: number;\n gasUsed?: number;\n errorMessage?: string;\n}>;\n\ntype SimulationRequestResponse = Readonly<{\n simulation?: {\n network_id: string;\n block_number: number;\n error_message: string;\n status: boolean;\n block_header: {\n baseFeePerGas: Hex;\n gasLimit: Hex;\n timestamp: Hex;\n gasUsed: Hex;\n };\n };\n}>;\n\nconst simulate = (env: SimulationEnvironment) => {\n const { tenderlyConfig, network_id, from, trx, gas, gas_price, block_number, simulationType, verbose } = env;\n\n const url = `https://api.tenderly.co/api/v1/account/${tenderlyConfig.accountSlug}/project/${tenderlyConfig.projectSlug}/simulate`;\n\n const body = {\n /* Simulation Configuration */\n save: false, // if true simulation is saved and shows up in the dashboard\n save_if_fails: false, // if true, reverting simulations show up in the dashboard\n simulation_type: simulationType || \"full\", // full, abi or quick (full is default)\n network_id, // network to simulate on\n /* Standard EVM Transaction object */\n from,\n to: trx.to,\n input: trx.data,\n gas,\n gas_price,\n value: trx.value.toString(),\n block_number,\n };\n\n const headers = {\n headers: {\n \"content-type\": \"application/JSON\",\n \"X-Access-Key\": tenderlyConfig.accessKey,\n },\n };\n\n if (verbose) {\n console.log(`Simulation Request: body:${JSON.stringify(body)}`);\n }\n\n return fetch(url, {\n method: \"POST\",\n body: JSON.stringify(body),\n headers: headers.headers,\n });\n};\n\nexport const simulateOrThrow = async (env: SimulationEnvironment): Promise<SimulationResult> => {\n const resp = await simulate(env);\n\n if (!resp.ok) {\n // Get the error response body if possible\n let errorBody = \"\";\n try {\n errorBody = await resp.text();\n } catch (e) {\n errorBody = \"Could not read error response body\";\n }\n\n throw new Error(\n `Simulation request failed:\n Status: ${resp.status}\n Status Text: ${resp.statusText}\n URL: ${resp.url}\n Response Body: ${errorBody}\n Network ID: ${env.network_id}\n From Address: ${env.from}\n To Address: ${env.trx.to}`,\n );\n }\n\n const payload: SimulationRequestResponse = (await resp.json()) as SimulationRequestResponse;\n\n // Add validation for expected payload structure\n if (!payload.simulation) {\n throw new Error(`Invalid simulation response: ${JSON.stringify(payload)}`);\n }\n\n const { network_id, block_number, error_message, status, block_header } = payload.simulation;\n\n return {\n result: status,\n blockNumber: block_number,\n networkId: network_id,\n errorMessage: error_message,\n baseFeePerGas: hexToNumber(block_header.baseFeePerGas),\n gasLimit: hexToNumber(block_header.gasLimit),\n timestamp: hexToNumber(block_header.timestamp),\n gasUsed: hexToNumber(block_header.gasUsed),\n };\n};\n"
|
package/package.json
CHANGED