Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
SilasZhr committed Jun 30, 2023
0 parents commit 0311092
Show file tree
Hide file tree
Showing 148 changed files with 16,787 additions and 0 deletions.
61 changes: 61 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
*.swp
*.swo

# Logs
logs
*.log

# Runtime data
pids
*.pid
*.seed
allFiredEvents
scTopics

# Coverage directory used by tools like istanbul
coverage
coverage.json
coverageEnv

# node-waf configuration
.lock-wscript

# Dependency directory
node_modules

# Debug log from npm
npm-debug.log

# local env variables
.env

# truffle build directory
build/

# macOS
.DS_Store

# truffle
.node-xmlhttprequest-*

# IntelliJ IDE
.idea

# docs artifacts
docs/modules/api

# only used to package @openzeppelin/contracts
contracts/dist/

# temporary artifact from solidity-coverage
allFiredEvents
.coverage_artifacts
.coverage_cache
.coverage_contracts


# Certora
.certora*
.last_confs
certora_*
.zip-output-url.txt
22 changes: 22 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Contribution Guidelines

## Branch Strategy

We recommend that developers following the rules [here](https://jeffkreeftmeijer.com/git-flow/git-flow.png).

- Branch `main` with stable code and tags on it.
- Branch `develop` for "next release" development.
- Feature branches start with prefix `feat/`
- Release branches start with prefix `release/`
- Hotfix branches start with prefix `hotfix/`

## Contributing

- Fork the repository or create branches.
- Checkout your branch like a feature or bugfix.
- Make a pull request to the `develop` branch of this repository.
- Wait for review and PR merged.

---

**Working on your first Pull Request?** You can learn how from this *free* series [How to Contribute to an Open Source Project on GitHub](https://kcd.im/pull-request)
7 changes: 7 additions & 0 deletions LEGAL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Legal Disclaimer

Within this source code, the comments in Chinese shall be the original, governing version. Any comment in other languages are for reference only. In the event of any conflict between the Chinese language version comments and other language version comments, the Chinese language version shall prevail.

法律免责声明

关于代码注释部分,中文注释为官方版本,其它语言注释仅做参考。中文注释可能与其它语言注释存在不一致,当中文注释与其它语言注释存在不一致时,请以中文注释为准。
201 changes: 201 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/

TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

1. Definitions.

"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.

"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.

"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.

"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.

"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.

"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.

"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).

"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.

"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."

"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.

2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.

3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.

4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:

(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and

(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and

(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and

(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.

You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.

5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.

6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.

7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.

8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.

9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.

END OF TERMS AND CONDITIONS

APPENDIX: How to apply the Apache License to your work.

To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright {yyyy} {name of copyright owner}

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
100 changes: 100 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<div align="center">
<img alt="am logo" src="https://antchainbridge.oss-cn-shanghai.aliyuncs.com/antchainbridge/document/picture/antchain.png" width="250" >
<h1 align="center">AntChain Developer Digital Badges</h1>
<p align="center">
<a href="http://makeapullrequest.com">
<img alt="pull requests welcome badge" src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat">
</a>
<a href="https://www.java.com">
<img alt="Language" src="https://img.shields.io/badge/Language-Java-blue.svg?style=flat">
</a>
<a href="https://github.com/AntChainOpenLab/AntChainDeveloper DigitalBadges/graphs/contributors">
<img alt="GitHub contributors" src="https://img.shields.io/github/contributors/AntChainOpenLab/AntChainDeveloperDigitalBadges">
</a>
<a href="https://www.apache.org/licenses/LICENSE-2.0">
<img alt="License" src="https://img.shields.io/github/license/AntChainOpenLab/AntChainDeveloperDigitalBadges?style=flat">
</a>
</p>
</div>


# 介绍

AntChain Developer Digital Badges是蚂蚁链(开放联盟链)的Web3示范应用, 可以与 Web3 开发者共同探索、构建数字世界。通过为熟悉传统应用开发却不熟悉Web3应用架构广大的开发者提供Web3示范应用,帮助广大开发者根据自己的业务场景去定制开发,同时将开发者引入到Web3世界中。
通过个性化定制开发,可以实现例如数字头像、数字门票、数字徽章(POAP)、权益(优惠券)发放和核销等功能,满足各类数字化场景的基本需求,也可支持会场交互需求。


在AntChain Developer Digital Badges的架构中,需要与区块链进行交互,而链的版本、连接方式类型繁多,无法统一适配,因此AntChain Developer Digital Badges示例中使用蚂蚁链BaaS平台官方提供的[REST接入服务](https://antchain.antgroup.com/docs/11/204700),从而实现易用、高效、可靠的统一区块链接入服务。


AntChain Developer Digital Badges为开发者提供了数字头像合约模板,来帮助开发者完成插件和合约的开发,需要使用蚂蚁链合约工具[myfish](contracts/README.md)进行编译部署。


以下介绍了AntChain Developer Digital Badges的整体架构:

![](https://mdn.alipayobjects.com/huamei_3x8d2m/afts/img/A*3tOZSIhIG4wAAAAAAAAAAAAADjmWAQ/original)

插件SDK共有四个部分,包括:

在当前的工程实现中,AntChain Developer Digital Badges核心部分是以传统的 MVC 三层架构思想的分层模型实现的。
- **bootstrap 层(启动层**
该层是 SOFABoot 项目中的启动模块,其中包含 SOFABoot 应用的启动类、配置文件、打包插件等,其测试目录中还提供了集成测试的基类,可支持继承和扩展。
该模块可通过直接或间接依赖引用其他各模块的代码。

- **ervice 层(服务层)**
service 层作为 web 层或 facade 层与 model 层之间的桥梁,是实现主要业务逻辑的模块(如提供访问数据库之前的数据校验,处理数据库返回的值,发布 RPC 服务等)。
- **model 层(模型层)**
model 层用于存放实体类,即定义业务逻辑的领域对象。
- **dal 层(数据库层)**
dal 层主要是用于访问数据库,即编写对数据库的增删改查的 sql 语句实现。
- **utils 层 (工具层)**
utils 层提供了一些公共的工具库类,这些类可以被应用中的所有类使用。



# 构建

**在开始之前,请您确保安装了maven和JDK,这里推荐使用openjdk-1.8版本*
- **下载并安装REST SDK**

自带依赖的下载链接:[rest-client-2.16.5-with-dependencies.jar](https://static-aliyun-doc.oss-cn-hangzhou.aliyuncs.com/file-manage-files/zh-CN/20230512/sghb/rest-client-2.16.5-with-dependencies.jar)

下载成功后在server目录中运行
mvn install:install-file -Dfile=jar包的位置 -DgroupId=com.antfinancial.antchain.baas.tool -DartifactId=rest-client -Dversion=2.16.5 -Dpackaging=jar

# 快速开始

- **申请区块链账号**
1. 在开放联盟链官网进行账号、AK等申请,具体步骤请参考[蚂蚁链服务获取](https://opendocs.antchain.antgroup.com/docs/intro#-%E8%8E%B7%E5%8F%96%E6%9C%8D%E5%8A%A1)
2. 数字藏品需要存储图像以及MetaData数据, 用户可以自由选择数据服务平台。 本应用中使用[阿里云oss服务](https://www.aliyun.com/product/oss)作为示例, 使用其他数据存储服务需要进行个性化定制开发。

- **部署合约**
本应用中提供两个不同的数字头像合约实现, 所使用的合约语言均为Soldity语言,[蚂蚁链合约平台与原生 Solidity 具有不一样的特性](https://antchain.antgroup.com/docs/11/101909)。部署合约需要使用蚂蚁链合约工具[myfish](contracts/README.md)进行编译部署。两个合约不同之处在于, [index.sol](contracts/solidity/index.sol) 中设置了baseURI, 即所有数字藏品metadata URI均在此基础上进行递增。 而[indexCustomizedURI.sol](contracts/solidity/indexCustomizedURI.sol)合约可以为每一个数字藏品设置完全不同的URI,可定制程度更高。


- **启动应用**
启动方式与传统spring-boot应用完全相同,在完成配置文件以及依赖安装后,运行如下命令
```bash
mvn spring-boot:run
```

- **A-Pocket服务使用**
A-Pocket是蚂蚁链数字钱包,支持密钥托管,链上NFT资产展示,并开放提供对外部DApp的调用。在支付宝小程序搜索A-Pocket即可使用,在开放联盟链中铸造的数字藏品, 可以接入A-Pocket进行展示, 目前A-Pocket数字藏品接入还处于白名单阶段,用户可以在issue以"A-Pocket白名单申请作为标题", 附带上合约地址等相关信息,我们会尽快审核。有相关疑问可以加入下方社区治理钉群中进行提问&讨论。

# 社区治理

AntChain Bridge 欢迎您以任何形式参与社区建设。

您可以通过以下方式参与社区讨论

- 钉钉

![scan dingding](https://mdn.alipayobjects.com/huamei_7pldhj/afts/img/A*sjpaS6gIPFgAAAAAAAAAAAAADoaYAQ/original)

- 邮件

发送邮件到`antchainbridge@service.alipay.com`

# License

详情参考[LICENSE](./LICENSE)
Loading

0 comments on commit 0311092

Please sign in to comment.