# decentraland-contract-plugins

> Decentraland Contracts Plugins

Latest version **2.2.0** (published 2021-02-15) · ISC license · 0 weekly downloads

## Install

```sh
npm install decentraland-contract-plugins
pnpm add decentraland-contract-plugins
yarn add decentraland-contract-plugins
bun add decentraland-contract-plugins
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.2.0 |
| Published | 2021-02-15 |
| First published | 2019-04-10 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 7 |
| Unpacked size | 92.5 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | decentralandbot |

## Links

- npm: https://www.npmjs.com/package/decentraland-contract-plugins
- Repository: https://github.com/decentraland/contracts-plugins
- Homepage: https://github.com/decentraland/contracts-plugins#readme
- Issues: https://github.com/decentraland/contracts-plugins/issues
- npm.io page: https://npm.io/package/decentraland-contract-plugins

## Dependencies (7)

- [ts-node](https://npm.io/package/ts-node.md) ^8.0.3
- [typescript](https://npm.io/package/typescript.md) ^4.1.3
- [bid-contract](https://npm.io/package/bid-contract.md) ^1.0.1
- [truffle-contract](https://npm.io/package/truffle-contract.md) ^4.0.11
- [decentraland-mana](https://npm.io/package/decentraland-mana.md) ^1.0.0
- [marketplace-contracts](https://npm.io/package/marketplace-contracts.md) ^2.0.0
- [openzeppelin-solidity](https://npm.io/package/openzeppelin-solidity.md) ^2.2.0

## Recent versions

- 2.2.0 (latest) — 2021-02-15
- 2.1.0 — 2021-02-15
- 2.0.4 — 2021-01-26
- 2.0.3 — 2021-01-26
- 2.0.2 — 2021-01-26
- 2.0.1 — 2021-01-25
- 2.0.0 — 2021-01-25
- 1.1.0 — 2019-12-27
- 1.0.6 — 2019-04-16
- 1.0.5 — 2019-04-16
- 1.0.4 — 2019-04-15
- 1.0.3 — 2019-04-15
- 1.0.2 — 2019-04-15
- 1.0.1 — 2019-04-15
- 1.0.0 — 2019-04-10

## README

# Contracts Plugins

⚠️ Work in progress - Collaboration is accepted

⚠️ Buidler Tasks are work in progress

Contracts Plugins is a set of usefull classes to deploy Decentraland contracts for testing purposes.

# Table

- [Install](#install)
- [Get started](#get-started)
- [Addresses](#addresses)
- [Contracts](#contracts)
  - [MANA](#mana)
  - [ERC721](#erc721)
  - [Marketplace](#marketplace)
  - [Bid](#bid)
  - [Listing](#listing)

## Install

`npm i --save-dev contracts-plugins`

## Get started

To deploy your Decentraland fake contracts just import the contract you want to use and `deploy` it. Every contract is deployed within initial settings to let you focus **only** in testing your new contracts.

_exchange.spec.ts_

```typescript
import { Mana, ADDRESS_INDEXES } from 'contracts-plugins'

const BN = web3.utils.BN
const expect = require('chai').use(require('bn-chai')(BN)).expect

describe('Exchange', function() {
  let accounts
  let deployer
  let mana
  let manaContract

  beforeEach(async function() {
    accounts = await web3.eth.getAccounts()
    deployer = accounts[ADDRESS_INDEXES.deployer]

    mana = new Mana({ accounts, artifacts })
    manaContract = await mana.deploy({
      txParams: {
        from: deployer,
        gas: 6e6,
        gasPrice: 21e9
      }
    })
  })

  it('should set initial balances', async function() {
    for (let account of accounts) {
      let balance = await manaContract.balanceOf(account)
      expect(balance).to.eq.BN(web3.utils.toWei('1000', 'ether'))
    }
  })
})
```

Contracts could need other contract addresses to be deployed and be ready for testing as the [Marketplace contract](#marketplace).

## Addresses

The contracts allowed are based on the accounts from set when running ganache:

| index | name                  |
| ----- | --------------------- |
| 0     | deployer              |
| 1     | user                  |
| 2     | anotherUser           |
| 3     | operator              |
| 4     | anotherOperator       |
| 5     | updateOperator        |
| 6     | anotherUpdateOperator |
| 7     | buyer                 |
| 8     | anotherBuyer          |
| 9     | bidder                |
| 10    | anotherBidder         |
| 11    | hacker                |

Use ths [script](#link_al_script)

## Contracts

Every contract is deployed by the `deployer` account.

### MANA

Simulates Decentraland MANA contract

#### deploy

Deploy the MANA contract, set initial balances for all the accounts and return the contrcact reployed

```typescript
mana.deploy(options)
```

#### addBalances

Min `amount` into every account of `accounts`.

```typescript
mana.addBalances(accounts: string[], amount: string)
```

#### removeBalances

Remove balances from `accounts`.

```typescript
mana.removeBalances(accounts: string[])
```

#### getContract

Get the deployed MANA contract

```typescript
mana.getContract()
```

### ERC721

ERC721 generic contract

#### deploy

Deploy an ERC721 contract and mint initial tokens:

- `1` to [user](#addresses)
- `2` to [anotherUser](#addresses)

#### getContract

Get the deployed erc721 contract

### Marketplace

#### deploy

The marketplace contract needs to be initialized with an erc20 token as the accepted token
and an erc721 token as the legacyNFT (related to marketplace v1).
This contracts can be passed as properties of the deploy options. If not they will instanceated and deployed.

_options_

```typescript
type Marketplaceptions = {
  mana: Mana | null
  erc721: Erc721 | null
  txParams: TxParams
}
```

### Bid

#### deploy

The marketplace contract needs to be initialized with an erc20 token as the accepted token
and an erc721 token as the legacyNFT (related to marketplace v1).
This contracts can be passed as properties of the deploy options. If not they will instanceated and deployed.

_options_

```typescript
type Marketplaceptions = {
  mana: Mana | null
  erc721: Erc721 | null
  txParams: TxParams
}
```

### Listing

#### deploy

The marketplace contract needs to be initialized with an erc20 token as the accepted token
and an erc721 token as the legacyNFT (related to marketplace v1).
This contracts can be passed as properties of the deploy options. If not they will instanceated and deployed.

```

```

---
_Source: https://npm.io/package/decentraland-contract-plugins · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
