Skip to content

Commit

Permalink
Merge pull request #8931 from Agoric/8917-telescope
Browse files Browse the repository at this point in the history
build cosmic-proto with Telescope
  • Loading branch information
mergify[bot] authored Feb 29, 2024
2 parents 3d13c09 + db6cdef commit 072c457
Show file tree
Hide file tree
Showing 129 changed files with 27,574 additions and 6,001 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ packages/stat-logger
**/vars.tf
**/*.log
**/dist
!packages/cosmic-proto/dist
**/build
**/bundles
**/__pycache__
Expand Down
9 changes: 9 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,15 @@ module.exports = {
'no-undef': 'off',
},
},
{
files: ['*.d.ts'],
rules: {
// Irrelevant in a typedef
'no-use-before-define': 'off',
// Linter confuses the type declaration with value declaration
'no-redeclare': 'off',
},
},
{
// disable type-aware linting in HTML
files: ['*.html'],
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ bundles
bundle-*.js
compiled
dist
!packages/cosmic-proto/dist
api-docs

# misc
Expand Down
1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,3 @@ public

# copied from upstream
/packages/xsnap/lib/object-inspect.js

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
"typedoc": "^0.25.7",
"typescript": "^5.3.3"
},
"resolutions": {
"**/protobufjs": "^7.2.4"
},
"engines": {
"node": "^16.13 || ^18.12 || ^20.9"
},
Expand Down Expand Up @@ -84,7 +87,7 @@
},
"ava": {
"files": [
"packages/*/test/**/test-*.js"
"packages/*/test/**/test-*.ts"
],
"timeout": "30m"
},
Expand Down
16 changes: 8 additions & 8 deletions packages/agoric-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
"lint:eslint": "eslint ."
},
"devDependencies": {
"@agoric/deploy-script-support": "^0.10.3",
"@agoric/cosmic-swingset": "^0.41.3",
"@agoric/deploy-script-support": "^0.10.3",
"ava": "^5.3.0",
"c8": "^7.13.0",
"dd-trace": "^4.11.1"
Expand All @@ -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 All @@ -52,12 +52,12 @@
"@agoric/vats": "^0.15.1",
"@agoric/zoe": "^0.26.2",
"@agoric/zone": "^0.2.2",
"@confio/relayer": "^0.9.0",
"@cosmjs/crypto": "^0.30.1",
"@cosmjs/encoding": "^0.30.1",
"@cosmjs/math": "^0.30.1",
"@cosmjs/proto-signing": "^0.30.1",
"@cosmjs/stargate": "^0.30.1",
"@confio/relayer": "^0.11.3",
"@cosmjs/crypto": "^0.32.2",
"@cosmjs/encoding": "^0.32.2",
"@cosmjs/math": "^0.32.2",
"@cosmjs/proto-signing": "^0.32.2",
"@cosmjs/stargate": "^0.32.2",
"@endo/bundle-source": "^3.1.0",
"@endo/captp": "^4.0.4",
"@endo/compartment-mapper": "^1.1.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/agoric-cli/src/bin-agops.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ program.addCommand(makeAuctionCommand(logger, { ...procIO, fetch }));
program.addCommand(makeInterCommand(procIO, { fetch }));
program.addCommand(makeTestCommand(procIO, { fetch }));

E.when(program.parseAsync(process.argv), undefined, err => {
void E.when(program.parseAsync(process.argv), undefined, err => {
if (err instanceof CommanderError) {
console.error(err.message);
} else {
Expand Down
11 changes: 6 additions & 5 deletions packages/agoric-cli/src/commands/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,23 +50,24 @@ export const makeWalletCommand = async command => {
)
.option('--spend', 'confirm you want to spend')
.option('--nickname <string>', 'nickname to use', 'my-wallet')
.action(function (opts) {
.action(async function (opts) {
const { account, nickname, spend } = opts;
const { home, keyringBackend: backend } = wallet.opts();
const tx = ['provision-one', nickname, account, 'SMART_WALLET'];
await null;
if (spend) {
execSwingsetTransaction(tx, {
from: account,
keyring: { home, backend },
...networkConfig,
});
} else {
const params = fetchSwingsetParams(networkConfig);
const params = await fetchSwingsetParams(networkConfig);
assert(
params.power_flag_fees.length === 1,
'multiple power_flag_fees not supported',
params.powerFlagFees.length === 1,
'multiple powerFlagFees not supported',
);
const { fee: fees } = params.power_flag_fees[0];
const { fee: fees } = params.powerFlagFees[0];
const nf = new Intl.NumberFormat('en-US');
const costs = fees
.map(f => `${nf.format(Number(f.amount))} ${f.denom}`)
Expand Down
10 changes: 6 additions & 4 deletions packages/agoric-cli/src/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ export default async function installMain(progname, rawArgs, powers, opts) {
p.childProcess.stdout.on('data', out => stdout.push(out));
await p;
const d = JSON.parse(Buffer.concat(stdout).toString('utf-8'));
Object.entries(d).forEach(([name, { location }]) =>
map.set(name, path.resolve(cwd, location)),
);
for (const [name, { location }] of Object.entries(d)) {
map.set(name, path.resolve(cwd, location));
}
return map;
}

Expand Down Expand Up @@ -268,7 +268,9 @@ export default async function installMain(progname, rawArgs, powers, opts) {
};
await Promise.all(subdirs.map(removeNodeModulesSymlinks));
} else {
DEFAULT_SDK_PACKAGE_NAMES.forEach(name => sdkPackageToPath.set(name, null));
for (const name of DEFAULT_SDK_PACKAGE_NAMES) {
sdkPackageToPath.set(name, null);
}
}

if (forceSdkVersion !== undefined) {
Expand Down
28 changes: 14 additions & 14 deletions packages/agoric-cli/src/lib/chain.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @ts-check
/* global process */
import { agoric } from '@agoric/cosmic-proto';
import { normalizeBech32 } from '@cosmjs/encoding';
import { execFileSync as execFileSyncAmbient } from 'child_process';

Expand Down Expand Up @@ -92,20 +93,19 @@ export const execSwingsetTransaction = (swingsetArgs, opts) => {
};
harden(execSwingsetTransaction);

// xxx rpc should be able to query this by HTTP without shelling out
export const fetchSwingsetParams = net => {
const { chainName, rpcAddrs, execFileSync = execFileSyncAmbient } = net;
const cmd = [
`--node=${rpcAddrs[0]}`,
`--chain-id=${chainName}`,
'query',
'swingset',
'params',
'--output',
'--json',
];
const buffer = execFileSync(agdBinary, cmd);
return JSON.parse(buffer.toString());
/**
*
* @param {import('./rpc.js').MinimalNetworkConfig} net
* @returns {Promise<import('@agoric/cosmic-proto/dist/codegen/agoric/swingset/swingset').Params>}
*/
export const fetchSwingsetParams = async net => {
const { rpcAddrs } = net;
const rpcEndpoint = rpcAddrs[0];
const client = await agoric.ClientFactory.createRPCQueryClient({
rpcEndpoint,
});
const { params } = await client.agoric.swingset.params();
return params;
};
harden(fetchSwingsetParams);

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
18 changes: 9 additions & 9 deletions packages/agoric-cli/test/test-inter-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,12 @@ const makeProcess = (t, keyring, out) => {
t.truthy(cmd);
switch (cmd) {
case 'keys': {
['--node', '--chain'].forEach(opt => {
for (const opt of ['--node', '--chain']) {
const ix = args.findIndex(a => a.startsWith(opt));
if (ix >= 0) {
args.splice(ix, 1);
}
});
}
t.deepEqual(args.slice(0, 3), ['keys', 'show', '--address']);
const name = args[3];
const addr = keyring[name];
Expand Down Expand Up @@ -316,10 +316,10 @@ test('README: inter usage', async t => {

const net = makeNet({ ...publishedNames, wallet: govWallets });
const cmd = await makeInterCommand(makeProcess(t, testKeyring, out), net);
subCommands(cmd).forEach(c => {
for (const c of subCommands(cmd)) {
c.exitOverride();
c.configureOutput({ writeErr: s => diag.push(s) });
});
}

await t.throwsAsync(cmd.parseAsync(argv));
const txt = diag.join('').trim();
Expand All @@ -343,10 +343,10 @@ test('diagnostic for agd ENOENT', async t => {
},
makeNet({}),
);
subCommands(cmd).forEach(c => {
for (const c of subCommands(cmd)) {
c.exitOverride();
c.configureOutput({ writeErr: s => diag.push(s) });
});
}

await t.throwsAsync(cmd.parseAsync(argv), { instanceOf: CommanderError });
t.is(
Expand All @@ -366,11 +366,11 @@ const usageTest = (words, blurb = 'Command usage:') => {
const program = createCommand('agops');
const cmd = await makeInterCommand(makeProcess(t, {}, out), makeNet({}));
program.addCommand(cmd);
subCommands(program).forEach(c =>
for (const c of subCommands(program)) {
c.exitOverride(() => {
throw new CommanderError(1, 'usage', '');
}),
);
});
}
cmd.configureOutput({
writeOut: s => out.push(s),
writeErr: s => out.push(s),
Expand Down
3 changes: 2 additions & 1 deletion 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 Expand Up @@ -52,7 +53,7 @@
"@agoric/swingset-liveslots": "^0.10.2",
"ava": "^5.3.0",
"c8": "^7.13.0",
"tsx": "^3.12.8"
"tsx": "3.12.8"
},
"files": [
"CHANGELOG.md",
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
10 changes: 5 additions & 5 deletions packages/casting/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
"@agoric/notifier": "^0.6.2",
"@agoric/spawner": "^0.6.8",
"@agoric/store": "^0.9.2",
"@cosmjs/encoding": "^0.30.1",
"@cosmjs/proto-signing": "^0.30.1",
"@cosmjs/stargate": "^0.30.1",
"@cosmjs/tendermint-rpc": "^0.30.1",
"@cosmjs/encoding": "^0.32.2",
"@cosmjs/proto-signing": "^0.32.2",
"@cosmjs/stargate": "^0.32.2",
"@cosmjs/tendermint-rpc": "^0.32.2",
"@endo/far": "^1.0.4",
"@endo/init": "^1.0.4",
"@endo/lockdown": "^1.0.4",
Expand All @@ -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: 5 additions & 0 deletions packages/cosmic-proto/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules/
dist/
main/
module/
coverage/
Loading

0 comments on commit 072c457

Please sign in to comment.