Skip to content

Commit

Permalink
Update web code to handle latest auction-related Protobuf changes (#1022
Browse files Browse the repository at this point in the history
)

* Update packages

* Update crates

* Handle the new views in viewActionPlan()

* Rename file

* Rename Dutch auction schedule view component, and update it to work with the View pb

* Save metadata for auction NFTs during the planner stage

* Make metadata calls concurrent

* Use metadata from the view to render values correctly
  • Loading branch information
jessepinho authored May 2, 2024
1 parent e68ef74 commit aa49e49
Show file tree
Hide file tree
Showing 27 changed files with 378 additions and 200 deletions.
4 changes: 2 additions & 2 deletions apps/extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
},
"dependencies": {
"@buf/cosmos_ibc.connectrpc_es": "1.4.0-20240327103030-e2006674271c.2",
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.9.0-20240429125510-24b08e70bbc2.1",
"@buf/penumbra-zone_penumbra.connectrpc_es": "1.4.0-20240429125510-24b08e70bbc2.2",
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.9.0-20240501193854-ea3cc743390d.1",
"@buf/penumbra-zone_penumbra.connectrpc_es": "1.4.0-20240501193854-ea3cc743390d.2",
"@bufbuild/protobuf": "^1.9.0",
"@connectrpc/connect": "^1.4.0",
"@connectrpc/connect-web": "^1.4.0",
Expand Down
4 changes: 2 additions & 2 deletions apps/minifront/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"dependencies": {
"@buf/cosmos_ibc.bufbuild_es": "1.9.0-20240327103030-e2006674271c.1",
"@buf/cosmos_ibc.connectrpc_es": "1.4.0-20240327103030-e2006674271c.2",
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.9.0-20240429125510-24b08e70bbc2.1",
"@buf/penumbra-zone_penumbra.connectrpc_es": "1.4.0-20240429125510-24b08e70bbc2.2",
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.9.0-20240501193854-ea3cc743390d.1",
"@buf/penumbra-zone_penumbra.connectrpc_es": "1.4.0-20240501193854-ea3cc743390d.2",
"@bufbuild/protobuf": "^1.9.0",
"@cosmjs/proto-signing": "^0.32.3",
"@cosmjs/stargate": "^0.32.3",
Expand Down
2 changes: 1 addition & 1 deletion apps/minifront/src/components/tx-details/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Card } from '@penumbra-zone/ui/components/ui/card';
import { FadeTransition } from '@penumbra-zone/ui/components/ui/fade-transition';
import { TxViewer } from './hash-parser';
import { TxViewer } from './tx-viewer';
import { EduInfoCard } from '../shared/edu-panels/edu-info-card';
import { EduPanel } from '../shared/edu-panels/content';
import { LoaderFunction, useLoaderData, useRouteError } from 'react-router-dom';
Expand Down
4 changes: 2 additions & 2 deletions apps/node-status/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"preview": "vite preview"
},
"dependencies": {
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.9.0-20240429125510-24b08e70bbc2.1",
"@buf/penumbra-zone_penumbra.connectrpc_es": "1.4.0-20240429125510-24b08e70bbc2.2",
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.9.0-20240501193854-ea3cc743390d.1",
"@buf/penumbra-zone_penumbra.connectrpc_es": "1.4.0-20240501193854-ea3cc743390d.2",
"@buf/tendermint_tendermint.bufbuild_es": "1.9.0-20231117195010-33ed361a9051.1",
"@connectrpc/connect-web": "^1.4.0",
"@penumbra-zone/crypto-web": "workspace:*",
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
"dependencies": {
"@buf/cosmos_ibc.bufbuild_es": "1.9.0-20240327103030-e2006674271c.1",
"@buf/cosmos_ibc.connectrpc_es": "1.4.0-20240327103030-e2006674271c.2",
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.9.0-20240429125510-24b08e70bbc2.1",
"@buf/penumbra-zone_penumbra.connectrpc_es": "1.4.0-20240429125510-24b08e70bbc2.2",
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.9.0-20240501193854-ea3cc743390d.1",
"@buf/penumbra-zone_penumbra.connectrpc_es": "1.4.0-20240501193854-ea3cc743390d.2",
"@buf/tendermint_tendermint.bufbuild_es": "1.9.0-20231117195010-33ed361a9051.1",
"@bufbuild/protobuf": "^1.9.0",
"@connectrpc/connect": "^1.4.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/bech32m/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
"bech32": "^2.0.0"
},
"devDependencies": {
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.9.0-20240429125510-24b08e70bbc2.1"
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.9.0-20240501193854-ea3cc743390d.1"
},
"peerDependencies": {
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.9.0-20240429125510-24b08e70bbc2.1"
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.9.0-20240501193854-ea3cc743390d.1"
}
}
8 changes: 8 additions & 0 deletions packages/constants/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,13 @@
"types": "./dist/index.d.ts"
}
}
},
"devDependencies": {
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.9.0-20240501193854-ea3cc743390d.1",
"@bufbuild/protobuf": "^1.9.0"
},
"peerDependencies": {
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.9.0-20240501193854-ea3cc743390d.1",
"@bufbuild/protobuf": "^1.9.0"
}
}
4 changes: 2 additions & 2 deletions packages/getters/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
"@penumbra-zone/constants": "workspace:*"
},
"devDependencies": {
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.9.0-20240429125510-24b08e70bbc2.1",
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.9.0-20240501193854-ea3cc743390d.1",
"@bufbuild/protobuf": "^1.9.0"
},
"peerDependencies": {
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.9.0-20240429125510-24b08e70bbc2.1",
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.9.0-20240501193854-ea3cc743390d.1",
"@bufbuild/protobuf": "^1.9.0"
}
}
10 changes: 10 additions & 0 deletions packages/getters/src/dutch-auction-description.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { DutchAuctionDescription } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/component/auction/v1alpha1/auction_pb';
import { createGetter } from './utils/create-getter';

export const getInputAssetId = createGetter(
(dutchAuctionDescription?: DutchAuctionDescription) => dutchAuctionDescription?.input?.assetId,
);

export const getOutputAssetId = createGetter(
(dutchAuctionDescription?: DutchAuctionDescription) => dutchAuctionDescription?.outputId,
);
5 changes: 3 additions & 2 deletions packages/perspective/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@
},
"dependencies": {
"@penumbra-zone/bech32m": "workspace:*",
"@penumbra-zone/getters": "workspace:*",
"@penumbra-zone/types": "workspace:*",
"@penumbra-zone/wasm": "workspace:*"
},
"devDependencies": {
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.9.0-20240429125510-24b08e70bbc2.1"
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.9.0-20240501193854-ea3cc743390d.1"
},
"peerDependencies": {
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.9.0-20240429125510-24b08e70bbc2.1"
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.9.0-20240501193854-ea3cc743390d.1"
}
}
73 changes: 73 additions & 0 deletions packages/perspective/plan/view-action-plan.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ import {
} from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/component/stake/v1/stake_pb';
import { addressFromBech32m } from '@penumbra-zone/bech32m/penumbra';
import { fullViewingKeyFromBech32m } from '@penumbra-zone/bech32m/penumbrafullviewingkey';
import {
ActionDutchAuctionSchedule,
ActionDutchAuctionWithdraw,
AuctionId,
} from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/component/auction/v1alpha1/auction_pb';

vi.mock('@penumbra-zone/wasm/auction', () => ({
getAuctionId: () => new AuctionId({ inner: new Uint8Array([0, 1, 2, 3]) }),
}));

describe('viewActionPlan()', () => {
const addressAsBech32 =
Expand Down Expand Up @@ -508,6 +517,70 @@ describe('viewActionPlan()', () => {
});
});

describe('`actionDutchAuctionSchedule` action', () => {
test('returns an action view with the appropriate view', async () => {
const schedule = new ActionDutchAuctionSchedule({
description: {
input: {
amount: { hi: 0n, lo: 1n },
assetId: {},
},
outputId: {},
},
});
const actionPlan = new ActionPlan({
action: {
case: 'actionDutchAuctionSchedule',
value: schedule,
},
});

const actionView = viewActionPlan(metadataByAssetId, mockFvk)(actionPlan);

await expect(actionView).resolves.toEqual(
new ActionView({
actionView: {
case: 'actionDutchAuctionSchedule',
value: {
action: schedule,
auctionId: { inner: new Uint8Array([0, 1, 2, 3]) },
inputMetadata: metadata,
outputMetadata: metadata,
},
},
}),
);
});
});

describe('`actionDutchAuctionWithdraw` action', () => {
test('returns an action view with the action as-is', async () => {
const withdraw = new ActionDutchAuctionWithdraw({
auctionId: {},
seq: 0n,
});
const actionPlan = new ActionPlan({
action: {
case: 'actionDutchAuctionWithdraw',
value: withdraw,
},
});

const actionView = viewActionPlan(metadataByAssetId, mockFvk)(actionPlan);

await expect(actionView).resolves.toEqual(
new ActionView({
actionView: {
case: 'actionDutchAuctionWithdraw',
value: {
action: withdraw,
},
},
}),
);
});
});

describe('all other action cases', () => {
test('returns an action view with the case but no value', async () => {
const actionPlan = new ActionPlan({
Expand Down
41 changes: 39 additions & 2 deletions packages/perspective/plan/view-action-plan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ import {
SwapView,
} from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/component/dex/v1/dex_pb';
import { FullViewingKey } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/core/keys/v1/keys_pb';
import { getAuctionId } from '@penumbra-zone/wasm/auction';
import {
getInputAssetId,
getOutputAssetId,
} from '@penumbra-zone/getters/dutch-auction-description';

const getValueView = async (
value: Value | undefined,
Expand Down Expand Up @@ -250,9 +255,41 @@ export const viewActionPlan =
},
});

case 'actionDutchAuctionSchedule':
case 'actionDutchAuctionEnd':
case 'actionDutchAuctionSchedule': {
const inputAssetId = getInputAssetId.optional()(actionPlan.action.value.description);
const outputAssetId = getOutputAssetId.optional()(actionPlan.action.value.description);
const [inputMetadata, outputMetadata] = await Promise.all([
inputAssetId ? await denomMetadataByAssetId(inputAssetId) : undefined,
outputAssetId ? await denomMetadataByAssetId(outputAssetId) : undefined,
]);

return new ActionView({
actionView: {
case: 'actionDutchAuctionSchedule',
value: {
action: actionPlan.action.value,
auctionId: actionPlan.action.value.description
? getAuctionId(actionPlan.action.value.description)
: undefined,
inputMetadata,
outputMetadata,
},
},
});
}

case 'actionDutchAuctionWithdraw':
return new ActionView({
actionView: {
case: 'actionDutchAuctionWithdraw',
value: {
action: actionPlan.action.value,
/** @todo: Add `reserves` property */
},
},
});

case 'actionDutchAuctionEnd':
return new ActionView({
actionView: actionPlan.action,
});
Expand Down
4 changes: 2 additions & 2 deletions packages/protobuf/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
"peerDependencies": {
"@buf/cosmos_ibc.bufbuild_es": "1.9.0-20240327103030-e2006674271c.1",
"@buf/cosmos_ibc.connectrpc_es": "1.4.0-20240327103030-e2006674271c.2",
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.9.0-20240429125510-24b08e70bbc2.1",
"@buf/penumbra-zone_penumbra.connectrpc_es": "1.4.0-20240429125510-24b08e70bbc2.2",
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.9.0-20240501193854-ea3cc743390d.1",
"@buf/penumbra-zone_penumbra.connectrpc_es": "1.4.0-20240501193854-ea3cc743390d.2",
"@bufbuild/protobuf": "^1.9.0",
"@connectrpc/connect": "^1.4.0"
}
Expand Down
8 changes: 4 additions & 4 deletions packages/query/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@
"devDependencies": {
"@buf/cosmos_ibc.bufbuild_es": "1.9.0-20240327103030-e2006674271c.1",
"@buf/cosmos_ibc.connectrpc_es": "1.4.0-20240327103030-e2006674271c.2",
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.9.0-20240429125510-24b08e70bbc2.1",
"@buf/penumbra-zone_penumbra.connectrpc_es": "1.4.0-20240429125510-24b08e70bbc2.2",
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.9.0-20240501193854-ea3cc743390d.1",
"@buf/penumbra-zone_penumbra.connectrpc_es": "1.4.0-20240501193854-ea3cc743390d.2",
"@bufbuild/protobuf": "^1.9.0",
"@connectrpc/connect": "^1.4.0",
"@connectrpc/connect-web": "^1.4.0"
},
"peerDependencies": {
"@buf/cosmos_ibc.bufbuild_es": "1.9.0-20240327103030-e2006674271c.1",
"@buf/cosmos_ibc.connectrpc_es": "1.4.0-20240327103030-e2006674271c.2",
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.9.0-20240429125510-24b08e70bbc2.1",
"@buf/penumbra-zone_penumbra.connectrpc_es": "1.4.0-20240429125510-24b08e70bbc2.2",
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.9.0-20240501193854-ea3cc743390d.1",
"@buf/penumbra-zone_penumbra.connectrpc_es": "1.4.0-20240501193854-ea3cc743390d.2",
"@bufbuild/protobuf": "^1.9.0",
"@connectrpc/connect": "^1.4.0",
"@connectrpc/connect-web": "^1.4.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/services-context/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
"exponential-backoff": "^3.1.1"
},
"devDependencies": {
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.9.0-20240429125510-24b08e70bbc2.1",
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.9.0-20240501193854-ea3cc743390d.1",
"@bufbuild/protobuf": "^1.9.0",
"@penumbra-zone/polyfills": "workspace:*"
},
"peerDependencies": {
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.9.0-20240429125510-24b08e70bbc2.1",
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.9.0-20240501193854-ea3cc743390d.1",
"@bufbuild/protobuf": "^1.9.0"
}
}
8 changes: 4 additions & 4 deletions packages/services/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@
"@penumbra-zone/wasm": "workspace:*"
},
"devDependencies": {
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.9.0-20240429125510-24b08e70bbc2.1",
"@buf/penumbra-zone_penumbra.connectrpc_es": "1.4.0-20240429125510-24b08e70bbc2.2",
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.9.0-20240501193854-ea3cc743390d.1",
"@buf/penumbra-zone_penumbra.connectrpc_es": "1.4.0-20240501193854-ea3cc743390d.2",
"@bufbuild/protobuf": "^1.9.0",
"@connectrpc/connect": "^1.4.0"
},
"peerDependencies": {
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.9.0-20240429125510-24b08e70bbc2.1",
"@buf/penumbra-zone_penumbra.connectrpc_es": "1.4.0-20240429125510-24b08e70bbc2.2",
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.9.0-20240501193854-ea3cc743390d.1",
"@buf/penumbra-zone_penumbra.connectrpc_es": "1.4.0-20240501193854-ea3cc743390d.2",
"@bufbuild/protobuf": "^1.9.0",
"@connectrpc/connect": "^1.4.0"
}
Expand Down
4 changes: 2 additions & 2 deletions packages/storage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@
"idb": "^8.0.0"
},
"devDependencies": {
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.9.0-20240429125510-24b08e70bbc2.1",
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.9.0-20240501193854-ea3cc743390d.1",
"@bufbuild/protobuf": "^1.9.0",
"@penumbra-zone/polyfills": "workspace:*",
"@penumbra-zone/types": "workspace:*",
"@penumbra-zone/wasm": "workspace:*"
},
"peerDependencies": {
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.9.0-20240429125510-24b08e70bbc2.1",
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.9.0-20240501193854-ea3cc743390d.1",
"@bufbuild/protobuf": "^1.9.0"
}
}
8 changes: 6 additions & 2 deletions packages/types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,16 @@
},
"devDependencies": {
"@buf/cosmos_ibc.bufbuild_es": "1.9.0-20240327103030-e2006674271c.1",
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.9.0-20240429125510-24b08e70bbc2.1",
"@buf/cosmos_ibc.connectrpc_es": "1.4.0-20240327103030-e2006674271c.2",
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.9.0-20240501193854-ea3cc743390d.1",
"@buf/penumbra-zone_penumbra.connectrpc_es": "1.4.0-20240501193854-ea3cc743390d.2",
"@bufbuild/protobuf": "^1.9.0"
},
"peerDependencies": {
"@buf/cosmos_ibc.bufbuild_es": "1.9.0-20240327103030-e2006674271c.1",
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.9.0-20240429125510-24b08e70bbc2.1",
"@buf/cosmos_ibc.connectrpc_es": "1.4.0-20240327103030-e2006674271c.2",
"@buf/penumbra-zone_penumbra.bufbuild_es": "1.9.0-20240501193854-ea3cc743390d.1",
"@buf/penumbra-zone_penumbra.connectrpc_es": "1.4.0-20240501193854-ea3cc743390d.2",
"@bufbuild/protobuf": "^1.9.0"
}
}
Loading

0 comments on commit aa49e49

Please sign in to comment.