Code Monkey home page Code Monkey logo

amman's People

Contributors

aheckmann avatar austbot avatar jpbogle avatar mccjul avatar olgkv avatar stegabob avatar thlorenz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

amman's Issues

[Q] Config for metaplex testing

Trying to run some anchor testing, using same config as https://github.com/metaplex-foundation/js-next/blob/main/.ammanrc.js (pasted my exact one, below)

But I get the failure:
Caused By: Error: failed to send transaction: Transaction simulation failed: Attempt to load a program that does not exist

When I try to run:
metaplex.nfts().create.

Would love some guidance how to properly config to load metaplex programs into amman.

import { LOCALHOST, tmpLedgerDir } from '@metaplex-foundation/amman'
const path = require('path');
const mplCandyMachine = require('@metaplex-foundation/mpl-candy-machine');
const mplTokenMetadata = require('@metaplex-foundation/mpl-token-metadata');

function localDeployPath(programName) {
    return path.join(__dirname, 'test', 'programs', `${programName}.so`);
}

const accountProviders = {
    CandyMachine: mplCandyMachine.CandyMachine,
    CollectionPDA: mplCandyMachine.CollectionPDA,
    CollectionAuthorityRecord: mplTokenMetadata.CollectionAuthorityRecord,
    Edition: mplTokenMetadata.Edition,
    EditionMarker: mplTokenMetadata.EditionMarker,
    MasterEditionV2: mplTokenMetadata.MasterEditionV2,
    Metadata: mplTokenMetadata.Metadata,
    ReservationListV2: mplTokenMetadata.ReservationListV2,
    UseAuthorityRecord: mplTokenMetadata.UseAuthorityRecord
};

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

const programs = [
    {
        label: 'Token Metadata',
        programId: programIds.metadata,
        deployPath: localDeployPath('mpl_token_metadata'),
    },
    {
        label: 'Candy Machine',
        programId: programIds.candyMachine,
        deployPath: localDeployPath('mpl_candy_machine'),
    },
];

module.exports = {
    validator: {
        killRunningValidators: true,
        programs,
        jsonRpcUrl: LOCALHOST,
        websocketUrl: '',
        commitment: 'confirmed',
        ledgerDir: tmpLedgerDir(),
        resetLedger: true,
        verifyFees: false,
    },
    relay: {
        accountProviders,
    },
};

Not obvious that you need a cusper error resolver to assertError

When you call assertError on a transactionHandler with no errorResolver and include a typed error generated by Solita, you get a relatively unhelpful error message: not ok 39 Expected an error of type TreasuryIsNotEmptyError, but did not get a typed error. Got: 'custom program error: 0x178a' in the logs instead

New version breaks if you don't install ts-essentials globally

on running newest version of amman cli you get

node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module 'ts-essentials'
Require stack:
- /home/beanbopper/.nvm/versions/node/v16.10.0/lib/node_modules/@metaplex-foundation/amman/dist/relay/rest-server.js
- /home/beanbopper/.nvm/versions/node/v16.10.0/lib/node_modules/@metaplex-foundation/amman/dist/relay/server.js
- /home/beanbopper/.nvm/versions/node/v16.10.0/lib/node_modules/@metaplex-foundation/amman/dist/validator/init-validator.js
- /home/beanbopper/.nvm/versions/node/v16.10.0/lib/node_modules/@metaplex-foundation/amman/dist/validator/index.js
- /home/beanbopper/.nvm/versions/node/v16.10.0/lib/node_modules/@metaplex-foundation/amman/dist/utils/config.js
- /home/beanbopper/.nvm/versions/node/v16.10.0/lib/node_modules/@metaplex-foundation/amman/dist/cli/commands/start.js
- /home/beanbopper/.nvm/versions/node/v16.10.0/lib/node_modules/@metaplex-foundation/amman/dist/cli/commands/index.js
- /home/beanbopper/.nvm/versions/node/v16.10.0/lib/node_modules/@metaplex-foundation/amman/dist/cli/amman.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/home/beanbopper/.nvm/versions/node/v16.10.0/lib/node_modules/@metaplex-foundation/amman/dist/relay/rest-server.js:6:25)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/beanbopper/.nvm/versions/node/v16.10.0/lib/node_modules/@metaplex-foundation/amman/dist/relay/rest-server.js',
    '/home/beanbopper/.nvm/versions/node/v16.10.0/lib/node_modules/@metaplex-foundation/amman/dist/relay/server.js',
    '/home/beanbopper/.nvm/versions/node/v16.10.0/lib/node_modules/@metaplex-foundation/amman/dist/validator/init-validator.js',
    '/home/beanbopper/.nvm/versions/node/v16.10.0/lib/node_modules/@metaplex-foundation/amman/dist/validator/index.js',
    '/home/beanbopper/.nvm/versions/node/v16.10.0/lib/node_modules/@metaplex-foundation/amman/dist/utils/config.js',
    '/home/beanbopper/.nvm/versions/node/v16.10.0/lib/node_modules/@metaplex-foundation/amman/dist/cli/commands/start.js',
    '/home/beanbopper/.nvm/versions/node/v16.10.0/lib/node_modules/@metaplex-foundation/amman/dist/cli/commands/index.js',
    '/home/beanbopper/.nvm/versions/node/v16.10.0/lib/node_modules/@metaplex-foundation/amman/dist/cli/amman.js'
  ]
}

This can be fixed by installing ts-essentials globally but I think this should be part of the package itself.

Be able to assign RPC port

So I have a particular use case in which I am running amman in a docker container and spawning it to do testing of my contracts and apis via heroku. I am able to make the container work however, heroku does not respect the docker EXPOSE keywords and requires me to inject a port for the app to listen to. solana-test-validator has the --rpc-port command and it seems like it would work for this. I could add this to the project myself via a validator mapping but I would like to have feedback as another way would be to add extra arguments. Ex: amman start --extra="--rpc-port=8080"

feat: launch without config file

This is needed to use this as a tool unrelated to a particular contract or SDK and will be very useful for simple amman demos.

assertNone() not ignoring the txn errors

When using the built-in sendAndConfirmTransaction, assertNone doesn't seem to register and still returns the errors.

Example code:

await handler
  .sendAndConfirmTransaction(with_system_txn, [], { skipPreflight: true }, 'noSystemProgram')
  .assertNone();

Expected output:

nothing I dont think lel

Actual output:

## Problem
When skipping preflight you need to call ‘assertSuccess’ or ‘assertError’
directly on the Promise that is returned by the amman TransactionHandler.
Otherwise transaction errors go unhandled.
NOTE: that when no ‘skipPreflight’ option is provided then it defaults to ‘true’.
## Examples:
  await txHandler.sendAndConfirmTransaction(
    tx,
    signers,
  ).assertSuccess(t)
  await txHandler.sendAndConfirmTransaction(
    tx,
    signers,
    { skipPreflight: true, commitment: ‘confirmed’ },
  )
  .assertError(t, StakeDoesNotMatchError)
  .then((res: ConfirmedTransactionDetails) => console.log(res.txSignature))
## Workaround
Alternatively you can ignore this error by calling ‘assertNone’ on the returned Promise.
await txHandler.sendAndConfirmTransaction(
  tx,
  signers,
).assertNone()
## Origin
    at PayerTransactionHandler.sendAndConfirmTransaction (/Users/sammyharris/metaplex-studios/sammy/cpi-test/node_modules/@metaplex-foundation/amman-client/src/transactions/transaction-handler.ts:61:12)
    at main (/Users/sammyharris/metaplex-studios/sammy/cpi-test/packages/test/src/test.ts:32:17)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at Immediate.<anonymous> (/Users/sammyharris/metaplex-studios/sammy/cpi-test/node_modules/@metaplex-foundation/amman-client/src/transactions/confirmed-transaction-assertable-promise.ts:75:17)
    at processImmediate (node:internal/timers:466:21)

Can't find account info file for account cloned from cluster

Hello!
I saw the same problem, but this issue was close.

Now, I get this error message, when run yarn amman:start from this repo

amman:error Error: Can't find account info file for account GymEN1BZjNJhhAvnP3PCVYCfHq9QQEoyFbkKgetcZSGk cloned from cluster https://api.metaplex.solana.com!

amman:error Make sure the account exists locally or on that cluster and try again.
amman:error at processAccounts (/Users/makuznetsov/work_dir/js/node_modules/@metaplex-foundation/amman/dist/validator/process-accounts.js:29:23)
amman:error at async buildSolanaValidatorArgs (/Users/makuznetsov/work_dir/js/node_modules/@metaplex-foundation/amman/dist/validator/solana-validator.js:46:69)
amman:error at async initValidator (/Users/makuznetsov/work_dir/js/node_modules/@metaplex-foundation/amman/dist/validator/init-validator.js:50:136)
amman:error at async handleStartCommand (/Users/makuznetsov/work_dir/js/node_modules/@metaplex-foundation/amman/dist/cli/commands/start.js:36:9)
amman:error at async main (/Users/makuznetsov/work_dir/js/node_modules/@metaplex-foundation/amman/dist/cli/amman.js:154:34) +0ms

But this account exist and i have last version solana

solana --version
solana-cli 1.10.29 (src:7f1fb145; feat:1425680972)

Can you help me resolve this problem?

Cannot disable relay from the configs

Hey 👋

I've encountered a small bug on the Amman configs. Globally disabling the relay from the config does not seem to work as the Amman client will still try to connect to it.

How to replicate

Given the following configs,

relay: {
  enabled: false,
},

When we start Amman, we get the following error:

'request:relay-version' timed out
/Users/loris/Code/spl-clients/node_modules/.pnpm/@[email protected]/node_modules/@metaplex-foundation/amman-client/dist/relay/client.js:198
            const timeout = (0, timeout_1.createTimeout)(timeoutMs, new Error(`Unable to ${action}. ${AMMAN_NOT_RUNNING_ERROR}`), (reason) => {
                                                                    ^

Error: Unable to fetch version. , is amman running with the relay enabled?
If not please start it as part of amman in a separate terminal via `amman start`
Make sure to set `relay: { enabled: true }` in `.ammanrc.js`.
Alternatively set environment var `CI=1` in your current terminal or
instantiate amman via `const amman = Amnnan.instance({ connectClient: false })`
    at /Users/loris/Code/spl-clients/node_modules/.pnpm/@[email protected]/node_modules/@metaplex-foundation/amman-client/dist/relay/client.js:198:69
 ELIFECYCLE  Command failed with exit code 1.

Current workaround

To go around this, I've got to set CI=1 on the terminal since this will tell both the server and the client not to use a relay.

Allow custom log message on assertSuccess and assertError

Currently, both assertSuccess and assertError allows you to specify a particular regex to be present in the log of the transaction. In most cases, this is enough to provide feedback on what the assert is testing. E.g.:

  • match '/SetAuthority/i' in log messages tells you that the transaction was successful and the SetAuthority log was found

There are scenarios where there is not a specific log message that you are interested, but you still would like to provide context to the assert. For example, when creating a candy machine, an assertSuccess will give you the default message 'transaction summary has no transaction error'. While the purpose of the assert was only to test whether the transaction succeeded or not, it would be useful to provide an optional log message that would replace the default one. E.g.:

  • await tx.assertSuccess(t, [], 'candy machine created')

This could also be used in combination with msgRxs:

  • await tx.assertSuccess(t, [/SetAuthority/i], 'authority changed')

Can't find account info file for account cloned from cluster

OSX, M1

my config:

module.exports = {
    validator: {
        accountsCluster: "https://api.mainnet-beta.solana.com",
        accounts: [
            {
                label: "Goki Smart Wallet Program",
                accountId: "GokivDYuQXPZCWRkwMhdH2h91KpDQXBEmpgBgs55bnpH",
                executable: true,
            },
        ],
    },
};

blows up with an error on amman start

Loading config from /Users/nathanleclaire/worknet/.ammanrc.js
Running validator with 0 custom program(s) and 1 remote account(s) preloaded
Launching new solana-test-validator with programs predeployed and ledger at /var/folders/ps/6j4p5ftd2jq3rqc886kx2l7m0000gn/T/amman-ledger
Saving account GokivDYuQXPZCWRkwMhdH2h91KpDQXBEmpgBgs55bnpH from cluster https://api.mainnet-beta.solana.com
Saving executable data for GokivDYuQXPZCWRkwMhdH2h91KpDQXBEmpgBgs55bnpH from cluster https://api.mainnet-beta.solana.com
Error: Can't find account info file for account GokivDYuQXPZCWRkwMhdH2h91KpDQXBEmpgBgs55bnpH cloned from cluster https://api.mainnet-beta.solana.com! 
Make sure the account exists locally or on that cluster and try again.
    at processAccounts (/Users/nathanleclaire/.nvm/versions/node/v16.15.0/lib/node_modules/@metaplex-foundation/amman/dist/validator/process-accounts.js:29:23)
    at async buildSolanaValidatorArgs (/Users/nathanleclaire/.nvm/versions/node/v16.15.0/lib/node_modules/@metaplex-foundation/amman/dist/validator/solana-validator.js:46:69)
    at async initValidator (/Users/nathanleclaire/.nvm/versions/node/v16.15.0/lib/node_modules/@metaplex-foundation/amman/dist/validator/init-validator.js:50:136)
    at async handleStartCommand (/Users/nathanleclaire/.nvm/versions/node/v16.15.0/lib/node_modules/@metaplex-foundation/amman/dist/cli/commands/start.js:36:9)
    at async main (/Users/nathanleclaire/.nvm/versions/node/v16.15.0/lib/node_modules/@metaplex-foundation/amman/dist/cli/amman.js:154:34)
Rerun `amman --help` for more information

WS fails to connect

I am trying to run amman and get following and it keeps printing last line

$ amman start
Loading config from /home/saber/code/baxus-anchor/.ammanrc.js
Running validator with 1 custom program(s) and 0 remote account(s) preloaded
Launching new solana-test-validator with programs predeployed and ledger at ./test-ledger
Successfully launched Relay at :::50474
ws error: connect ECONNREFUSED 127.0.0.1:8900
Successfully launched MockStorageServer at :::50475
ws error: connect ECONNREFUSED 127.0.0.1:8900
ws error: connect ECONNREFUSED 127.0.0.1:8900

Config:

module.exports = {
  validator: {
    killRunningValidators: true,
    programs: [
      { 
        label: 'Token Metadata Program',
        programId: 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s',
        deployPath: '../metaplex-program-library/token-metadata/'
      },
    ],
    jsonRpcUrl: 'localhost',
    websocketUrl: 'localhost',
    commitment: 'confirmed',
    ledgerDir: './test-ledger',
    resetLedger: true,
    verifyFees: false,
    detached: process.env.CI != null,
  },
  relay: {
    enabled: process.env.CI == null,
    killlRunningRelay: true,
  },
  storage: {
    enabled: process.env.CI == null,
    storageId: 'mock-storage',
    clearOnStart: true,
  },
}

Address label fetch error

Fails to start. Console output is

Running validator with 3 custom program(s) preloaded
Spawning new solana-test-validator with programs predeployed and ledger at /var/folders/5m/vqbbq3kd4yq047ml6536k52h0000gn/T/amman-ledger
solana-test-validator is up
> Streaming transaction logs. Confirmed commitment
Waiting for fees to stabilize 1...
/opt/homebrew/lib/node_modules/@metaplex-foundation/amman/dist/relay/client.js:68
            const timeout = (0, timeout_1.createTimeout)(2000, new Error(AMMAN_UNABLE_FETCH_LABELS + AMMAN_NOT_RUNNING_ERROR), reject);
                                                               ^

Error: Unable to connect to fetch address labels, is amman running with the relay enabled?
If not please start it as part of amman in a separate terminal via `amman start`
Make sure to set `relay: { enabled: false }` in `.ammanrc.js`.
Alternatively set environment var `CI=1` in your current terminal or
instantiate amman via `const amman = Amnnan.instance({ connectClient: false })`
    at /opt/homebrew/lib/node_modules/@metaplex-foundation/amman/dist/relay/client.js:68:64
    at new Promise (<anonymous>)
    at ConnectedAmmanClient.fetchAddressLabels (/opt/homebrew/lib/node_modules/@metaplex-foundation/amman/dist/relay/client.js:67:16)
    at AddressLabels.getRemoteLabelAddresses (/opt/homebrew/lib/node_modules/@metaplex-foundation/amman/dist/diagnostics/address-labels.js:201:53)
    at new AddressLabels (/opt/homebrew/lib/node_modules/@metaplex-foundation/amman/dist/diagnostics/address-labels.js:126:14)
    at Function.setInstance (/opt/homebrew/lib/node_modules/@metaplex-foundation/amman/dist/diagnostics/address-labels.js:271:35)
    at Function.instance (/opt/homebrew/lib/node_modules/@metaplex-foundation/amman/dist/api.js:127:65)
    at cliAmmanInstance (/opt/homebrew/lib/node_modules/@metaplex-foundation/amman/dist/cli/utils/resolvers.js:7:24)
    at handleStartCommand (/opt/homebrew/lib/node_modules/@metaplex-foundation/amman/dist/cli/commands/start.js:37:76)
    at async main (/opt/homebrew/lib/node_modules/@metaplex-foundation/amman/dist/cli/amman.js:133:34)

Node.js v17.8.0

With config

'use strict';
// @ts-check
const { LOCALHOST, tmpLedgerDir } = require('@metaplex-foundation/amman');
const base = require('../../.ammanrc.js');

const validator = {
  ...base.validator,
  jsonRpcUrl: LOCALHOST,
  programs: [
      base.programs.metadata, 
      base.programs.tokenEntangler, 
      base.programs.tokenFuser
    ],
};

const relay = {
  enabled: false
}
module.exports = { validator, relay };

[feat]: mock storage server

Value

In order try and test NFT uploads and see the results as they would for real without having to setup and upload to an actual storage provider, the artifacts need to be stored somewhere and then provided via a URL.
This allows them to show in the amman explorer as well as could be downloaded in tests for diagnostic purposes.

It also will make it easier to demo our SDK + related tooling as we can show the full picture.

Implementation

The server will be used in order to simulate a storage provider like bundlr/arweave.

The amman API will provide a StorageProvider interface which tests/apps/libs use to upload NFTs. It will store the results of that upload in a designated temporary folder on disk. The metadata for the uploaded artifacts will include a predetermined URI that ends up pointing at the amman mock storage server.

The mock storage server, configured as part of .ammanrc.js will know how to resolve the stored artifacts from that location and expose them at the predetermined URI (configured in .ammanrc.js).

When launching amman start that mock storage server will launch with it if it is configured.
amman stop will kill that storage server if it is running along with the solana-test-validator and the amman relay.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.