Skip to content
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

fix cosmic-proto swingset exports #6540

Merged
merged 4 commits into from
Nov 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions packages/cosmic-proto/MAINTAINERS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
We check-in and publish the `gen` generated artifacts to npm.
This package is updated rarely and so the build is checked into SCM. That is, part of `dist` is copied to root so they can be imported in consumers that don't yet support ESM. We also have symlink `./swingset` to the `dist/agoric/swingset` for local requires. (Note [NPM won't publish symlinks](https://github.com/npm/npm/issues/3310)).

We used to check in `gen` but they're redundant with `dist` output and include `.ts` which creates problems for downstream consumers using TypeScript ([ref](https://github.com/microsoft/TypeScript/issues/47387#issuecomment-1168711813)).

To rebuild the generated artifacts, install `protoc` [1] and run `yarn rebuild` in
this package.
this package. Then force the `dist` changes over the gitignore,
```
git add -f dist/{agoric,cosmos}
```

Generating artifacts requires a `protoc` system dependency that we
do not require for general development, so we do not regenerate artifacts with
Expand Down Expand Up @@ -46,3 +52,4 @@ To surface additional stubs:
symbolic links for aliasing when necessary.

[1] http://google.github.io/proto-lens/installing-protoc.html

5 changes: 5 additions & 0 deletions packages/cosmic-proto/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@

This package exports JavaScript and TypeScript generated from Cosmic Swingset
Protobuf IDL so that clients can communicate with the Agoric chain.

Package exports are defined in `exports` and also made available in the
`swingset/` file path for backwards compatibility.

See also [MAINTAINERS.md](MAINTAINERS.md).
450 changes: 450 additions & 0 deletions packages/cosmic-proto/dist/agoric/swingset/msgs.d.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,9 @@ export const MsgInstallBundleResponse = {
};
export class MsgClientImpl {
rpc;
constructor(rpc) {
service;
constructor(rpc, opts) {
this.service = opts?.service || 'agoric.swingset.Msg';
this.rpc = rpc;
this.InstallBundle = this.InstallBundle.bind(this);
this.DeliverInbound = this.DeliverInbound.bind(this);
Expand All @@ -547,83 +549,77 @@ export class MsgClientImpl {
}
InstallBundle(request) {
const data = MsgInstallBundle.encode(request).finish();
const promise = this.rpc.request(
'agoric.swingset.Msg',
'InstallBundle',
data,
);
const promise = this.rpc.request(this.service, 'InstallBundle', data);
return promise.then((data) =>
MsgInstallBundleResponse.decode(new _m0.Reader(data)),
);
}
DeliverInbound(request) {
const data = MsgDeliverInbound.encode(request).finish();
const promise = this.rpc.request(
'agoric.swingset.Msg',
'DeliverInbound',
data,
);
const promise = this.rpc.request(this.service, 'DeliverInbound', data);
return promise.then((data) =>
MsgDeliverInboundResponse.decode(new _m0.Reader(data)),
);
}
WalletAction(request) {
const data = MsgWalletAction.encode(request).finish();
const promise = this.rpc.request(
'agoric.swingset.Msg',
'WalletAction',
data,
);
const promise = this.rpc.request(this.service, 'WalletAction', data);
return promise.then((data) =>
MsgWalletActionResponse.decode(new _m0.Reader(data)),
);
}
WalletSpendAction(request) {
const data = MsgWalletSpendAction.encode(request).finish();
const promise = this.rpc.request(
'agoric.swingset.Msg',
'WalletSpendAction',
data,
);
const promise = this.rpc.request(this.service, 'WalletSpendAction', data);
return promise.then((data) =>
MsgWalletSpendActionResponse.decode(new _m0.Reader(data)),
);
}
Provision(request) {
const data = MsgProvision.encode(request).finish();
const promise = this.rpc.request('agoric.swingset.Msg', 'Provision', data);
const promise = this.rpc.request(this.service, 'Provision', data);
return promise.then((data) =>
MsgProvisionResponse.decode(new _m0.Reader(data)),
);
}
}
var globalThis = (() => {
if (typeof globalThis !== 'undefined') return globalThis;
if (typeof self !== 'undefined') return self;
if (typeof window !== 'undefined') return window;
if (typeof global !== 'undefined') return global;
if (typeof globalThis !== 'undefined') {
return globalThis;
}
if (typeof self !== 'undefined') {
return self;
}
if (typeof window !== 'undefined') {
return window;
}
if (typeof global !== 'undefined') {
return global;
}
throw 'Unable to locate global object';
})();
const atob =
globalThis.atob ||
((b64) => globalThis.Buffer.from(b64, 'base64').toString('binary'));
function bytesFromBase64(b64) {
const bin = atob(b64);
const arr = new Uint8Array(bin.length);
for (let i = 0; i < bin.length; ++i) {
arr[i] = bin.charCodeAt(i);
if (globalThis.Buffer) {
return Uint8Array.from(globalThis.Buffer.from(b64, 'base64'));
} else {
const bin = globalThis.atob(b64);
const arr = new Uint8Array(bin.length);
for (let i = 0; i < bin.length; ++i) {
arr[i] = bin.charCodeAt(i);
}
return arr;
}
return arr;
}
const btoa =
globalThis.btoa ||
((bin) => globalThis.Buffer.from(bin, 'binary').toString('base64'));
function base64FromBytes(arr) {
const bin = [];
arr.forEach((byte) => {
bin.push(String.fromCharCode(byte));
});
return btoa(bin.join(''));
if (globalThis.Buffer) {
return globalThis.Buffer.from(arr).toString('base64');
} else {
const bin = [];
arr.forEach((byte) => {
bin.push(String.fromCharCode(byte));
});
return globalThis.btoa(bin.join(''));
}
}
if (_m0.util.Long !== Long) {
_m0.util.Long = Long;
Expand Down
Loading