@flowtyio/flow-contracts 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/README.md +28 -1
  2. package/add.js +5 -1
  3. package/index.js +1 -1
  4. package/package.json +1 -6
package/README.md CHANGED
@@ -4,6 +4,33 @@
4
4
  npm i @flowty/flow-contracts
5
5
  ```
6
6
 
7
+ ## Commands
8
+
9
+ **These commands assume you have installed flow-contracts and npx on your machine**
10
+
11
+ You can use `flow-contracts` to edit your own flow configuration so that you don't have to manually add contracts to your project.
12
+ Currently, there are two commands:
13
+ - add -> adds a contract and its dependencies to your flow.json
14
+ - add-all -> adds all contracts in this repo to your flow.json
15
+
16
+ ### Add a contract
17
+
18
+ Adds a contract and its dependencies to your flow.json. This command will also add the contract to your emulator deployment section.
19
+ If there are any contracts already defined in your config which would be imported, it will be skipped
20
+
21
+ ```
22
+ npx flow-contracts add MetadataViews -c /path/to/config/flow.json
23
+ ```
24
+
25
+ ### Add all contracts
26
+
27
+ Adds all contracts maintained in this repo to your own flow.json, and add them to your emulator deployment section.
28
+
29
+ ```
30
+ npx flow-contracts add-all -c /path/to/config/flow.json
31
+ ```
32
+
33
+
7
34
  This repository publishes common Flow contracts as an npm package so that they can be more easily consumed.
8
35
  Currently, the list includes:
9
36
 
@@ -102,4 +129,4 @@ you will need to:
102
129
  If you would like to request other contracts be included, please create a ticket, or submit a PullRequest to add them and
103
130
  ping us on Twitter/Discord.
104
131
 
105
- Cheers!
132
+ Cheers!
package/add.js CHANGED
@@ -48,6 +48,8 @@ const importContract = (contractName, source, config, account) => {
48
48
  return
49
49
  }
50
50
 
51
+ contract.source = `./node_modules/@flowtyio/flow-contracts/contracts/${contractName}.cdc`
52
+
51
53
  if (specialContractsHandlers[contractName]) {
52
54
  specialContractsHandlers[contractName](contract, newConfig, account)
53
55
  } else {
@@ -70,12 +72,14 @@ const add = ({name, config, account}) => {
70
72
 
71
73
  const exampleConfigLocation = `${__dirname}/flow.json`
72
74
  const exampleConfig = getConfig(exampleConfigLocation)
73
- const contract = exampleConfig.contracts[name]
75
+ let contract = exampleConfig.contracts[name]
74
76
  if (!contract) {
75
77
  console.error(`Contract "${name}" could not be found`)
76
78
  return
77
79
  }
78
80
 
81
+ contract.source = `./node_modules/@flowtyio/flow-contracts/contracts/${name}.cdc`
82
+
79
83
  if (!userConfig.contracts) {
80
84
  userConfig.contracts = {}
81
85
  }
package/index.js CHANGED
@@ -10,7 +10,7 @@ program
10
10
  .description("A CLI to help manage and import Flow contracts")
11
11
 
12
12
  program.command('add')
13
- .description('Add a contract to your flow.json config')
13
+ .description('Add a contract (and its dependencies) to your flow.json config')
14
14
  .argument('<contractName>', 'The contract to be added')
15
15
  .option('-c, --config <config>', 'File location of the config to be edited')
16
16
  .option('-a, --account <account>', 'Account that will deploy this imported contract', 'emulator-account')
package/package.json CHANGED
@@ -1,13 +1,10 @@
1
1
  {
2
2
  "name": "@flowtyio/flow-contracts",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "main": "index.json",
5
5
  "description": "An NPM package for common flow contracts",
6
6
  "author": "flowtyio",
7
7
  "license": "MIT",
8
- "scripts": {
9
- "add": "node ./index.js add"
10
- },
11
8
  "repository": {
12
9
  "type": "git",
13
10
  "url": "git+https://github.com/Flowtyio/flow-contracts.git"
@@ -23,8 +20,6 @@
23
20
  },
24
21
  "homepage": "https://github.com/Flowtyio/flow-contracts/blob/main/README.md",
25
22
  "dependencies": {
26
- "command-line-args": "^5.2.1",
27
- "command-line-commands": "^3.0.2",
28
23
  "commander": "^11.0.0"
29
24
  },
30
25
  "bin": {