metaplex-foundation / amman

A modern mandatory toolbelt to help test solana SDK libraries and apps on a locally running validator.
https://metaplex-foundation.github.io/amman/docs/
Apache License 2.0
72 stars 17 forks source link

fix: minor changes #3

Closed olgkv closed 2 years ago

olgkv commented 2 years ago
thlorenz commented 2 years ago

I'd love to merge the spelling fix in so please remove all other changes and provide the other changes in a separate PR so we can discuss if/how to merge them in there. Please keep PRs focused on one aspect in the future so it's easier to accept them.

The title of the PR should be able to express the feature added or bug it fixed. If the title ends up being something like various/misc fixes/features or similar then that indicates that it's not focused enough.

thlorenz commented 2 years ago

I pulled in the spelling fix since I needed to publish a new version. We can discuss here regarding those other changes ... however if you agree with what I said above please close this PR.

Thanks!

olgkv commented 2 years ago

The reason I open the PR was not my personal preference of styling, how to check properties and certainly not looking for typos.

Let me explain the problem:

Create the project, install @metaplex-foundation/amman, add configuration file .ammanrc with contents you gave me before

$ ls -la
drwxr-xr-x  3 oleg oleg  4096 Dec 10 15:21 ./
drwxr-xr-x 22 oleg oleg  4096 Dec 10 12:04 ../
-rw-r--r--  1 oleg oleg   965 Dec 12 00:12 .ammanrc.js
drwxr-xr-x 81 oleg oleg  4096 Dec 12 00:10 node_modules/
-rw-r--r--  1 oleg oleg   158 Dec 12 00:10 package.json
-rw-r--r--  1 oleg oleg 29033 Dec 12 00:10 yarn.lock
$ cat package.json 
{
  "name": "amman-tmp",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "dependencies": {
    "@metaplex-foundation/amman": "^0.0.3"
  }
}
$ cat .ammanrc.js 
// @ts-check
'use strict';
const path = require('path');

const localDeployDir = path.join(__dirname, 'target', 'deploy');

const programIds = {
  metadata: 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s',
  vault: 'vau1zxA2LbssAUEF7Gpw91zMM1LvXrvpzJtmZ58rPsn',
  auction: 'auctxRXPeJoc4817jDhf4HbjnhEcr1cCXenosMhK5R8',
  metaplex: 'p1exdMJcjVao65QdewkaZRUnU6VPSXhus9n2GzWfh98',
};

function localDeployPath(programName) {
  return path.join(localDeployDir, `${programName}.so`);
}
const programs = {
  metadata: { programId: programIds.metadata, deployPath: localDeployPath('mpl_token_metadata') },
  vault: { programId: programIds.vault, deployPath: localDeployPath('mpl_token_vault') },
  auction: { programId: programIds.auction, deployPath: localDeployPath('mpl_auction') },
  metaplex: { programId: programIds.metaplex, deployPath: localDeployPath('mpl_metaplex') },
};

const validator = {
  verifyFees: true
};

module.exports = {
  programs,
  validator,
};

After these steps, I run the command:

$ npx amman validator

And I get errors:


TypeError: Cannot read properties of undefined (reading 'length')
    at handleValidatorCommand (/home/oleg/meta/amman-tmp/node_modules/@metaplex-foundation/amman/dist/cli/commands/validator.js:23:82)
    at async main (/home/oleg/meta/amman-tmp/node_modules/@metaplex-foundation/amman/dist/cli/amman.js:23:30)
Having trouble loading amman config from [object Object] which resolved to /home/oleg/meta/amman-tmp/.ammanrc.js
amman validator [config]

Launches a solana-test-validator

Positionals:
  config  File containing config with `validator` property.

Options:
  --version  Show version number                                       [boolean]
  --help
              amman validator <config.js>

              The config should be a JavaScript module exporting 'validator'
              with any of the below properties:

              killRunningValidators: if true will kill any
              solana-test-validators currently running on the system.

              programs: bpf programs which should be loaded into the test
              validator

              jsonRpcUrl: the URL at which the test validator should listen for
              JSON RPC requests

              websocketUrl: for the RPC websocket

              ledgerDir: where the solana test validator writes the ledger

              resetLedger: if true the ledger is reset to genesis at startup

              verifyFees: if true the validator is not considered fully started
              up until it charges transaction fees
                                                                       [boolean]

That's it. @thlorenz I would be grateful if you would point out the solution to the problem, which is more suitable for you. I don't insist on merging the PR, I just want to run amman - needed for job :)

thlorenz commented 2 years ago

I can help you out more on Monday, but mainly your problem is that your config doesn't match the type of 'programs` of the amman config. Please consult this example closely to see what I mean.

Namely this is an object hash:

const programs = {
  metadata: { programId: programIds.metadata, deployPath: localDeployPath('mpl_token_metadata') },
  vault: { programId: programIds.vault, deployPath: localDeployPath('mpl_token_vault') },
  auction: { programId: programIds.auction, deployPath: localDeployPath('mpl_auction') },
  metaplex: { programId: programIds.metaplex, deployPath: localDeployPath('mpl_metaplex') },
};

but the config expects an array.

I feel like you tried to change amman to make up for that discrepancy when you ran into issues. I pointed that out as well. Instead you should make your config (namely programs) be of the type that amman expects.

olgkv commented 2 years ago

Thanks. That's all wanted to know, that the config I used does not meet the requirements