Skip to content

Commit

Permalink
refactor: back to cosmic-proto without RPC
Browse files Browse the repository at this point in the history
This reverts commit 5f19df9.
  • Loading branch information
turadg committed Apr 4, 2024
1 parent 6093d4a commit 7b7e823
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
13 changes: 10 additions & 3 deletions packages/agoric-cli/src/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ import {
makeLeaderFromRpcAddresses,
makeCastingSpec,
} from '@agoric/casting';
import { getSigningAgoricClientOptions } from '@agoric/cosmic-proto';
import { DirectSecp256k1HdWallet } from '@cosmjs/proto-signing';
import { DirectSecp256k1HdWallet, Registry } from '@cosmjs/proto-signing';
import { defaultRegistryTypes } from '@cosmjs/stargate';
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 @@ -36,6 +38,11 @@ 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 @@ -281,8 +288,8 @@ export const makeCosmosBundlePublisher = ({

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

// AWAIT
Expand Down
21 changes: 13 additions & 8 deletions packages/casting/test/test-interpose-net-access.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
// @ts-check
/* global globalThis */
import { QueryClient, setupBankExtension } from '@cosmjs/stargate';
import { Tendermint34Client } from '@cosmjs/tendermint-rpc';
import anyTest from 'ava';
import {
createProtobufRpcClient,
QueryClient,
setupBankExtension,
} from '@cosmjs/stargate';
import { Tendermint34Client } from '@cosmjs/tendermint-rpc';
// import { QueryClientImpl } from '@agoric/cosmic-proto/vstorage/query.js';

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 @@ -69,21 +73,22 @@ const scenario2 = {
],
};

test(`vstorage query: Children (RECORDING: ${RECORDING})`, async t => {
test.failing(`vstorage query: Children (RECORDING: ${RECORDING})`, async t => {
const { context: io } = t;

const { fetch: fetchMock, web } = io.recording
? captureIO(io.fetch)
: { 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 queryService = agoric.vstorage.createRpcQueryExtension(qClient);
const rpc = createProtobufRpcClient(qClient);
// @ts-expect-error -- XXX
// eslint-disable-next-line no-undef -- XXX
const queryService = new QueryClientImpl(rpc);

const children = await queryService.children({ path: '' });
const children = await queryService.Children({ path: '' });
if (io.recording) {
t.snapshot(web);
}
Expand Down

0 comments on commit 7b7e823

Please sign in to comment.