Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
feat(PTP-404): deploy erc721mintable contract
Browse files Browse the repository at this point in the history
  • Loading branch information
salimtb committed May 25, 2022
1 parent d25c668 commit 51bb3fb
Show file tree
Hide file tree
Showing 12 changed files with 26,197 additions and 24 deletions.
4 changes: 2 additions & 2 deletions e2e/readContract.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { config as loadEnv } from 'dotenv';
import SDK from '../lib/SDK/SDK';
import SDK from '../lib/SDK/sdk';
import Auth from '../lib/Auth/Auth';

loadEnv();

describe('E2E Test: SDK (read)', () => {
describe('E2E Test: Sdk (read)', () => {
jest.setTimeout(120 * 1000);
let sdk;

Expand Down
45 changes: 45 additions & 0 deletions e2e/writeContract.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { config as loadEnv } from 'dotenv';
import Auth from '../lib/Auth/Auth';
import SDK from '../lib/SDK/sdk';
import { TEMPLATES } from '../lib/NFT/constants';

loadEnv();
let sdk;
let account;

describe('E2E Test: Basic NFT (write)', () => {
jest.setTimeout(120 * 1000);

beforeAll(async () => {
const privateKey = process.env.PRIVATE_KEY;
const rpcUrl = process.env.RPC_URL;
const chainId = 4;
const projectId = process.env.PROJECT_ID;
const secretId = process.env.SECRET_ID;
const IPFS = { IPFSProjectID: '', IPFSProjectSecret: '' };

account = new Auth({
privateKey,
projectId,
secretId,
rpcUrl,
chainId,
IPFS,
});

sdk = new SDK(account);
});

it('should return deployed contract', async () => {
const contractObject = await sdk.deploy({
template: TEMPLATES.ERC721Mintable,
params: {
name: 'Cool Contract',
symbol: 'CC',
contractURI: 'URI',
},
});

expect(contractObject).not.toBe(null);
});
});
9 changes: 6 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
* MIT Licensed
*/

import { ExternallyOwnedAccount } from './lib/NFT/externallyOwnedAccount.js';
import Sdk from './lib/SDK/sdk';
import Auth from './lib/Auth/Auth';
import { TEMPLATES } from './lib/NFT/constants';

export * from './lib/NFT/externallyOwnedAccount.js';
export default {
ExternallyOwnedAccount,
SDK: Sdk,
Auth,
TEMPLATES,
};
30 changes: 15 additions & 15 deletions legal/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
## Pseudo flow

Pseudo User flow.
End user should be able to configure and use SDK as clean as possible.
End user should be able to configure and use Sdk as clean as possible.
Design patterns to consider: Facade, Delegate, Builder.


## Start


1. Developer imports dependencies
1. Developer imports dependencies
> *Usage: npm install dotenv --save*
```sh
import 'dotenv/config'
```

2. Developer imports the Consensys SDK
2. Developer imports the Consensys Sdk
> *Usage: npm install csys-sdk --save*
```sh
Expand All @@ -33,7 +33,7 @@ const PRIVATE_KEY = process.env.PRIVATE_KEY
const API_KEY = process.env.INFURA_API_KEY
```

4. Developer create & configue instance of the Consensys Client
4. Developer create & configue instance of the Consensys Client

```sh
const client = new ConsensysClient(API_KEY)
Expand All @@ -60,40 +60,40 @@ const mintNft = await nftClient.mint('tokenURI');
const getNft = await nftClient.get('tokenURI');
```

7. Response from completed Tx is received and logged
7. Response from completed Tx is received and logged

```sh
console.log('nft:mint', mintNft);
console.log('nft:get', getNft);
```


## Next SDK Phase

In next phase to unlock more SDK features users can work on ConsensysClient,
e.g.
## Next Sdk Phase

In next phase to unlock more Sdk features users can work on ConsensysClient,
e.g.

GasEstimation module:
ConsensysClient.GasEstimation()

Token module:
ConsensysClient.Token()

Idea is that SDK features/modules are exposed via internal SDK API.

Downside of this approach is that users will need to import full SDK instead of only modules they need.
Idea is that Sdk features/modules are exposed via internal Sdk API.

Downside of this approach is that users will need to import full Sdk instead of only modules they need.
Maybe workaround can be to move auth into separate module so that it can be imported as standalone module
e.g.


import { AuthClient } from '@consensys-sdk/core'
import { Nft } from '@consensys-sdk/common'
import { GasEstimation, Token } from '@consensys-sdk/common'


this way user imports modules as required while keeping code base reasonably low.
Downside of this approach is that it takes more time to develop but certainly improves quality and extendibility of the SDK.
Downside of this approach is that it takes more time to develop but certainly improves quality and extendibility of the Sdk.


## MVP Features
Expand Down
Loading

0 comments on commit 51bb3fb

Please sign in to comment.