Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to types w/ useCompatAddress #1623

Merged
merged 7 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .changeset/few-monkeys-thank.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
'@penumbra-zone/transport-chrome': minor
'@penumbra-zone/transport-dom': minor
'@penumbra-zone/perspective': minor
'@penumbra-zone/protobuf': minor
'@penumbra-zone/services': minor
'@penumbra-zone/getters': minor
'@penumbra-zone/storage': minor
'@penumbra-zone/client': minor
'@penumbra-zone/query': minor
'@penumbra-zone/react': minor
'@penumbra-zone/types': minor
'@penumbra-zone/wasm': minor
'@repo/ui': minor
---

Updating to v0.80.0 bufbuild types
13 changes: 13 additions & 0 deletions .syncpackrc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@
"pnpmOverrides",
"prod"
],
"semverGroups": [
{
"range": "",
"dependencies": [
"@buf/*",
"@bufbuild/**",
"@connectrpc/**"
],
"packages": [
"**"
]
}
],
"versionGroups": [
{
"label": "Use workspace protocol for local packages",
Expand Down
2 changes: 1 addition & 1 deletion apps/minifront/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"test": "vitest run"
},
"dependencies": {
"@bufbuild/protobuf": "^1.10.0",
"@bufbuild/protobuf": "1.10.0",
"@cosmjs/proto-signing": "^0.32.4",
"@cosmjs/stargate": "^0.32.4",
"@cosmos-kit/core": "^2.13.1",
Expand Down
3 changes: 2 additions & 1 deletion apps/minifront/src/components/ibc/ibc-out/chain-selector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { AllSlices } from '../../../state';
import { Chain } from '@penumbra-labs/registry';
import { useStoreShallow } from '../../../utils/use-store-shallow';
import { useChains } from '../../../state/ibc-out';
import { bech32ChainIds } from '../../../state/shared.ts';

const chainSelectorSelector = (state: AllSlices) => ({
chain: state.ibcOut.chain,
Expand Down Expand Up @@ -44,7 +45,7 @@ export const ChainSelector = () => {
<SelectContent className='left-[-17px]'>
{chains.data?.map((i, index) => (
<SelectItem
disabled={i.chainId === 'noble-1'}
disabled={bech32ChainIds.includes(i.chainId)}
key={index}
value={i.displayName}
className={cn(
Expand Down
23 changes: 9 additions & 14 deletions apps/minifront/src/state/ibc-in/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { currentTimePlusTwoDaysRounded } from '../ibc-out';
import { EncodeObject } from '@cosmjs/proto-signing';
import { MsgTransfer } from 'osmo-query/ibc/applications/transfer/v1/tx';
import { parseRevisionNumberFromChainId } from './parse-revision-number-from-chain-id';
import { bech32ChainIds } from '../shared.ts';

export interface IbcInSlice {
selectedChain?: ChainInfo;
Expand Down Expand Up @@ -64,7 +65,7 @@ export const createIbcInSlice = (): SliceCreator<IbcInSlice> => (set, get) => {
address: undefined,
setAddress: async () => {
const { selectedChain, account } = get().ibcIn;
const penumbraAddress = await getPenumbraAddress(account, selectedChain?.chainName);
const penumbraAddress = await getPenumbraAddress(account, selectedChain?.chainId);
if (penumbraAddress) {
set(state => {
state.ibcIn.address = penumbraAddress;
Expand Down Expand Up @@ -132,25 +133,19 @@ const getExplorerPage = (txHash: string, chainId?: string) => {
return txPage.replace('${txHash}', txHash);
};

/**
* For Noble specifically we need to use a Bech32 encoding rather than Bech32m,
* because Noble currently has a middleware that decodes as Bech32.
* Noble plans to change this at some point in the future but until then we need
* to use a special encoding just for Noble specifically.
*/
const bech32Chains = ['noble', 'nobletestnet'];
Comment on lines -135 to -141
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to shared file

const getCompatibleBech32 = (chainName: string, address: Address): string => {
return bech32Chains.includes(chainName) ? bech32CompatAddress(address) : bech32mAddress(address);
const getCompatibleBech32 = (chainId: string, address: Address): string => {
return bech32ChainIds.includes(chainId) ? bech32CompatAddress(address) : bech32mAddress(address);
};

export const getPenumbraAddress = async (
account: number,
chainName?: string,
chainId?: string,
): Promise<string | undefined> => {
if (!chainName) {
if (!chainId) {
return undefined;
}
const receiverAddress = await getAddrByIndex(account, true);
return getCompatibleBech32(chainName, receiverAddress);
return getCompatibleBech32(chainId, receiverAddress);
};

const estimateFee = async ({
Expand Down Expand Up @@ -201,7 +196,7 @@ async function execute(
throw new Error('Penumbra chain id could not be retrieved');
}

const penumbraAddress = await getPenumbraAddress(account, selectedChain.chainName);
const penumbraAddress = await getPenumbraAddress(account, selectedChain.chainId);
if (!penumbraAddress) {
throw new Error('Penumbra address not available');
}
Expand Down
2 changes: 2 additions & 0 deletions apps/minifront/src/state/ibc-out.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { Channel } from '@buf/cosmos_ibc.bufbuild_es/ibc/core/channel/v1/channel
import { BLOCKS_PER_HOUR } from './constants';
import { createZQuery, ZQueryState } from '@penumbra-zone/zquery';
import { getChains } from '../fetchers/registry';
import { bech32ChainIds } from './shared';

export const { chains, useChains } = createZQuery({
name: 'chains',
Expand Down Expand Up @@ -217,6 +218,7 @@ const getPlanRequest = async ({
timeoutHeight,
timeoutTime,
sourceChannel: chain.channelId,
useCompatAddress: bech32ChainIds.includes(chain.chainId),
},
],
source: addressIndex,
Expand Down
11 changes: 11 additions & 0 deletions apps/minifront/src/state/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@ import { Address } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/k
import { getAddress, getAddressIndex } from '@penumbra-zone/getters/address-view';
import { AbridgedZQueryState } from '@penumbra-zone/zquery/src/types';

/**
* For Noble specifically we need to use a Bech32 encoding rather than Bech32m,
* because Noble currently has a middleware that decodes as Bech32.
* Noble plans to change this at some point in the future but until then we need
* to use a special encoding just for Noble specifically.
*/
export const bech32ChainIds = [
'noble-1', // noble mainnet
'grand-1', // noble testnet
];

export const { stakingTokenMetadata, useStakingTokenMetadata } = createZQuery({
name: 'stakingTokenMetadata',
fetch: getStakingTokenMetadata,
Expand Down
2 changes: 1 addition & 1 deletion apps/node-status/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"preview": "vite preview"
},
"dependencies": {
"@connectrpc/connect-web": "^1.4.0",
"@connectrpc/connect-web": "1.4.0",
"@penumbra-zone/protobuf": "workspace:*",
"@repo/ui": "workspace:*",
"date-fns": "^3.6.0",
Expand Down
15 changes: 7 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"scripts": {
"all-check": "pnpm clean:vitest-mjs && pnpm install && pnpm compile && pnpm lint:strict && pnpm lint:rust && pnpm build && pnpm test && pnpm test:rust",
"all-check:clean": "pnpm clean && pnpm clean:modules && pnpm all-check",
"buf-update": "pnpm update --latest \"@buf/*\" \"@bufbuild/*\" \"@connectrpc/*\" && pnpm syncpack fix-mismatches && pnpm install",
"build": "turbo build",
"clean": "turbo clean",
"clean:modules": "rm -rf node_modules apps/*/node_modules packages/*/node_modules pnpm-lock.yaml",
Expand All @@ -35,14 +34,14 @@
"dependencies": {
"@buf/connectrpc_eliza.bufbuild_es": "1.10.0-20230913231627-233fca715f49.1",
"@buf/connectrpc_eliza.connectrpc_es": "1.4.0-20230913231627-233fca715f49.3",
"@buf/cosmos_ibc.bufbuild_es": "1.10.0-20240703151202-d7191877c701.1",
"@buf/cosmos_ibc.connectrpc_es": "1.4.0-20240703151202-d7191877c701.3",
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.10.0-20240703080008-312294d02bf9.1",
"@buf/penumbra-zone_penumbra.connectrpc_es": "1.4.0-20240703080008-312294d02bf9.3",
"@buf/cosmos_ibc.bufbuild_es": "1.10.0-20230913112312-7ab44ae956a0.1",
"@buf/cosmos_ibc.connectrpc_es": "1.4.0-20230913112312-7ab44ae956a0.3",
Comment on lines +37 to +38
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these two moved backwards, because i noticed it's what core uses https://github.com/penumbra-zone/penumbra/blob/main/proto/buf.lock

"@buf/penumbra-zone_penumbra.bufbuild_es": "1.10.0-20240804013626-f19a2ee01838.1",
"@buf/penumbra-zone_penumbra.connectrpc_es": "1.4.0-20240804013626-f19a2ee01838.3",
"@buf/tendermint_tendermint.bufbuild_es": "1.10.0-20231117195010-33ed361a9051.1",
"@bufbuild/protobuf": "^1.10.0",
"@connectrpc/connect": "^1.4.0",
"@connectrpc/connect-web": "^1.4.0"
"@bufbuild/protobuf": "1.10.0",
"@connectrpc/connect": "1.4.0",
"@connectrpc/connect-web": "1.4.0"
},
"devDependencies": {
"@changesets/cli": "^2.27.3",
Expand Down
4 changes: 2 additions & 2 deletions packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@
}
},
"devDependencies": {
"@connectrpc/connect": "^1.4.0",
"@connectrpc/connect": "1.4.0",
"@penumbra-zone/protobuf": "workspace:*",
"@penumbra-zone/transport-dom": "workspace:*",
"@types/chrome": "^0.0.268"
},
"peerDependencies": {
"@connectrpc/connect": "^1.4.0",
"@connectrpc/connect": "1.4.0",
"@penumbra-zone/protobuf": "workspace:*",
"@penumbra-zone/transport-dom": "workspace:*"
}
Expand Down
8 changes: 4 additions & 4 deletions packages/getters/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@
}
},
"devDependencies": {
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.10.0-20240703080008-312294d02bf9.1",
"@bufbuild/protobuf": "^1.10.0",
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.10.0-20240804013626-f19a2ee01838.1",
"@bufbuild/protobuf": "1.10.0",
"@penumbra-zone/bech32m": "workspace:*",
"@penumbra-zone/protobuf": "workspace:*"
},
"peerDependencies": {
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.10.0-20240703080008-312294d02bf9.1",
"@bufbuild/protobuf": "^1.10.0",
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.10.0-20240804013626-f19a2ee01838.1",
"@bufbuild/protobuf": "1.10.0",
"@penumbra-zone/bech32m": "workspace:*",
"@penumbra-zone/protobuf": "workspace:*"
}
Expand Down
4 changes: 2 additions & 2 deletions packages/perspective/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@
}
},
"devDependencies": {
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.10.0-20240703080008-312294d02bf9.1",
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.10.0-20240804013626-f19a2ee01838.1",
"@penumbra-zone/bech32m": "workspace:*",
"@penumbra-zone/getters": "workspace:*",
"@penumbra-zone/wasm": "workspace:*"
},
"peerDependencies": {
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.10.0-20240703080008-312294d02bf9.1",
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.10.0-20240804013626-f19a2ee01838.1",
"@penumbra-zone/bech32m": "workspace:*",
"@penumbra-zone/getters": "workspace:*",
"@penumbra-zone/wasm": "workspace:*"
Expand Down
20 changes: 10 additions & 10 deletions packages/protobuf/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@
}
},
"devDependencies": {
"@buf/cosmos_ibc.bufbuild_es": "1.10.0-20240703151202-d7191877c701.1",
"@buf/cosmos_ibc.connectrpc_es": "1.4.0-20240703151202-d7191877c701.3",
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.10.0-20240703080008-312294d02bf9.1",
"@buf/penumbra-zone_penumbra.connectrpc_es": "1.4.0-20240703080008-312294d02bf9.3",
"@bufbuild/protobuf": "^1.10.0"
"@buf/cosmos_ibc.bufbuild_es": "1.10.0-20230913112312-7ab44ae956a0.1",
"@buf/cosmos_ibc.connectrpc_es": "1.4.0-20230913112312-7ab44ae956a0.3",
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.10.0-20240804013626-f19a2ee01838.1",
"@buf/penumbra-zone_penumbra.connectrpc_es": "1.4.0-20240804013626-f19a2ee01838.3",
"@bufbuild/protobuf": "1.10.0"
},
"peerDependencies": {
"@buf/cosmos_ibc.bufbuild_es": "1.10.0-20240703151202-d7191877c701.1",
"@buf/cosmos_ibc.connectrpc_es": "1.4.0-20240703151202-d7191877c701.3",
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.10.0-20240703080008-312294d02bf9.1",
"@buf/penumbra-zone_penumbra.connectrpc_es": "1.4.0-20240703080008-312294d02bf9.3",
"@bufbuild/protobuf": "^1.10.0"
"@buf/cosmos_ibc.bufbuild_es": "1.10.0-20230913112312-7ab44ae956a0.1",
"@buf/cosmos_ibc.connectrpc_es": "1.4.0-20230913112312-7ab44ae956a0.3",
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.10.0-20240804013626-f19a2ee01838.1",
"@buf/penumbra-zone_penumbra.connectrpc_es": "1.4.0-20240804013626-f19a2ee01838.3",
"@bufbuild/protobuf": "1.10.0"
}
}
14 changes: 7 additions & 7 deletions packages/query/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@
}
},
"dependencies": {
"@bufbuild/protobuf": "^1.10.0",
"@connectrpc/connect": "^1.4.0",
"@connectrpc/connect-web": "^1.4.0",
"@bufbuild/protobuf": "1.10.0",
"@connectrpc/connect": "1.4.0",
"@connectrpc/connect-web": "1.4.0",
"exponential-backoff": "^3.1.1"
},
"devDependencies": {
"@buf/cosmos_ibc.bufbuild_es": "1.10.0-20240703151202-d7191877c701.1",
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.10.0-20240703080008-312294d02bf9.1",
"@buf/cosmos_ibc.bufbuild_es": "1.10.0-20230913112312-7ab44ae956a0.1",
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.10.0-20240804013626-f19a2ee01838.1",
"@penumbra-zone/bech32m": "workspace:*",
"@penumbra-zone/crypto-web": "workspace:*",
"@penumbra-zone/getters": "workspace:*",
Expand All @@ -47,8 +47,8 @@
"@penumbra-zone/wasm": "workspace:*"
},
"peerDependencies": {
"@buf/cosmos_ibc.bufbuild_es": "1.10.0-20240703151202-d7191877c701.1",
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.10.0-20240703080008-312294d02bf9.1",
"@buf/cosmos_ibc.bufbuild_es": "1.10.0-20230913112312-7ab44ae956a0.1",
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.10.0-20240804013626-f19a2ee01838.1",
"@penumbra-zone/bech32m": "workspace:*",
"@penumbra-zone/crypto-web": "workspace:*",
"@penumbra-zone/getters": "workspace:*",
Expand Down
6 changes: 3 additions & 3 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@
"@penumbra-zone/transport-dom": "workspace:*"
},
"devDependencies": {
"@connectrpc/connect": "^1.4.0",
"@connectrpc/connect": "1.4.0",
"@types/react": "^18.3.2",
"react": "^18.3.1"
},
"peerDependencies": {
"@bufbuild/protobuf": "^1.10.0",
"@connectrpc/connect": "^1.4.0",
"@bufbuild/protobuf": "1.10.0",
"@connectrpc/connect": "1.4.0",
"react": "^18.3.1"
}
}
12 changes: 6 additions & 6 deletions packages/services/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
}
},
"devDependencies": {
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.10.0-20240703080008-312294d02bf9.1",
"@bufbuild/protobuf": "^1.10.0",
"@connectrpc/connect": "^1.4.0",
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.10.0-20240804013626-f19a2ee01838.1",
"@bufbuild/protobuf": "1.10.0",
"@connectrpc/connect": "1.4.0",
"@penumbra-zone/bech32m": "workspace:*",
"@penumbra-zone/crypto-web": "workspace:*",
"@penumbra-zone/getters": "workspace:*",
Expand All @@ -51,9 +51,9 @@
"@types/chrome": "^0.0.268"
},
"peerDependencies": {
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.10.0-20240703080008-312294d02bf9.1",
"@bufbuild/protobuf": "^1.10.0",
"@connectrpc/connect": "^1.4.0",
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.10.0-20240804013626-f19a2ee01838.1",
"@bufbuild/protobuf": "1.10.0",
"@connectrpc/connect": "1.4.0",
"@penumbra-zone/bech32m": "workspace:*",
"@penumbra-zone/crypto-web": "workspace:*",
"@penumbra-zone/getters": "workspace:*",
Expand Down
8 changes: 4 additions & 4 deletions packages/storage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
}
},
"dependencies": {
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.10.0-20240703080008-312294d02bf9.1",
"@bufbuild/protobuf": "^1.10.0",
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.10.0-20240804013626-f19a2ee01838.1",
"@bufbuild/protobuf": "1.10.0",
"@penumbra-labs/registry": "11.0.0",
"@penumbra-zone/bech32m": "workspace:*",
"@penumbra-zone/getters": "workspace:*",
Expand All @@ -44,8 +44,8 @@
"fetch-mock": "^10.0.7"
},
"peerDependencies": {
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.10.0-20240703080008-312294d02bf9.1",
"@bufbuild/protobuf": "^1.10.0",
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.10.0-20240804013626-f19a2ee01838.1",
"@bufbuild/protobuf": "1.10.0",
"@penumbra-labs/registry": "11.0.0",
"@penumbra-zone/bech32m": "workspace:*",
"@penumbra-zone/getters": "workspace:*",
Expand Down
8 changes: 4 additions & 4 deletions packages/transport-chrome/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@
}
},
"devDependencies": {
"@bufbuild/protobuf": "^1.10.0",
"@connectrpc/connect": "^1.4.0",
"@bufbuild/protobuf": "1.10.0",
"@connectrpc/connect": "1.4.0",
"@penumbra-zone/transport-dom": "workspace:*",
"@types/chrome": "^0.0.268"
},
"peerDependencies": {
"@bufbuild/protobuf": "^1.10.0",
"@connectrpc/connect": "^1.4.0",
"@bufbuild/protobuf": "1.10.0",
"@connectrpc/connect": "1.4.0",
"@penumbra-zone/transport-dom": "workspace:*"
}
}
4 changes: 2 additions & 2 deletions packages/transport-dom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
}
},
"dependencies": {
"@bufbuild/protobuf": "^1.10.0",
"@connectrpc/connect": "^1.4.0"
"@bufbuild/protobuf": "1.10.0",
"@connectrpc/connect": "1.4.0"
}
}
Loading
Loading