-
Notifications
You must be signed in to change notification settings - Fork 217
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
build cosmic-proto with Telescope #8931
Conversation
test plan looks as good as anything I can think of. IIUC, it should address... Here's hoping for a moment to try it. I'm also interested to see how it goes with |
140KLOC. oh my. |
I suppose so.
Exactly the code in |
863515d
to
af55111
Compare
a19dee0
to
f67bda7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good start! I would like to see some effort towards reducing the amount of noise introduced by Telescope, such as support for CommonJS and the semantically void codegen/
and dist/
directory names. But by all means, full steam ahead!
packages/boot/tools/supports.ts
Outdated
@@ -26,6 +26,7 @@ import { | |||
import type { ExecutionContext as AvaT } from 'ava'; | |||
|
|||
import { makeRunUtils } from '@agoric/swingset-vat/tools/run-utils.js'; | |||
import { CoreEvalSDKType } from '@agoric/cosmic-proto/dist/codegen/agoric/swingset/swingset'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import { CoreEvalSDKType } from '@agoric/cosmic-proto/dist/codegen/agoric/swingset/swingset'; | |
import type { CoreEvalSDKType } from '@agoric/cosmic-proto/agoric/swingset/swingset'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added type
and exports for swingset/swingset.js
.
Importing it here would be nice. Unfortunately it will only work with NodeNext
moduleResolution and enabling that breaks our use of ambient types (3364 errors).
Punting to #9005
EDIT: I see your other comment about moving dist/codegen/*
to the package level. I'll discuss that there.
const rimraf = require('rimraf').rimrafSync; | ||
|
||
const protoDirs = [join(__dirname, '/../proto')]; | ||
const outPath = join(__dirname, '../src/codegen'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer this, since "codegen"
is just noise.
const outPath = join(__dirname, '../src/codegen'); | |
const outPath = join(__dirname, '../src'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it helpful to distinguish which source files were generated by machine vs by human? @dckc asked for this explicitly in review
packages/cosmic-proto/src/index.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this is the only hand-written source file in the src
directory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. And you can tell that because it's not in the codegen
directory
}, | ||
rpcClients: { | ||
enabled: true, | ||
camelCase: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the setting that required changes in agoric-cli
for the returned swingset params?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose so. Are you opposed to it? To me the camelCase is what one would expect in a JS API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@samsiegart you've written the most client code. What's your opinion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd guess camelCase, but not sure where this shows up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@michaelfig made a good point about sticking to defaults. I took this option out to adopt the defaults. Turns out true
is the Telescope default
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@michaelfig made a good point about sticking to defaults. I took this option out to adopt the defaults. Turns out true
is the Telescope default.
@samsiegart it shows up in 7c01cb0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yea, camelCase
please 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found the option that determines power_flag_fees
vs powerFlagFees
: parser.keepCase.
Setting it to keepCase: true
matches the older snake_case. Removing it uses the camelCase, so that is the default of Telescope. Given our desire to match the defaults I've left it alone. I considered removing it but I think it's helpful for discovery.
e954f2c
to
3b88b7b
Compare
855f30b
to
f71b722
Compare
something recently started reporting TS errors in there. just ignore
853de5d
to
2304c44
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to adopt any of these suggestions right now... I'm fine with putting them in a future PR.
packages/cosmic-proto/README.md
Outdated
|
||
### Codegen | ||
|
||
Contract schemas live in `./contracts`, and protos in `./proto`. Look inside of `scripts/codegen.cjs` and configure the settings for bundling your SDK and contracts into `@agoric/cosmic-proto`: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't use "Contract schemas" or "bundling contracts into @agoric/cosmic-proto
":
Contract schemas live in `./contracts`, and protos in `./proto`. Look inside of `scripts/codegen.cjs` and configure the settings for bundling your SDK and contracts into `@agoric/cosmic-proto`: | |
Protos live in `./proto`. Look inside of `scripts/codegen.cjs` and configure the settings for bundling your SDK into `@agoric/cosmic-proto`: |
packages/cosmic-proto/README.md
Outdated
- [Usage](#usage) | ||
- [RPC Clients](#rpc-clients) | ||
- [Composing Messages](#composing-messages) | ||
- Cosmos, CosmWasm, and IBC |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For future reference, please search the readme for all instances of (case-insensitive) "cosmwasm" and remove them as they may confuse somebody writing an Agoric smart contract.
+ const importStmts = bundler.bundle.importPaths; | ||
+ for (const stmt of importStmts) { | ||
+ if (stmt.source.value.startsWith('.') && !stmt.source.value.endsWith('.js')) { | ||
+ stmt.source.value += '.js'; | ||
+ } | ||
+ } | ||
+ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nicely done!
- const reducedDescriptors = {}; | ||
+ let reducedDescriptors = {}; | ||
|
||
forEach(descriptors, (descriptor, name) => { | ||
let ret; | ||
if ((ret = reducer(descriptor, name, obj)) !== false) { | ||
- reducedDescriptors[name] = ret || descriptor; | ||
+ reducedDescriptors = {...reducedDescriptors, | ||
+ [name]: ret || descriptor | ||
+ }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FFR, we should probably use Object.defineProperty(reducedDescriptors, name, { value: ret || descriptor })
since otherwise this loop is quadratic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what I did first but when PRing upstream it caused a test failure.
a64795e
to
db6cdef
Compare
closes: #8917
Description
Will change @agoric/cosmic-proto to build with Telescope, giving us better helper code.
I tried to keep the commits clean. The package started generated as
new-cosmic-proto
and I replace the existing one after nailing some thing down.Security Considerations
Scaling Considerations
Documentation Considerations
Testing Considerations
green PR in dapp-inter:
green PR in wallet-app
green PR in ui-kit :
green PR in cosmos-proposal-builder
agoric-3-proposals had some references, but they were dead code,
Upgrade Considerations