From 31cdbe2b731255deed0f911c9f2312c17cc5af8c Mon Sep 17 00:00:00 2001 From: samsiegart Date: Tue, 27 May 2025 22:35:39 -0700 Subject: [PATCH 1/3] feat!: ist winddown --- package.json | 4 +- src/components/ChainConnection.tsx | 2 +- src/components/ProvisionSmartWalletDialog.tsx | 42 +- yarn.lock | 476 +++++++++++++++--- 4 files changed, 435 insertions(+), 89 deletions(-) diff --git a/package.json b/package.json index d85e6e9..d0156fd 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "type": "module", "scripts": { "dev": "vite", - "build": "tsc && vite build", + "build": "vite build", "preview": "vite preview", "lint": "eslint src", "format": "prettier --write . && yarn lint --fix", @@ -25,7 +25,7 @@ "@agoric/smart-wallet": "^0.5.3", "@agoric/synpress": "^3.8.5-beta.0", "@agoric/ui-components": "^0.9.0", - "@agoric/web-components": "^0.15.0", + "@agoric/web-components": "^0.17.0", "@agoric/zoe": "^0.26.2", "@endo/eventual-send": "^1.1.2", "@headlessui/react": "^1.6.6", diff --git a/src/components/ChainConnection.tsx b/src/components/ChainConnection.tsx index 9e03f95..1ba09aa 100644 --- a/src/components/ChainConnection.tsx +++ b/src/components/ChainConnection.tsx @@ -4,7 +4,7 @@ import { toast } from 'react-toastify'; import { Oval } from 'react-loader-spinner'; import { makeAgoricWalletConnection, - AgoricKeplrConnectionErrors as Errors, + Errors, suggestChain, } from '@agoric/web-components'; import { diff --git a/src/components/ProvisionSmartWalletDialog.tsx b/src/components/ProvisionSmartWalletDialog.tsx index 25194e1..1a21b5a 100644 --- a/src/components/ProvisionSmartWalletDialog.tsx +++ b/src/components/ProvisionSmartWalletDialog.tsx @@ -9,6 +9,7 @@ const useSmartWalletFeeQuery = (rpc?: string) => { const [smartWalletFee, setFee] = useState<{ fee: bigint; feeUnit: bigint; + feeUnitName?: string; } | null>(null); const [error, setError] = useState(null); @@ -24,8 +25,13 @@ const useSmartWalletFeeQuery = (rpc?: string) => { const feeUnit = params.params.beansPerUnit.find( ({ key }: { key: string }) => key === 'feeUnit' )?.beans; + const feeUnitName = params.params?.feeUnitPrice[0]?.denom; assert(feeUnit); - setFee({ fee: BigInt(beansPerSmartWallet), feeUnit: BigInt(feeUnit) }); + setFee({ + fee: BigInt(beansPerSmartWallet), + feeUnit: BigInt(feeUnit), + feeUnitName, + }); } catch (e) { setError(e as Error); } @@ -54,12 +60,20 @@ const ProvisionSmartWalletNoticeDialog = ({ const { smartWalletFee, error: _smartWalletFeeError } = useSmartWalletFeeQuery(rpc); + const feeUnitNameForDisplay = + smartWalletFee?.feeUnitName === 'uist' ? 'IST' : 'BLD'; const smartWalletFeeForDisplay = smartWalletFee - ? String(smartWalletFee.fee / smartWalletFee.feeUnit) + ' IST' + ? String(smartWalletFee.fee / smartWalletFee.feeUnit) + + ' ' + + feeUnitNameForDisplay : null; const purses = useAtomValue(pursesAtom); const istPurse = purses?.find(p => p.brandPetname === 'IST'); + const bldPurse = purses?.find(p => p.brandPetname === 'BLD'); + const purseToDisplay = + smartWalletFee?.feeUnitName === 'uist' ? istPurse : bldPurse; + const { displayAmount, getDecimalPlaces } = useAtomValue(displayFunctionsAtom) ?? {}; @@ -73,37 +87,41 @@ const ProvisionSmartWalletNoticeDialog = ({ "Proceed" to provision wallet and submit transaction.
- {istPurse && displayAmount && ( + {purseToDisplay && displayAmount && (
- IST Balance: {displayAmount(istPurse.currentAmount)} + {feeUnitNameForDisplay} Balance:{' '} + {displayAmount(purseToDisplay.currentAmount)}
)} - {istPurse && ( + {purseToDisplay && ( )}
); - const istDecimals = - istPurse && getDecimalPlaces && getDecimalPlaces(istPurse.brand); + const decimalsToDisplay = + purseToDisplay && + getDecimalPlaces && + getDecimalPlaces(purseToDisplay.brand); // "feeUnit" is observed to be 1000000000000n, so when "fee" is 1000000000000n // that means 1 IST (after dividing "fee" by "feeUnit"). To convert to uIST, // we then multiply by 10^6. const denominatedSmartWalletFee = - istDecimals && + decimalsToDisplay && smartWalletFee && - (smartWalletFee.fee / smartWalletFee.feeUnit) * 10n ** BigInt(istDecimals); + (smartWalletFee.fee / smartWalletFee.feeUnit) * + 10n ** BigInt(decimalsToDisplay); const hasRequiredFee = denominatedSmartWalletFee && - istPurse !== undefined && - istPurse.currentAmount.value >= denominatedSmartWalletFee; + purseToDisplay !== undefined && + purseToDisplay.currentAmount.value >= denominatedSmartWalletFee; return ( Date: Tue, 27 May 2025 23:02:30 -0700 Subject: [PATCH 2/3] test: compat with ist winddown --- tests/e2e/specs/swap-tokens.spec.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/e2e/specs/swap-tokens.spec.js b/tests/e2e/specs/swap-tokens.spec.js index 4ae085c..73e63aa 100644 --- a/tests/e2e/specs/swap-tokens.spec.js +++ b/tests/e2e/specs/swap-tokens.spec.js @@ -87,6 +87,8 @@ describe('Swap Tokens Tests', () => { expect(amount).to.be.oneOf([ limitFloat(istBalance - amountToSwap - provisionFee), limitFloat(istBalance - amountToSwap - provisionFee - transactionFee), + limitFloat(istBalance - amountToSwap), // If provision fee in IST is removed + limitFloat(istBalance - amountToSwap - transactionFee), ]) ); }); From 77e9ee8dc256b845e82b10cb22551b58b175e775 Mon Sep 17 00:00:00 2001 From: samsiegart Date: Wed, 28 May 2025 10:31:16 -0700 Subject: [PATCH 3/3] chore: document tsc issue --- package.json | 1 + src/components/ProvisionSmartWalletDialog.tsx | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d0156fd..9c3d523 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "build": "vite build", "preview": "vite preview", "lint": "eslint src", + "lint:types": "echo 'XXX tsc is not working, even though vite build is successful' && tsc --noEmit", "format": "prettier --write . && yarn lint --fix", "test": "vitest", "coverage": "vitest run --coverage", diff --git a/src/components/ProvisionSmartWalletDialog.tsx b/src/components/ProvisionSmartWalletDialog.tsx index 1a21b5a..e5401ac 100644 --- a/src/components/ProvisionSmartWalletDialog.tsx +++ b/src/components/ProvisionSmartWalletDialog.tsx @@ -9,7 +9,7 @@ const useSmartWalletFeeQuery = (rpc?: string) => { const [smartWalletFee, setFee] = useState<{ fee: bigint; feeUnit: bigint; - feeUnitName?: string; + feeUnitName: string; } | null>(null); const [error, setError] = useState(null); @@ -26,7 +26,10 @@ const useSmartWalletFeeQuery = (rpc?: string) => { ({ key }: { key: string }) => key === 'feeUnit' )?.beans; const feeUnitName = params.params?.feeUnitPrice[0]?.denom; - assert(feeUnit); + assert( + beansPerSmartWallet && feeUnit && feeUnitName, + 'missing fee params' + ); setFee({ fee: BigInt(beansPerSmartWallet), feeUnit: BigInt(feeUnit),