Skip to content

Commit

Permalink
refactor: use new cosmic-proto
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Feb 29, 2024
1 parent 6598319 commit 5f19df9
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 206 deletions.
2 changes: 1 addition & 1 deletion packages/agoric-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"@agoric/assert": "^0.6.0",
"@agoric/cache": "^0.3.2",
"@agoric/casting": "^0.4.2",
"@agoric/cosmic-proto": "^0.3.0",
"@agoric/cosmic-proto": "^0.4.0",
"@agoric/ertp": "^0.16.2",
"@agoric/governance": "^0.10.3",
"@agoric/inter-protocol": "^0.16.1",
Expand Down
13 changes: 3 additions & 10 deletions packages/agoric-cli/src/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ import {
makeLeaderFromRpcAddresses,
makeCastingSpec,
} from '@agoric/casting';
import { DirectSecp256k1HdWallet, Registry } from '@cosmjs/proto-signing';
import { defaultRegistryTypes } from '@cosmjs/stargate';
import { getSigningAgoricClientOptions } from '@agoric/cosmic-proto';
import { DirectSecp256k1HdWallet } from '@cosmjs/proto-signing';
import { stringToPath } from '@cosmjs/crypto';
import { Decimal } from '@cosmjs/math';
import { fromBech32 } from '@cosmjs/encoding';

import { MsgInstallBundle } from '@agoric/cosmic-proto/swingset/msgs.js';

// https://github.com/Agoric/agoric-sdk/blob/master/golang/cosmos/daemon/main.go
const Agoric = {
Bech32MainPrefix: 'agoric',
Expand All @@ -38,11 +36,6 @@ const Agoric = {
const hdPath = (coinType = 118, account = 0) =>
stringToPath(`m/44'/${coinType}'/${account}'/0/0`);

const registry = new Registry([
...defaultRegistryTypes,
[Agoric.proto.swingset.InstallBundle.typeUrl, MsgInstallBundle],
]);

/**
* @typedef {object} JsonHttpRequest
* @property {string} hostname
Expand Down Expand Up @@ -290,8 +283,8 @@ export const makeCosmosBundlePublisher = ({

// AWAIT
const stargateClient = await connectWithSigner(endpoint, wallet, {
...getSigningAgoricClientOptions(),
gasPrice: Agoric.gasPrice,
registry,
});

// AWAIT
Expand Down
1 change: 1 addition & 0 deletions packages/boot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"license": "Apache-2.0",
"dependencies": {
"@agoric/assert": "^0.6.0",
"@agoric/cosmic-proto": "^0.4.0",
"@agoric/builders": "^0.1.0",
"@agoric/cosmic-swingset": "^0.41.3",
"@agoric/ertp": "^0.16.2",
Expand Down
3 changes: 2 additions & 1 deletion packages/boot/tools/supports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
import type { ExecutionContext as AvaT } from 'ava';

import { makeRunUtils } from '@agoric/swingset-vat/tools/run-utils.js';
import type { CoreEvalSDKType } from '@agoric/cosmic-proto/dist/codegen/agoric/swingset/swingset';

const trace = makeTracer('BSTSupport', false);

Expand Down Expand Up @@ -172,7 +173,7 @@ export const makeProposalExtractor = ({ childProcess, fs }: Powers) => {
loadAndRmPkgFile(permit),
loadAndRmPkgFile(script),
]);
return { json_permits: permits, js_code: code };
return { json_permits: permits, js_code: code } as CoreEvalSDKType;
}),
);

Expand Down
2 changes: 1 addition & 1 deletion packages/casting/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"node-fetch": "^2.6.0"
},
"devDependencies": {
"@agoric/cosmic-proto": "^0.3.0",
"@agoric/cosmic-proto": "^0.4.0",
"@endo/ses-ava": "^1.1.2",
"@types/node-fetch": "^2.6.2",
"ava": "^5.3.0",
Expand Down
17 changes: 7 additions & 10 deletions packages/casting/test/test-interpose-net-access.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
// @ts-check
/* global globalThis */
import anyTest from 'ava';
import {
createProtobufRpcClient,
QueryClient,
setupBankExtension,
} from '@cosmjs/stargate';
import { QueryClient, setupBankExtension } from '@cosmjs/stargate';
import { Tendermint34Client } from '@cosmjs/tendermint-rpc';
import { QueryClientImpl } from '@agoric/cosmic-proto/vstorage/query.js';
import anyTest from 'ava';

import { agoric } from '@agoric/cosmic-proto';
import { makeHttpClient } from '../src/makeHttpClient.js';
import { captureIO, replayIO, web1, web2 } from './net-access-fixture.js';

Expand Down Expand Up @@ -81,12 +77,13 @@ test(`vstorage query: Children (RECORDING: ${RECORDING})`, async t => {
: { fetch: replayIO(web2), web: new Map() };
const rpcClient = makeHttpClient(scenario2.endpoint, fetchMock);

t.is(agoric.vstorage.Children.typeUrl, '/agoric.vstorage.Children');

const tmClient = await Tendermint34Client.create(rpcClient);
const qClient = new QueryClient(tmClient);
const rpc = createProtobufRpcClient(qClient);
const queryService = new QueryClientImpl(rpc);
const queryService = agoric.vstorage.createRpcQueryExtension(qClient);

const children = await queryService.Children({ path: '' });
const children = await queryService.children({ path: '' });
if (io.recording) {
t.snapshot(web);
}
Expand Down
5 changes: 4 additions & 1 deletion packages/cosmic-swingset/src/params.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ export const encodeQueueSizes = queueSizes =>
return { key, size };
});

// Map the SwingSet parameters to a deterministic data structure.
/**
* Map the SwingSet parameters to a deterministic data structure.
* @param {import('@agoric/cosmic-proto/dist/codegen/agoric/swingset/swingset.js').ParamsSDKType} params
*/
export const parseParams = params => {
const {
beans_per_unit: rawBeansPerUnit,
Expand Down
3 changes: 3 additions & 0 deletions packages/cosmic-swingset/src/sim-params.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ export const defaultQueueMax = [
makeQueueSize(QueueInbound, defaultInboundQueueMax),
];

/**
* @type {import('@agoric/cosmic-proto/dist/codegen/agoric/swingset/swingset.js').ParamsSDKType}
*/
export const DEFAULT_SIM_SWINGSET_PARAMS = {
beans_per_unit: defaultBeansPerUnit,
fee_unit_price: defaultFeeUnitPrice,
Expand Down
2 changes: 1 addition & 1 deletion packages/smart-wallet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"lint:eslint": "eslint ."
},
"devDependencies": {
"@agoric/cosmic-proto": "^0.3.0",
"@agoric/cosmic-proto": "^0.4.0",
"@agoric/swingset-vat": "^0.32.2",
"@endo/bundle-source": "^3.1.0",
"@endo/captp": "^4.0.4",
Expand Down
6 changes: 3 additions & 3 deletions packages/smart-wallet/src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import type { ERef } from '@endo/far';
import type { CapData } from '@endo/marshal';
import type { MsgWalletSpendAction } from '@agoric/cosmic-proto/swingset/msgs';
import type { agoric } from '@agoric/cosmic-proto';
import type { AgoricNamesRemotes } from '@agoric/vats/tools/board-utils.js';
import type { OfferSpec } from './offers.js';

Expand Down Expand Up @@ -40,7 +40,7 @@ export type BridgeActionCapData = WalletCapData<
/**
* Defined by walletAction struct in msg_server.go
*
* @see {MsgWalletSpendAction} and walletSpendAction in msg_server.go
* @see {agoric.swingset.MsgWalletAction} and walletSpendAction in msg_server.go
*/
export type WalletActionMsg = {
type: 'WALLET_ACTION';
Expand All @@ -55,7 +55,7 @@ export type WalletActionMsg = {
/**
* Defined by walletSpendAction struct in msg_server.go
*
* @see {MsgWalletSpendAction} and walletSpendAction in msg_server.go
* @see {agoric.swingset.MsgWalletSpendAction} and walletSpendAction in msg_server.go
*/
export type WalletSpendActionMsg = {
type: 'WALLET_SPEND_ACTION';
Expand Down
8 changes: 1 addition & 7 deletions packages/vats/src/core/chain-behaviors.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,7 @@ export const bridgeCoreEval = async allPowers => {
async fromBridge(obj) {
switch (obj.type) {
case 'CORE_EVAL': {
/**
* Type defined by
* `agoric-sdk/golang/cosmos/proto/agoric/swingset/swingset.proto`
* CoreEval.
*
* @type {{ evals: { json_permits: string; js_code: string }[] }}
*/
/** @type {import('@agoric/cosmic-proto/dist/codegen/agoric/swingset/swingset.d.ts').CoreEvalProposalSDKType} */
const { evals } = obj;
return Promise.all(
evals.map(({ json_permits: jsonPermit, js_code: code }) =>
Expand Down
Loading

0 comments on commit 5f19df9

Please sign in to comment.