-
Notifications
You must be signed in to change notification settings - Fork 214
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
new client-utils package #10407
new client-utils package #10407
Conversation
@@ -2,11 +2,11 @@ | |||
/* eslint-env node */ | |||
import '@endo/init'; |
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.
Have you tried @endo/init/legacy.js? I'd expect axios to work with that, because @agoric/rpc
itself already uses axios. It would still be great to get your patch into axios itself
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.
Thank you! That will help so much with #9200.
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.
LGTM for now. I am curious to know if we can make this in typescript, but I think most of this code so far is taken from existing js files so I'm not going to request it be rewritten.
It would require a build step. #9200 will require a build step for the codegen so it wouldn't be a huge change after that. |
Deploying agoric-sdk with Cloudflare Pages
|
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.
Thanks for getting this moving.
After a bit of thinking-out-loud (mostly marked suggestion), I tried to focus my review on the package boundaries. A number of requests regard dependencies such as governance and inter-protocol that, as far as I can see, aren't used.
My most substantive request is probably around doing I/O at module-load-time for networkConfig
.
packages/client-utils/src/chain.js
Outdated
* @returns {Promise<StargateClient>} | ||
*/ | ||
export const makeStargateClient = config => | ||
StargateClient.connect(pickEndpoint(config)); |
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 it important to export makeStargateClient
?
StargateClient.connect
uses ambient access to the nest unless you pass in an endpoint object instead of a string.
(In particular, it uses axios, which seems a little silly now that fetch
is mature.)
suggestion: Perhaps apply the pattern from #10038 ? I suppose we can do that later.
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.
It's necessary for the pollBlocks
feature of WalletUtils. Passing an Endpoint object doesn't help because that's just {url, headers}
.
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 think I've got it working with something from casting (so I added that dep back)
packages/client-utils/package.json
Outdated
"@agoric/casting": "^0.4.2", | ||
"@agoric/cosmic-proto": "*", | ||
"@agoric/ertp": "^0.16.2", | ||
"@agoric/governance": "^0.10.3", |
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 don't see any occurrences of governance in this new package.
request:
"@agoric/governance": "^0.10.3", |
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.
very soon
packages/client-utils/package.json
Outdated
"@agoric/cosmic-proto": "*", | ||
"@agoric/ertp": "^0.16.2", | ||
"@agoric/governance": "^0.10.3", | ||
"@agoric/inter-protocol": "^0.16.1", |
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.
nor inter-protocol.
request:
"@agoric/inter-protocol": "^0.16.1", |
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.
very soon
'offerStatusTuples', | ||
'pickEndpoint', | ||
'purseBalanceTuples', | ||
'rpcUrl', |
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.
What rpcUrl
does is reasonable, but the name suggests something more general purpose and there's no docstring.
suggestion: Rename it to include agoricNet
or the like? Add a docstring?
- GUI (such as dapps) | ||
- Tests (such as a3p-integration tests) | ||
|
||
As such the modules cannot assume they're running in Node. There are some ambient authorities in common in the above environments (e.g. `setTimeout`) but a further constraint is that these modules will not export ambient authority. Instead they will provide interfaces that are ergonomic for creating empowered objects in the client context. |
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.
👏 good to set this direction, even though we're not quite there yet.
@@ -48,6 +48,9 @@ export const getNetworkConfig = async env => { | |||
}); | |||
}; | |||
|
|||
// TODO distribute load |
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.
suggestion: Make this comment part of the API docs?
// TODO distribute load | |
/** | |
* TODO distribute load | |
*/ |
consider @deprecated
too.
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.
why? it's to be used to pick an endpoint from a config
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.
why: because without documentation, the caller would reasonably expect it to make use of >1 endpoint
import * as index from '@agoric/client-utils'; | ||
|
||
test('index', t => { | ||
t.snapshot(Object.keys(index).sort()); |
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 very handy.
@@ -1,3 +1,4 @@ | |||
/* eslint-env node */ |
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.
suggestion to follow convention:
/* eslint-env node */ | |
#!/usr/bin/env node | |
/* eslint-env node */ |
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 good.
I can live with not resolving our differences on dependency management.
6855062
to
c3f5438
Compare
incidental ## Description A couple days ago #10407 merged a new package, `@agoric/client-utils`. It wasn't marked private, but it didn't have `publishConfig` so the job that publishes to NPM was failing, ``` E402 You must sign up for private packages ``` This adds the necessary `publishConfig`. It also includes a couple other pending cleanups. ### Security Considerations Publishing another package. It's under the `@agoric` org so it can't be squatted. ### Scaling Considerations n/a ### Documentation Considerations n/a ### Testing Considerations We might want to have caught this problem in the PR but I don't think it's worth the effort. It was caught soon enough. ### Upgrade Considerations n/a
closes: #10168
Description
Provide a new package,
client-utils
, as a home for utilities that are useful to clients of an Agoric chain. This doesn't currently use@agoric/rpc
but over time some of it may be pushed down into that package.Related work…
codegen RPC clients #9200
This will be where those client factories are kept.
make a functional testing package #10369
This will solve most of what we need for functional testing. Some aspects are specific to the A3P synthetic chain (like account addresses and references to history) but most of what the tests are doing with the chain are operations that any client might do.
This will contribute to those goals.
Security Considerations
Reduces authority needed to query chain (from child_process to fetch)
Scaling Considerations
This is a big package, but it's not to be run on chain. Most client apps use some form of code shaking so they'll only take what they need.
Documentation Considerations
Once this settles down it ought to be a part of docs.agoric.com
Testing Considerations
The only test yet is a live one to make sure a query to Emerynet for Swingset params succeeds as expected, even under SES.
No package CI yet. Mostly it's refactoring of existing code so those uses serve as coverage. I do think this would benefit from some additional testing.
Upgrade Considerations
Will never be on chain