Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discover #48

Merged
merged 7 commits into from
Jan 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cicd/test_script/steps/add-new-peer-org.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ sleep 5

# [orgnew] deploy chaincode
export_env 'peer' ${PEER_ORG_NAME_ORGNEW} ${PEER_ORG_DOMAIN_ORGNEW} 'peer0'
bdk chaincode deploy -C ${CHANNEL_NAME} -l ${CHAINCODE_LABEL} -I -a --orderer ${ORDERER_ORG_URL_ORG0_ORDERER0}
bdk chaincode install -l ${CHAINCODE_LABEL}
bdk chaincode approve -C ${CHANNEL_NAME} -l ${CHAINCODE_LABEL} -I # discover

# [orgnew] install only
export_env 'peer' ${PEER_ORG_NAME_ORGNEW} ${PEER_ORG_DOMAIN_ORGNEW} 'peer1'
Expand Down
12 changes: 7 additions & 5 deletions cicd/test_script/steps/chaincode.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,25 @@ bdk chaincode package -n fabcar -v 1 -p ./chaincode/fabcar/go

# deploy
export_env 'peer' ${PEER_ORG_NAME_ORG0} ${PEER_ORG_DOMAIN_ORG0} 'peer0'
bdk chaincode deploy -C ${CHANNEL_NAME} -l ${CHAINCODE_LABEL} -I -a --orderer ${ORDERER_ORG_URL_ORG0_ORDERER0}
bdk chaincode install -l ${CHAINCODE_LABEL}
bdk chaincode approve -C ${CHANNEL_NAME} -l ${CHAINCODE_LABEL} -I --orderer ${ORDERER_ORG_URL_ORG0_ORDERER0} # without discover
export_env 'peer' ${PEER_ORG_NAME_ORG0} ${PEER_ORG_DOMAIN_ORG0} 'peer1'
bdk chaincode install -l ${CHAINCODE_LABEL}
export_env 'peer' ${PEER_ORG_NAME_ORG0} ${PEER_ORG_DOMAIN_ORG0} 'peer2'
bdk chaincode install -l ${CHAINCODE_LABEL}

export_env 'peer' ${PEER_ORG_NAME_ORG1} ${PEER_ORG_DOMAIN_ORG1} 'peer0'
bdk chaincode deploy -C ${CHANNEL_NAME} -l ${CHAINCODE_LABEL} -I -a --orderer ${ORDERER_ORG_URL_ORG0_ORDERER0}
bdk chaincode install -l ${CHAINCODE_LABEL}
bdk chaincode approve -C ${CHANNEL_NAME} -l ${CHAINCODE_LABEL} -I # discover

export_env 'peer' ${PEER_ORG_NAME_ORG2} ${PEER_ORG_DOMAIN_ORG2} 'peer0'
bdk chaincode install -l ${CHAINCODE_LABEL}
bdk chaincode approve -C ${CHANNEL_NAME} -l ${CHAINCODE_LABEL} -I --orderer ${ORDERER_ORG_URL_ORG0_ORDERER0}
bdk chaincode commit -C ${CHANNEL_NAME} -l ${CHAINCODE_LABEL} -I --orderer ${ORDERER_ORG_URL_ORG0_ORDERER0} --peer-addresses ${PEER_ORG_URL_ORG0_PEER0} --peer-addresses ${PEER_ORG_URL_ORG1_PEER0} --peer-addresses ${PEER_ORG_URL_ORG2_PEER0}
bdk chaincode approve -C ${CHANNEL_NAME} -l ${CHAINCODE_LABEL} -I # discover
bdk chaincode commit -C ${CHANNEL_NAME} -l ${CHAINCODE_LABEL} -I # discover

# invoke init
export_env 'peer' ${PEER_ORG_NAME_ORG0} ${PEER_ORG_DOMAIN_ORG0} 'peer0'
bdk chaincode invoke -C ${CHANNEL_NAME} -n ${CHAINCODE_NAME} -I -f InitLedger --orderer ${ORDERER_ORG_URL_ORG1_ORDERER0} --peer-addresses ${PEER_ORG_URL_ORG0_PEER0} --peer-addresses ${PEER_ORG_URL_ORG1_PEER0} --peer-addresses ${PEER_ORG_URL_ORG2_PEER0}
bdk chaincode invoke -C ${CHANNEL_NAME} -n ${CHAINCODE_NAME} -I -f InitLedger # discover

# [Org0] invoke & query
export_env 'peer' ${PEER_ORG_NAME_ORG0} ${PEER_ORG_DOMAIN_ORG0} 'peer0'
Expand Down
79 changes: 31 additions & 48 deletions docs/COMMANDS.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,47 +97,30 @@ Description: Enroll certificates.

Description: 代表環境變數中 BDK_ORG_NAME 的 Peer org 同意 Chaincode

| Options | Type | Description | Required | Default |
| --------------------- | :-----: | -------------------------------------- | :------: | ------- |
| --help | boolean | Show help | |
| --version | | boolean Show version number | |
| -i, --interactive | boolean | 是否使用 Cathay BDK 互動式問答 | |
| -C, --channel-id | string | 選擇欲同意 Chaincode 在的 Channel 名稱 | |
| -l, --chaincode-label | string | Chaincode package 的標籤名稱 | |
| -I, --init-required | boolean | Chaincode 是否需要初始化 | |
| --orderer | string | 選擇 Orderer 同意 Chaincode | |
| Options | Type | Description | Required | Default |
| --------------------- | :-----: | ----------------------------------------------------- | :------: | ------- |
| --help | boolean | Show help | | |
| --version | | boolean Show version number | | |
| -i, --interactive | boolean | 是否使用 Cathay BDK 互動式問答 | | |
| -C, --channel-id | string | 選擇欲同意 Chaincode 在的 Channel 名稱 | V | |
| -l, --chaincode-label | string | Chaincode package 的標籤名稱 | V | |
| -I, --init-required | boolean | Chaincode 是否需要初始化 | | |
| --orderer | string | 選擇 Orderer 同意 Chaincode (若未輸入則使用discover) | | |

### `bdk chaincode commit`

Description: 代表環境變數中 BDK_ORG_NAME 的 Peer org 發布 Chaincode

| Options | Type | Description | Required | Default |
| --------------------- | :-----: | -------------------------------------- | :------: | ------- |
| --help | boolean | Show help | |
| --version | boolean | Show version number | |
| -i, --interactive | boolean | 是否使用 Cathay BDK 互動式問答 | |
| -C, --channel-id | string | 選擇欲發布 Chaincode 在的 Channel 名稱 | |
| -l, --chaincode-label | string | Chaincode package 的標籤名稱 | |
| -I, --init-required | boolean | Chaincode 是否需要初始化 | |
| --orderer | string | 選擇 Orderer 同意 Chaincode | |
| --peer-addresses | array | 需要簽名的 Peer address | |

### `bdk chaincode deploy`

Description: 部署 / 更新 Chaincode

| Options | Type | Description | Required | Default |
| --------------------- | :-----: | -------------------------------------- | :------: | ------- |
| --help | boolean | Show help | |
| --version | boolean | Show version number | |
| -i, --interactive | boolean | 是否使用 Cathay BDK 互動式問答 | |
| -C, --channel-id | string | 選擇欲部署 Chaincode 在的 Channel 名稱 | |
| -l, --chaincode-label | string | Chaincode package 的標籤名稱 | |
| -a, --approve-only | boolean | 是否只需要做到同意的步驟 | |
| -c, --commit-only | boolean | 是否只需要做到部署的步驟 | |
| -I, --init-required | boolean | Chaincode 是否需要初始化 | |
| --orderer | string | 選擇 Orderer 部署 Chaincode | |
| --peer-addresses | array | 需要簽名的 Peer address | |
| Options | Type | Description | Required | Default |
| --------------------- | :-----: | ---------------------------------------------------- | :------: | ------- |
| --help | boolean | Show help | | |
| --version | boolean | Show version number | | |
| -i, --interactive | boolean | 是否使用 Cathay BDK 互動式問答 | | |
| -C, --channel-id | string | 選擇欲發布 Chaincode 在的 Channel 名稱 | | |
| -l, --chaincode-label | string | Chaincode package 的標籤名稱 | | |
| -I, --init-required | boolean | Chaincode 是否需要初始化 | | |
| --orderer | string | 選擇 Orderer 同意 Chaincode (若未輸入則使用discover) | | |
| --peer-addresses | array | 需要簽名的 Peer address (若未輸入則使用discover) | | |

### `bdk chaincode install`

Expand All @@ -154,18 +137,18 @@ Description: 安裝 Chaincode

Description: 執行 Chaincode function

| Options | Type | Description | Required | Default |
| ------------------------ | :-----: | -------------------------------------- | :------: | ------- |
| --help | boolean | Show help | |
| --version | boolean | Show version number | |
| -i, --interactive | boolean | 是否使用 Cathay BDK 互動式問答 | |
| -C, --channel-id | string | 選擇欲執行 Chaincode 在的 Channel 名稱 | |
| -n, --chaincode-name | string | 欲執行 Chaincode 的名稱 | |
| -I, --is-init | boolean | 是否要初始化 Chaincode | | false |
| -f, --chaincode-function | string | 執行 Chaincode 的 function | |
| -a, --args | array | 執行 Chaincode 需要的參數 | |
| --orderer | string | 選擇 Orderer 執行 Chaincode | |
| --peer-addresses | array | 需要簽名的 Peer address | |
| Options | Type | Description | Required | Default |
| ------------------------ | :-----: | ---------------------------------------------------- | :------: | ------- |
| --help | boolean | Show help | | |
| --version | boolean | Show version number | | |
| -i, --interactive | boolean | 是否使用 Cathay BDK 互動式問答 | | |
| -C, --channel-id | string | 選擇欲執行 Chaincode 在的 Channel 名稱 | | |
| -n, --chaincode-name | string | 欲執行 Chaincode 的名稱 | | |
| -I, --is-init | boolean | 是否要初始化 Chaincode | | false |
| -f, --chaincode-function | string | 執行 Chaincode 的 function | | |
| -a, --args | array | 執行 Chaincode 需要的參數 | | |
| --orderer | string | 選擇 Orderer 執行 Chaincode (若未輸入則使用discover) | | |
| --peer-addresses | array | 需要簽名的 Peer address (若未輸入則使用discover) | | |

### `bdk chaincode package`

Expand Down
11 changes: 7 additions & 4 deletions docs/EXAMPLE-EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,16 @@ bdk chaincode package -n fabcar -v 1 -p ./chaincode/fabcar/go
# export BDK_HOSTNAME='peer0'

# Install and approve chaincode on peer0 in Org1
bdk chaincode deploy -C test -l fabcar_1 -I -a --orderer orderer0.example.com:7050
bdk chaincode install -l fabcar_1
bdk chaincode approve -C test -l fabcar_1 -I --orderer orderer0.example.com:7050

# export BDK_ORG_NAME='Org2'
# export BDK_ORG_DOMAIN='org2.example.com'
# export BDK_HOSTNAME='peer0'

# Install and approve chaincode on peer0 in Org2
bdk chaincode deploy -C test -l fabcar_1 -I -a --orderer orderer0.example.com:7050
bdk chaincode install -l fabcar_1
bdk chaincode approve -C test -l fabcar_1 -I --orderer orderer0.example.com:7050
```

### Step 3: Install chaincode on peer1 in Org1
Expand All @@ -245,7 +247,7 @@ Deploys the chaincode labelled *fabcar_1*. Parameter `-c` is passed to restrict
# export BDK_ORG_DOMAIN='org1.example.com'
# export BDK_HOSTNAME='peer0'

bdk chaincode deploy -C test -l fabcar_1 -I -c --orderer orderer0.example.com:7050 --peer-addresses peer0.org1.example.com:7051 --peer-addresses peer0.org2.example.com:7151
bdk chaincode commit -C test -l fabcar_1 -I --orderer orderer0.example.com:7050 --peer-addresses peer0.org1.example.com:7051 --peer-addresses peer0.org2.example.com:7151
```

### Step 5: Initial chaincode from Org1
Expand Down Expand Up @@ -513,7 +515,8 @@ Install and approve the chaincode named fabcar_1. Since we are using the blockch
# export BDK_HOSTNAME='peer0'

# Install and approve chaincode on peer0 of Org3
bdk chaincode deploy -C test -l fabcar_1 -I -a --orderer orderer0.example.com:7050
bdk chaincode install -l fabcar_1
bdk chaincode approve -C test -l fabcar_1 -I --orderer orderer0.example.com:7050

# export BDK_ORG_NAME='Org3'
# export BDK_ORG_DOMAIN='org3.example.com'
Expand Down
11 changes: 7 additions & 4 deletions docs/EXAMPLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,16 @@ bdk chaincode package -n fabcar -v 1 -p ./chaincode/fabcar/go
# export BDK_HOSTNAME='peer0'

# Org1 的 peer0 安裝、同意 Chaincode
bdk chaincode deploy -C test -l fabcar_1 -I -a --orderer orderer0.example.com:7050
bdk chaincode install -l fabcar_1
bdk chaincode approve -C test -l fabcar_1 -I --orderer orderer0.example.com:7050

# export BDK_ORG_NAME='Org2'
# export BDK_ORG_DOMAIN='org2.example.com'
# export BDK_HOSTNAME='peer0'

# Org2 的 peer0 安裝、同意 Chaincode
bdk chaincode deploy -C test -l fabcar_1 -I -a --orderer orderer0.example.com:7050
bdk chaincode install -l fabcar_1
bdk chaincode approve -C test -l fabcar_1 -I --orderer orderer0.example.com:7050
```

### Step 3:Org1 的 peer1 安裝 Chaincode
Expand All @@ -245,7 +247,7 @@ bdk chaincode install -l fabcar_1
# export BDK_ORG_DOMAIN='org1.example.com'
# export BDK_HOSTNAME='peer0'

bdk chaincode deploy -C test -l fabcar_1 -I -c --orderer orderer0.example.com:7050 --peer-addresses peer0.org1.example.com:7051 --peer-addresses peer0.org2.example.com:7151
bdk chaincode commit -C test -l fabcar_1 -I --orderer orderer0.example.com:7050 --peer-addresses peer0.org1.example.com:7051 --peer-addresses peer0.org2.example.com:7151
```

### Step 5:Org1 初始化 Chaincode
Expand Down Expand Up @@ -513,7 +515,8 @@ bdk channel join -n test --orderer orderer0.example.com:7050
# export BDK_HOSTNAME='peer0'

# Org3 的 peer0 安裝、同意 Chaincode
bdk chaincode deploy -C test -l fabcar_1 -I -a --orderer orderer0.example.com:7050
bdk chaincode install -l fabcar_1
bdk chaincode approve -C test -l fabcar_1 -I --orderer orderer0.example.com:7050

# export BDK_ORG_NAME='Org3'
# export BDK_ORG_DOMAIN='org3.example.com'
Expand Down
57 changes: 4 additions & 53 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
"envfile": "^6.14.0",
"fs-extra": "^9.1.0",
"js-yaml": "^4.1.0",
"memory-streams": "^0.1.3",
"prompts": "^2.4.0",
"string-format": "^2.0.0",
"winston": "^3.3.3",
Expand Down
Loading