diff --git a/package.json b/package.json index ea13416..5771743 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "@0xsequence/design-system": "^1.0.13", "@0xsequence/indexer": "^1.9.8", "@0xsequence/network": "^1.9.8", - "@0xsequence/waas": "^1.9.8", + "@0xsequence/waas": "^1.9.16", "@react-oauth/google": "^0.11.1", "@vanilla-extract/css": "^1.12.0", "axios": "^1.6.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1defad0..9052436 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -15,8 +15,8 @@ dependencies: specifier: ^1.9.8 version: 1.9.8(ethers@5.7.2) '@0xsequence/waas': - specifier: ^1.9.8 - version: 1.9.8(ethers@5.7.2) + specifier: ^1.9.16 + version: 1.9.16(ethers@5.7.2) '@react-oauth/google': specifier: ^0.11.1 version: 0.11.1(react-dom@18.2.0)(react@18.2.0) @@ -88,10 +88,23 @@ devDependencies: packages: + /@0xsequence/abi@1.9.16: + resolution: {integrity: sha512-5E9AY/tBrOrHQAmgXQXYIS3DPeOAr1FaE5MsiG5P5XtRg8cLYsV07yhYCB2s7qxpckGY4zpKT6N94qWrBa/pDA==} + dev: false + /@0xsequence/abi@1.9.8: resolution: {integrity: sha512-im2xWjWb3FIj5veMG2zgABhPTVBn5QOdCZQ9+v/oEHMe8pMnCPsQdniGlgiAdG4qH7vO25QZnuOM6P2OB/phVw==} dev: false + /@0xsequence/core@1.9.16(ethers@5.7.2): + resolution: {integrity: sha512-loxofSmJ7y7261aEpdSlHy8aB5XA1WSJriRW7cWURU8aO6szPis82E0fNJastbVU2bE3t4xqfksn50Y4njb42A==} + peerDependencies: + ethers: '>=5.5' + dependencies: + '@0xsequence/abi': 1.9.16 + ethers: 5.7.2 + dev: false + /@0xsequence/core@1.9.8(ethers@5.7.2): resolution: {integrity: sha512-ZTOji/FjPQGmfxiTpO80BimwCtTCevAxqcgAl4yl978dnWfbHJNu8dTnWLOU9IGRNFpv94Sb02QRtKNaBve78w==} peerDependencies: @@ -129,10 +142,26 @@ packages: - '@types/react-dom' dev: false + /@0xsequence/indexer@1.9.16: + resolution: {integrity: sha512-7O3OyJl2tWZWwulCrN8e4/8xX0JQXMADSXtEYZCMOcFQQQ05ma/8qtMQafh+8Q1IP41FuOp/4GV2K2N+nw0p+Q==} + dev: false + /@0xsequence/indexer@1.9.8: resolution: {integrity: sha512-E4meNL7nROkCek7nEnYgp8mRRIbFVXguJUn5ni8g+dhXvKv6bsU5R0nL5n87n98jdcosXZ4rwrHdG1doWFMb4A==} dev: false + /@0xsequence/network@1.9.16(ethers@5.7.2): + resolution: {integrity: sha512-MW557qC4ObhDl2bOhjzp3lv9YaHEadl8xG88Poz9GZW8J9+IwhQs44V4l5Cus5iSAYoFAHEwlSGP5ZCGBYOvJg==} + peerDependencies: + ethers: '>=5.5 < 6' + dependencies: + '@0xsequence/core': 1.9.16(ethers@5.7.2) + '@0xsequence/indexer': 1.9.16 + '@0xsequence/relayer': 1.9.16(ethers@5.7.2) + '@0xsequence/utils': 1.9.16(ethers@5.7.2) + ethers: 5.7.2 + dev: false + /@0xsequence/network@1.9.8(ethers@5.7.2): resolution: {integrity: sha512-BPUiMD+Ug4ksWPer53b37rGZzg5oujlhUpS69GAH9pHJB3JqR16hCYsh3OLk2ViM+pFK6W8zFnVMPdteFwt0oQ==} peerDependencies: @@ -145,6 +174,17 @@ packages: ethers: 5.7.2 dev: false + /@0xsequence/relayer@1.9.16(ethers@5.7.2): + resolution: {integrity: sha512-dnwzmsrh4vlLryO8gAYVgrLcm4NU/SKqifjgrKFkdsn+YoijUUvQaMrTmSnHuBf8PaTTbIXarYtTStopgGpVww==} + peerDependencies: + ethers: '>=5.5 < 6' + dependencies: + '@0xsequence/abi': 1.9.16 + '@0xsequence/core': 1.9.16(ethers@5.7.2) + '@0xsequence/utils': 1.9.16(ethers@5.7.2) + ethers: 5.7.2 + dev: false + /@0xsequence/relayer@1.9.8(ethers@5.7.2): resolution: {integrity: sha512-tsOxo1ev4DxbGDMu6piSLNtyHKPv7Nxh3U/VNKkCVqhoQNkyoQ9mQa+MrrPx0XHpLs1mMuMF37EaZUHKq0GZ2A==} peerDependencies: @@ -156,6 +196,15 @@ packages: ethers: 5.7.2 dev: false + /@0xsequence/utils@1.9.16(ethers@5.7.2): + resolution: {integrity: sha512-ceG7CFhenntsdqH26ipN/Ff9cTC6XtWgSPzV0LtEOAIqxKUcoaVTbz3ztlzsLuElZOsGlVCkG49pxnR3m3+bxA==} + peerDependencies: + ethers: '>=5.5 < 6' + dependencies: + ethers: 5.7.2 + js-base64: 3.7.7 + dev: false + /@0xsequence/utils@1.9.8(ethers@5.7.2): resolution: {integrity: sha512-ydf9h00xVuy4qpr9GNxc3wnnvBAPqdV4+21FGlAd2uQ8vM9e0PI3uIc4G3AFTdLi8aMuIKRv3tj7EqlGQzJeHg==} peerDependencies: @@ -165,12 +214,12 @@ packages: js-base64: 3.7.7 dev: false - /@0xsequence/waas@1.9.8(ethers@5.7.2): - resolution: {integrity: sha512-HPeMuCKLpLcZlPGU/4PmYkFrZtdy573q8DXzQtxVnRsvFMIp87dvE4D5gskg1kSUfz2qYJxyQp5mcsazhBMILQ==} + /@0xsequence/waas@1.9.16(ethers@5.7.2): + resolution: {integrity: sha512-Hd9LWamxmQ1CGI0+rwVFHKgPrRcGrtD+NyiyMpCfQpSZFu8wbpkVltN1l/xYRleLUMWCWS+XoXVyCO0DS4gVNw==} peerDependencies: ethers: '>=5.5' dependencies: - '@0xsequence/network': 1.9.8(ethers@5.7.2) + '@0xsequence/network': 1.9.16(ethers@5.7.2) '@aws-sdk/client-cognito-identity-provider': 3.533.0 ethers: 5.7.2 idb: 7.1.1 diff --git a/src/components/views/CallContractsView.tsx b/src/components/views/CallContractsView.tsx index 629999f..cc3c960 100644 --- a/src/components/views/CallContractsView.tsx +++ b/src/components/views/CallContractsView.tsx @@ -2,7 +2,13 @@ import { Box, Text, Button, TextInput, Spinner } from "@0xsequence/design-system" import { SetStateAction, useState } from "react" import { sequence } from "../../main" -import { isSentTransactionResponse, Network } from "@0xsequence/waas" +import { + delayedEncode, + FeeOption, + isSentTransactionResponse, + Network, +} from "@0xsequence/waas" +import { checkTransactionFeeOptions, TransactionFeeOptions } from "./TransactionFeeOptions.tsx"; export function CallContractsView(props: {network?: Network}) { const [contractAddress, setContractAddress] = useState('') @@ -13,6 +19,35 @@ export function CallContractsView(props: {network?: Network}) { const [inProgress, setInProgress] = useState(false) const [sendTransactionError, setSendTransactionError] = useState() + const [feeOptions, setFeeOptions] = useState() + const [feeOption, setFeeOption] = useState() + const [feeQuote, setFeeQuote] = useState() + const [feeSponsored, setFeeSponsored] = useState(false) + + const checkFeeOptions = async () => { + const resp = await checkTransactionFeeOptions({ + transactions: [delayedEncode({ + to: contractAddress, + abi: contractAbi, + func: contractMethod, + args: JSON.parse(contractMethodArgs), + value: "0" + })], + network: props.network + }) + + if (resp.feeQuote && resp.feeOptions) { + setFeeOptions(resp.feeOptions) + setFeeQuote(resp.feeQuote) + + console.log('feeOptions', resp) + return + } + + setFeeSponsored(true) + console.log('tx sponsored') + } + const callContract = async () => { try { setSendTransactionError(undefined) @@ -24,7 +59,9 @@ export function CallContractsView(props: {network?: Network}) { abi: contractAbi, func: contractMethod, args: JSON.parse(contractMethodArgs), - value: 0 + value: 0, + transactionsFeeOption: feeOption, + transactionsFeeQuote: feeQuote }) if (isSentTransactionResponse(tx)) { @@ -94,23 +131,47 @@ export function CallContractsView(props: {network?: Network}) { data-id="nativeTokenSendAmount" /> + + + { feeSponsored && ( + + + Fee options: Tx Sponsored! + + + )} + {sendTransactionError && ( Transaction failed: {sendTransactionError} )} {!inProgress ? ( -