Skip to content

Commit

Permalink
stub Fast USDC CLI (#10330)
Browse files Browse the repository at this point in the history
refs: #10328

## Description
Sets up a package for Fast USDC and stubs out its CLI.

Finishing #10328 will require a contract that has the offer makers.

### Security Considerations
none

### Scaling Considerations
none


### Documentation Considerations
This will need end user documentation later

### Testing Considerations
basic test

### Upgrade Considerations
not deployed
  • Loading branch information
mergify[bot] authored Oct 23, 2024
2 parents 7b8c83c + 3275e08 commit d85c025
Show file tree
Hide file tree
Showing 11 changed files with 181 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .github/workflows/test-all-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,9 @@ jobs:
run: cd packages/casting && yarn ${{ steps.vars.outputs.test }} | $TEST_COLLECT
- name: yarn test (create-dapp)
run: cd packages/create-dapp && yarn ${{ steps.vars.outputs.test }} | $TEST_COLLECT
- name: yarn test (fast-usdc)
if: (success() || failure())
run: cd packages/fast-usdc && yarn ${{ steps.vars.outputs.test }} | $TEST_COLLECT
- name: yarn test (internal)
if: (success() || failure())
run: cd packages/internal && yarn ${{ steps.vars.outputs.test }} | $TEST_COLLECT
Expand Down
3 changes: 2 additions & 1 deletion packages/agoric-cli/src/sdk-package-names.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,6 @@ export default [
"@agoric/xsnap-lockdown",
"@agoric/zoe",
"@agoric/zone",
"agoric"
"agoric",
"fast-usdc"
];
25 changes: 25 additions & 0 deletions packages/fast-usdc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Fast USDC

Development package for the Fast USDC product.
Here in agoric-sdk as a convenience for integration testing and iterating on the SDK affordances required for the product.

# Naming

The package is `fast-usdc`, not `@agoric/fast-usdc`, because it's not part of the SDK.

It should not appear in the NPM directory. To this end the package is marked as private.

# Factoring

This package is meant to contain all the code for the Fast USDC product. However there are some constraints:

- a3p integration tests are in the `a3p-integration` top-level package, separate from this workspace
- the proposal builders are in `@agoric/builders` to work with the a3p-integration `build:submissions` script
- the RunUtils tests are in `@agoric/boot` to test running them atop a fresh bootstrapped environment

Over time we can update our tooling to decouple this more from the `packages` directory.

1. Make a3p-integration `build:submissions` script work with arbitrary builder paths, allowing this to be above `@agoric/builders` in the package graph
2. Export bootstrap testing utilities from `@agoric/boot`, allowing this to be above `@agoric/boot` in the package graph
3. Update CI to support packages that aren't under `packages/`, eg. a top-level `dapps` directory
4. Move this package out of agoric-sdk
50 changes: 50 additions & 0 deletions packages/fast-usdc/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"name": "fast-usdc",
"private": true,
"version": "0.1.0",
"description": "Create an Agoric Javascript smart contract application",
"type": "module",
"files": [
"contract",
"src"
],
"bin": {
"fast-usdc": "./src/cli.js"
},
"scripts": {
"build": "exit 0",
"test": "ava",
"test:c8": "c8 $C8_OPTIONS ava --config=ava-nesm.config.js",
"test:xs": "exit 0",
"lint-fix": "yarn lint:eslint --fix",
"lint": "run-s --continue-on-error lint:*",
"lint:types": "tsc",
"lint:eslint": "eslint ."
},
"devDependencies": {
"ava": "^5.3.0",
"c8": "^9.1.0",
"ts-blank-space": "^0.4.1"
},
"dependencies": {
"agoric": "^0.21.1",
"commander": "^12.1.0"
},
"ava": {
"extensions": {
"js": true,
"ts": "module"
},
"files": [
"test/**/*.test.*"
],
"nodeArguments": [
"--import=ts-blank-space/register",
"--no-warnings"
],
"require": [
"@endo/init/debug.js"
],
"timeout": "20m"
}
}
38 changes: 38 additions & 0 deletions packages/fast-usdc/src/cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env node

import { Command } from 'commander';
import { readFileSync } from 'fs';
import { fileURLToPath } from 'url';
import { dirname, resolve } from 'path';

const packageJson = JSON.parse(
readFileSync(
resolve(dirname(fileURLToPath(import.meta.url)), '../package.json'),
'utf8',
),
);

const program = new Command();

program
.name('fast-usdc')
.description('CLI to interact with Fast USDC liquidity pool')
.version(packageJson.version);

program
.command('deposit')
.description('Offer assets to the liquidity pool')
.action(() => {
console.error('TODO actually send deposit');
// TODO: Implement deposit logic
});

program
.command('withdraw')
.description('Withdraw assets from the liquidity pool')
.action(() => {
console.error('TODO actually send withdrawal');
// TODO: Implement withdraw logic
});

program.parse();
24 changes: 24 additions & 0 deletions packages/fast-usdc/test/cli.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import test from 'ava';
import { spawn } from 'child_process';
import { fileURLToPath } from 'url';
import { dirname, join } from 'path';

const dir = dirname(fileURLToPath(import.meta.url));
const CLI_PATH = join(dir, '../src/cli.js');

test('CLI shows help when run without arguments', async t => {
const output = await new Promise(resolve => {
const child = spawn('node', [CLI_PATH]);
let stderr = '';

child.stderr.on('data', data => {
stderr += data.toString();
});

child.on('close', () => {
resolve(stderr);
});
});

t.snapshot(output);
});
23 changes: 23 additions & 0 deletions packages/fast-usdc/test/snapshots/cli.test.ts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Snapshot report for `test/cli.test.ts`

The actual snapshot is saved in `cli.test.ts.snap`.

Generated by [AVA](https://avajs.dev).

## CLI shows help when run without arguments

> Snapshot 1
`Usage: fast-usdc [options] [command]␊
CLI to interact with Fast USDC liquidity pool␊
Options:␊
-V, --version output the version number␊
-h, --help display help for command␊
Commands:␊
deposit Offer assets to the liquidity pool␊
withdraw Withdraw assets from the liquidity pool␊
help [command] display help for command␊
`
Binary file added packages/fast-usdc/test/snapshots/cli.test.ts.snap
Binary file not shown.
10 changes: 10 additions & 0 deletions packages/fast-usdc/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"strict": true,
},
"include": [
"src",
"test",
],
}
1 change: 1 addition & 0 deletions scripts/check-untested-packages.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#! /usr/bin/env node
/* eslint-env node */
import fs from 'fs';
import path from 'path';
import { execFileSync } from 'child_process';
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4941,6 +4941,11 @@ commander@^11.1.0:
resolved "https://registry.yarnpkg.com/commander/-/commander-11.1.0.tgz#62fdce76006a68e5c1ab3314dc92e800eb83d906"
integrity sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==

commander@^12.1.0:
version "12.1.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-12.1.0.tgz#01423b36f501259fdaac4d0e4d60c96c991585d3"
integrity sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA==

[email protected], comment-parser@^1.4.0:
version "1.4.1"
resolved "https://registry.yarnpkg.com/comment-parser/-/comment-parser-1.4.1.tgz#bdafead37961ac079be11eb7ec65c4d021eaf9cc"
Expand Down

0 comments on commit d85c025

Please sign in to comment.