agoric 0.21.2-dev-c65915e.0 → 0.21.2-dev-4440ce1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +20 -20
  2. package/src/commands/wallet.js +33 -15
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agoric",
3
- "version": "0.21.2-dev-c65915e.0+c65915e",
3
+ "version": "0.21.2-dev-4440ce1.0+4440ce1",
4
4
  "description": "Manage the Agoric Javascript smart contract platform",
5
5
  "type": "module",
6
6
  "main": "src/main.js",
@@ -29,29 +29,29 @@
29
29
  "lint:eslint": "eslint ."
30
30
  },
31
31
  "devDependencies": {
32
- "@agoric/cosmic-swingset": "0.41.4-dev-c65915e.0+c65915e",
33
- "@agoric/deploy-script-support": "0.10.4-dev-c65915e.0+c65915e",
32
+ "@agoric/cosmic-swingset": "0.41.4-dev-4440ce1.0+4440ce1",
33
+ "@agoric/deploy-script-support": "0.10.4-dev-4440ce1.0+4440ce1",
34
34
  "ava": "^5.3.0",
35
35
  "c8": "^9.1.0",
36
36
  "dd-trace": "^4.11.1"
37
37
  },
38
38
  "dependencies": {
39
- "@agoric/access-token": "0.4.22-dev-c65915e.0+c65915e",
40
- "@agoric/assert": "0.6.1-dev-c65915e.0+c65915e",
41
- "@agoric/cache": "0.3.3-dev-c65915e.0+c65915e",
42
- "@agoric/casting": "0.4.3-dev-c65915e.0+c65915e",
43
- "@agoric/cosmic-proto": "0.4.1-dev-c65915e.0+c65915e",
44
- "@agoric/ertp": "0.16.3-dev-c65915e.0+c65915e",
45
- "@agoric/governance": "0.10.4-dev-c65915e.0+c65915e",
46
- "@agoric/inter-protocol": "0.16.2-dev-c65915e.0+c65915e",
47
- "@agoric/internal": "0.3.3-dev-c65915e.0+c65915e",
48
- "@agoric/network": "0.1.1-dev-c65915e.0+c65915e",
49
- "@agoric/smart-wallet": "0.5.4-dev-c65915e.0+c65915e",
50
- "@agoric/store": "0.9.3-dev-c65915e.0+c65915e",
51
- "@agoric/swingset-vat": "0.32.3-dev-c65915e.0+c65915e",
52
- "@agoric/vats": "0.15.2-dev-c65915e.0+c65915e",
53
- "@agoric/zoe": "0.26.3-dev-c65915e.0+c65915e",
54
- "@agoric/zone": "0.2.3-dev-c65915e.0+c65915e",
39
+ "@agoric/access-token": "0.4.22-dev-4440ce1.0+4440ce1",
40
+ "@agoric/assert": "0.6.1-dev-4440ce1.0+4440ce1",
41
+ "@agoric/cache": "0.3.3-dev-4440ce1.0+4440ce1",
42
+ "@agoric/casting": "0.4.3-dev-4440ce1.0+4440ce1",
43
+ "@agoric/cosmic-proto": "0.4.1-dev-4440ce1.0+4440ce1",
44
+ "@agoric/ertp": "0.16.3-dev-4440ce1.0+4440ce1",
45
+ "@agoric/governance": "0.10.4-dev-4440ce1.0+4440ce1",
46
+ "@agoric/inter-protocol": "0.16.2-dev-4440ce1.0+4440ce1",
47
+ "@agoric/internal": "0.3.3-dev-4440ce1.0+4440ce1",
48
+ "@agoric/network": "0.1.1-dev-4440ce1.0+4440ce1",
49
+ "@agoric/smart-wallet": "0.5.4-dev-4440ce1.0+4440ce1",
50
+ "@agoric/store": "0.9.3-dev-4440ce1.0+4440ce1",
51
+ "@agoric/swingset-vat": "0.32.3-dev-4440ce1.0+4440ce1",
52
+ "@agoric/vats": "0.15.2-dev-4440ce1.0+4440ce1",
53
+ "@agoric/zoe": "0.26.3-dev-4440ce1.0+4440ce1",
54
+ "@agoric/zone": "0.2.3-dev-4440ce1.0+4440ce1",
55
55
  "@confio/relayer": "^0.11.3",
56
56
  "@cosmjs/crypto": "^0.32.3",
57
57
  "@cosmjs/encoding": "^0.32.3",
@@ -101,5 +101,5 @@
101
101
  "typeCoverage": {
102
102
  "atLeast": 76.99
103
103
  },
104
- "gitHead": "c65915e607dd7ccfd50c9b5f8ba1692240fb605b"
104
+ "gitHead": "4440ce11c9cc3db685606ed86c0fe7bd68ddc2f0"
105
105
  }
@@ -29,19 +29,26 @@ const SLEEP_SECONDS = 3;
29
29
  * @returns {Promise<import('commander').Command>}
30
30
  */
31
31
  export const makeWalletCommand = async command => {
32
- const wallet = command('wallet')
33
- .description('wallet commands')
34
- .option('--home <dir>', 'agd application home directory')
35
- .option(
36
- '--keyring-backend <os|file|test>',
37
- 'keyring\'s backend (os|file|test) (default "os")',
38
- );
32
+ /**
33
+ * @param {import('commander').Command} baseCmd
34
+ */
35
+ const withSharedTxOptions = baseCmd =>
36
+ baseCmd
37
+ .option('--home <dir>', 'agd application home directory')
38
+ .option(
39
+ '--keyring-backend <os|file|test>',
40
+ 'keyring\'s backend (os|file|test) (default "os")',
41
+ );
42
+ /** @typedef {{home?: string, keyringBackend: 'os' | 'file' | 'test'}} SharedTxOptions */
43
+
44
+ const wallet = withSharedTxOptions(command('wallet')).description(
45
+ 'wallet commands',
46
+ );
39
47
 
40
48
  const normalizeAddress = literalOrName =>
41
49
  normalizeAddressWithOptions(literalOrName, wallet.opts());
42
50
 
43
- wallet
44
- .command('provision')
51
+ withSharedTxOptions(wallet.command('provision'))
45
52
  .description('provision a Smart Wallet')
46
53
  .requiredOption(
47
54
  '--account [address]',
@@ -51,8 +58,14 @@ export const makeWalletCommand = async command => {
51
58
  .option('--spend', 'confirm you want to spend')
52
59
  .option('--nickname <string>', 'nickname to use', 'my-wallet')
53
60
  .action(function (opts) {
54
- const { account, nickname, spend } = opts;
55
- const { home, keyringBackend: backend } = wallet.opts();
61
+ /** @typedef {{account: string, spend?: boolean, nickname: 'my-wallet' | string }} Opts */
62
+ const {
63
+ account,
64
+ nickname,
65
+ spend,
66
+ home,
67
+ keyringBackend: backend,
68
+ } = /** @type {SharedTxOptions & Opts} */ ({ ...wallet.opts(), ...opts });
56
69
  const tx = ['provision-one', nickname, account, 'SMART_WALLET'];
57
70
  if (spend) {
58
71
  execSwingsetTransaction(tx, {
@@ -110,8 +123,7 @@ export const makeWalletCommand = async command => {
110
123
  console.log(offerObj.offer.id);
111
124
  });
112
125
 
113
- wallet
114
- .command('send')
126
+ withSharedTxOptions(wallet.command('send'))
115
127
  .description('send a prepared offer')
116
128
  .requiredOption(
117
129
  '--from [address]',
@@ -121,8 +133,14 @@ export const makeWalletCommand = async command => {
121
133
  .requiredOption('--offer [filename]', 'path to file with prepared offer')
122
134
  .option('--dry-run', 'spit out the command instead of running it')
123
135
  .action(function (opts) {
124
- const { dryRun, from, offer } = opts;
125
- const { home, keyringBackend: backend } = wallet.opts();
136
+ /** @typedef {{ from: string, offer: string, dryRun: boolean }} Opts */
137
+ const {
138
+ dryRun,
139
+ from,
140
+ offer,
141
+ home,
142
+ keyringBackend: backend,
143
+ } = /** @type {SharedTxOptions & Opts} */ ({ ...wallet.opts(), ...opts });
126
144
 
127
145
  const offerBody = fs.readFileSync(offer).toString();
128
146
  execSwingsetTransaction(['wallet-action', '--allow-spend', offerBody], {