Skip to content

Latest commit

 

History

History
197 lines (135 loc) · 4.46 KB

README.md

File metadata and controls

197 lines (135 loc) · 4.46 KB

NOMO Nouns Contract SDKs

This package contains the TypeScript SDK for interacting with the NOMO Nouns smart contracts.

This package was automatically generated by eth-sdk. Don't edit its source code, it will be rewritten when you run eth-sdk next time.


index.cjs, index.d.ts, index.mjs, types.d.ts and package.json here are static files copied from eth-sdk/static to the generated package.

You can find your generated files in ./esm and ./cjs directories.

SDK Structure

The contract SDK has the following structure:

  • eth-sdk/ - Configuration for eth-sdk tool
    • abis/ - Contract ABIs for different networks
    • config.ts - Contract addresses configuration
  • cjs/ - CommonJS output (generated)
  • esm/ - ES Modules output (generated)

Updating the SDK

When you need to add support for a new network or update contract addresses:

  1. Update the configuration file:

    # Edit the eth-sdk config file
    nano eth-sdk/config.ts

    Add or update the network configuration:

    export default defineConfig({
      contracts: {
        // Existing networks...
        
        // Add new network (e.g., optimismSepolia)
        optimismSepolia: {
          nomoToken: "0x0a84d15E7Ed226a5934Fa33A1d73d62152d59Da7",
          nomoSeeder: "0x8E5870B947703E3073C15033Cc7522FDFcc7332A",
        }
      },
      outputPath: "./",
    });
  2. Add contract ABIs:

    Ensure the ABIs for the contracts are available in the corresponding network directory:

    # Create directory for the new network (if it doesn't exist)
    mkdir -p eth-sdk/abis/optimismSepolia
    
    # Add the contract ABIs
    cp path/to/NomoToken.json eth-sdk/abis/optimismSepolia/nomoToken.json
    cp path/to/NomoSeeder.json eth-sdk/abis/optimismSepolia/nomoSeeder.json

    You can typically find the ABIs in the artifacts directory of the contracts package after compilation.

Building the SDK

To build the SDK with the updated configuration:

  1. Install ts-node (if not already installed, required by eth-sdk):

    yarn add -D ts-node
  2. Update the package version:

    # Edit package.json to increment the version
    nano package.json

    Update the version number (e.g., from 1.2.2 to 1.2.3).

  3. Generate the SDK:

    # Run eth-sdk to generate the TypeScript files
    npx @dethcrypto/eth-sdk -p ./eth-sdk
  4. Create a tarball:

    # Create a tarball of the package
    npm pack

    This will create a file like nomo-nouns-contract-sdks-1.2.3.tgz.

  5. Move the tarball to the functions directory:

    # Move the tarball to the functions directory
    mv nomo-nouns-contract-sdks-1.2.3.tgz ../nomo-nouns-webapp/functions/

Using the Updated SDK

To use the updated SDK in your project:

  1. Update the functions package.json:

    # Navigate to the functions directory
    cd ../nomo-nouns-webapp/functions
    
    # Edit package.json
    nano package.json

    Update the dependency:

    "dependencies": {
      "nomo-nouns-contract-sdks": "file:./nomo-nouns-contract-sdks-1.2.3.tgz"
    }
  2. Install the updated package:

    # Install the package
    yarn add file:./nomo-nouns-contract-sdks-1.2.3.tgz
  3. Update the webapp package.json (if needed):

    # Navigate to the webapp directory
    cd ../
    
    # Edit package.json
    nano package.json

    Update the dependency version to match if the webapp directly uses the SDK.

  4. Build the functions project:

    # Build the project
    cd functions
    yarn build

Troubleshooting SDK Issues

If you encounter issues with the SDK:

  1. Check if eth-sdk generated the files correctly:

    # Look for files related to the new network
    find . -name "*optimismSepolia*" -type f
  2. Verify the type declarations:

    # Check for type declarations
    grep -r "optimismSepolia" --include="*.d.ts" .
  3. Clean and rebuild:

    If necessary, you can back up and remove the generated files before rebuilding:

    # Back up existing files
    mkdir -p backup
    mv cjs esm backup/
    
    # Regenerate the SDK
    npx @dethcrypto/eth-sdk -p ./eth-sdk
  4. Check for missing dependencies:

    If you get errors about missing dependencies when running eth-sdk:

    # Install common dependencies needed by eth-sdk
    yarn add -D ts-node typescript @types/node