├── .github └── ISSUE_TEMPLATE │ └── discussion-topic.md ├── .gitignore ├── .vscode └── settings.json ├── Cargo.toml ├── LICENSE ├── README.md ├── asset_transfer_rs ├── Cargo.toml ├── README.md └── src │ ├── contracts.rs │ ├── contracts │ ├── assettransfer.rs │ ├── assettransferquery.rs │ └── transfercontract.rs.notinuse │ ├── lib.rs │ ├── routing.md │ ├── types.rs │ └── types │ └── asset.rs ├── asset_transfer_secure_private_rs ├── Cargo.toml ├── README.md └── src │ ├── contracts.rs │ ├── contracts │ └── assettransferprivate.rs │ ├── lib.rs │ ├── routing.md │ ├── types.rs │ └── types │ ├── asset.rs │ ├── asset_private.rs │ ├── price_agreement.rs │ ├── trade_agreement.rs │ └── transfer_receipt.rs ├── azure-pipelines.yml ├── basic_contract_rs ├── Cargo.toml ├── README.md └── src │ ├── contracts.rs │ ├── contracts │ └── assetcontract.rs │ ├── lib.rs │ ├── routing.md │ ├── types.rs │ └── types │ └── myasset.rs ├── docs ├── .gitignore ├── 404.md ├── Gemfile ├── Gemfile.lock ├── _config.yml ├── _includes │ ├── footer.html │ └── header.html ├── apidoc │ ├── COPYRIGHT.txt │ ├── FiraSans-LICENSE.txt │ ├── FiraSans-Medium.woff │ ├── FiraSans-Regular.woff │ ├── LICENSE-APACHE.txt │ ├── LICENSE-MIT.txt │ ├── SourceCodePro-LICENSE.txt │ ├── SourceCodePro-Regular.woff │ ├── SourceCodePro-Semibold.woff │ ├── SourceSerifPro-Bold.ttf.woff │ ├── SourceSerifPro-It.ttf.woff │ ├── SourceSerifPro-LICENSE.md │ ├── SourceSerifPro-Regular.ttf.woff │ ├── aliases.js │ ├── asset_transfer_private_rs │ │ ├── all.html │ │ ├── contracts │ │ │ └── assettransferprivate │ │ │ │ └── struct.AssetTransfer.html │ │ ├── fn.__guest_call.html │ │ ├── fn.__launch.html │ │ ├── fn.once_wapc.html │ │ ├── index.html │ │ ├── sidebar-items.js │ │ ├── struct.Asset.html │ │ ├── struct.AssetPrivate.html │ │ ├── struct.AssetTransfer.html │ │ ├── struct.PriceAgreement.html │ │ └── types │ │ │ ├── asset │ │ │ └── struct.Asset.html │ │ │ ├── asset_private │ │ │ └── struct.AssetPrivate.html │ │ │ └── price_agreement │ │ │ └── struct.PriceAgreement.html │ ├── asset_transfer_rs │ │ ├── all.html │ │ ├── contracts │ │ │ ├── assettransfer │ │ │ │ └── struct.AssetTransfer.html │ │ │ ├── assettransferquery │ │ │ │ └── struct.AssetTransferQuery.html │ │ │ └── transfercontract │ │ │ │ └── struct.TransferContract.html │ │ ├── fn.__guest_call.html │ │ ├── fn.__launch.html │ │ ├── fn.once_wapc.html │ │ ├── index.html │ │ ├── sidebar-items.js │ │ ├── struct.Asset.html │ │ ├── struct.AssetTransfer.html │ │ ├── struct.AssetTransferQuery.html │ │ ├── struct.MyAsset.html │ │ ├── struct.TransferContract.html │ │ └── types │ │ │ ├── asset │ │ │ └── struct.Asset.html │ │ │ └── myasset │ │ │ └── struct.MyAsset.html │ ├── basic_contract_rs │ │ ├── all.html │ │ ├── contracts │ │ │ └── assetcontract │ │ │ │ └── struct.AssetContract.html │ │ ├── fn.__guest_call.html │ │ ├── fn.__launch.html │ │ ├── fn.once_wapc.html │ │ ├── fn.register.html │ │ ├── index.html │ │ ├── sidebar-items.js │ │ ├── struct.AssetContract.html │ │ ├── struct.MyAsset.html │ │ └── types │ │ │ └── myasset │ │ │ └── struct.MyAsset.html │ ├── brush.svg │ ├── contract_macros │ │ ├── all.html │ │ ├── attr.contract_impl.html │ │ ├── attr.property.html │ │ ├── attr.transaction.html │ │ ├── derive.DataType.html │ │ ├── derive.DataTypeMacro.html │ │ ├── index.html │ │ └── sidebar-items.js │ ├── dark.css │ ├── demo │ │ ├── all.html │ │ ├── fn.main.html │ │ ├── index.html │ │ └── sidebar-items.js │ ├── down-arrow.svg │ ├── fabric_contract │ │ ├── all.html │ │ ├── attr.contract_impl.html │ │ ├── attr.property.html │ │ ├── attr.transaction.html │ │ ├── blockchain │ │ │ ├── index.html │ │ │ ├── sidebar-items.js │ │ │ ├── struct.ClientIdentity.html │ │ │ ├── struct.Transaction.html │ │ │ └── struct.TransactionContext.html │ │ ├── blockchainapi │ │ │ ├── clientidentity │ │ │ │ └── struct.ClientIdentity.html │ │ │ ├── transaction │ │ │ │ ├── index.html │ │ │ │ └── struct.Transaction.html │ │ │ └── transactioncontext │ │ │ │ └── struct.TransactionContext.html │ │ ├── contract │ │ │ ├── attr.Contract_Impl.html │ │ │ ├── attr.Transaction.html │ │ │ ├── enum.CollectionName.html │ │ │ ├── enum.Expression.html │ │ │ ├── enum.KeyQueryHandler.html │ │ │ ├── enum.ROLE.html │ │ │ ├── index.html │ │ │ ├── sidebar-items.js │ │ │ ├── struct.Collection.html │ │ │ ├── struct.Context.html │ │ │ ├── struct.ContractError.html │ │ │ ├── struct.ContractManager.html │ │ │ ├── struct.Ledger.html │ │ │ ├── struct.LedgerError.html │ │ │ ├── struct.State.html │ │ │ ├── struct.StateBasedEndorsement.html │ │ │ ├── struct.StateHash.html │ │ │ ├── struct.StateQueryList.html │ │ │ ├── trait.Contract.html │ │ │ ├── trait.Metadata.html │ │ │ ├── trait.Routing.html │ │ │ └── trait.VerifyHashConsistency.html │ │ ├── contractapi │ │ │ ├── context │ │ │ │ ├── index.html │ │ │ │ ├── sidebar-items.js │ │ │ │ └── struct.Context.html │ │ │ ├── contract │ │ │ │ ├── index.html │ │ │ │ ├── sidebar-items.js │ │ │ │ ├── trait.Contract.html │ │ │ │ ├── trait.Metadata.html │ │ │ │ └── trait.Routing.html │ │ │ ├── contractdefn │ │ │ │ ├── index.html │ │ │ │ ├── sidebar-items.js │ │ │ │ └── struct.ContractDefn.html │ │ │ ├── contractmanager │ │ │ │ ├── index.html │ │ │ │ ├── sidebar-items.js │ │ │ │ └── struct.ContractManager.html │ │ │ ├── index.html │ │ │ ├── sidebar-items.js │ │ │ └── transaction │ │ │ │ ├── index.html │ │ │ │ ├── sidebar-items.js │ │ │ │ ├── struct.TransactionFn.html │ │ │ │ └── struct.TransactionFnBuilder.html │ │ ├── data │ │ │ ├── attr.Property.html │ │ │ ├── index.html │ │ │ ├── sidebar-items.js │ │ │ ├── struct.TypeSchema.html │ │ │ ├── struct.WireBuffer.html │ │ │ ├── trait.DataType.html │ │ │ └── trait.WireBufferFromReturnType.html │ │ ├── dataapi │ │ │ ├── typeschema │ │ │ │ └── struct.TypeSchema.html │ │ │ └── wirebuffer │ │ │ │ ├── struct.WireBuffer.html │ │ │ │ └── trait.WireBufferFromReturnType.html │ │ ├── derive.DataTypeMacro.html │ │ ├── error │ │ │ ├── index.html │ │ │ ├── sidebar-items.js │ │ │ ├── struct.ContractError.html │ │ │ └── struct.LedgerError.html │ │ ├── fabric_blockchain │ │ │ ├── index.html │ │ │ ├── sidebar-items.js │ │ │ ├── struct.Transaction.html │ │ │ └── transaction │ │ │ │ ├── index.html │ │ │ │ ├── sidebar-items.js │ │ │ │ └── struct.Transaction.html │ │ ├── index.html │ │ ├── ledgerapi │ │ │ ├── collection │ │ │ │ ├── enum.CollectionName.html │ │ │ │ ├── enum.KeyQueryHandler.html │ │ │ │ ├── index.html │ │ │ │ ├── sidebar-items.js │ │ │ │ ├── struct.Collection.html │ │ │ │ └── trait.CollectionIterator.html │ │ │ ├── datatype │ │ │ │ └── trait.DataType.html │ │ │ ├── endorsement │ │ │ │ ├── enum.Expression.html │ │ │ │ ├── enum.ROLE.html │ │ │ │ └── struct.StateBasedEndorsement.html │ │ │ ├── index.html │ │ │ ├── ledger │ │ │ │ ├── index.html │ │ │ │ ├── sidebar-items.js │ │ │ │ └── struct.Ledger.html │ │ │ ├── sidebar-items.js │ │ │ ├── state │ │ │ │ ├── index.html │ │ │ │ ├── sidebar-items.js │ │ │ │ ├── struct.State.html │ │ │ │ ├── struct.StateHash.html │ │ │ │ ├── trait.DataType.html │ │ │ │ └── trait.VerifyHashConsistency.html │ │ │ └── statequerylist │ │ │ │ └── struct.StateQueryList.html │ │ ├── macro.launch_handler!.html │ │ ├── macro.launch_handler.html │ │ ├── macro.register!.html │ │ ├── macro.register.html │ │ ├── prelude │ │ │ ├── fn.handle_wapc.html │ │ │ ├── fn.host_call.html │ │ │ ├── fn.host_log.html │ │ │ ├── index.html │ │ │ ├── macro.wapc_handler!.html │ │ │ ├── macro.wapc_handler.html │ │ │ ├── sidebar-items.js │ │ │ ├── struct.ContractDefn.html │ │ │ ├── struct.TransactionFn.html │ │ │ ├── struct.TransactionFnBuilder.html │ │ │ ├── type.CallResult.html │ │ │ └── type.Result.html │ │ ├── runtime │ │ │ ├── fn.hook.html │ │ │ ├── fn.init_logger.html │ │ │ ├── index.html │ │ │ ├── register │ │ │ │ ├── index.html │ │ │ │ ├── sidebar-items.js │ │ │ │ └── struct.ContractRuntime.html │ │ │ ├── runtime │ │ │ │ ├── fn.__guest_call.html │ │ │ │ ├── fn.__log.html │ │ │ │ ├── fn.handle_wapc.html │ │ │ │ ├── fn.log.html │ │ │ │ ├── index.html │ │ │ │ ├── items │ │ │ │ │ ├── index.html │ │ │ │ │ ├── sidebar-items.js │ │ │ │ │ ├── struct.Arguments.html │ │ │ │ │ └── struct.Return.html │ │ │ │ └── sidebar-items.js │ │ │ ├── sidebar-items.js │ │ │ ├── struct.ContracRuntime.html │ │ │ └── struct.ContractRuntime.html │ │ ├── runtimeapi │ │ │ ├── logger │ │ │ │ ├── fn.hook.html │ │ │ │ └── fn.init_logger.html │ │ │ ├── register │ │ │ │ └── struct.ContractRuntime.html │ │ │ └── wapc │ │ │ │ ├── fn.handle_wapc.html │ │ │ │ └── fn.log.html │ │ ├── sidebar-items.js │ │ └── transaction │ │ │ ├── index.html │ │ │ ├── sidebar-items.js │ │ │ └── struct.Transaction.html │ ├── fabric_contract_macros │ │ ├── all.html │ │ ├── attr.contract_impl.html │ │ ├── attr.property.html │ │ ├── attr.transaction.html │ │ ├── derive.DataTypeMacro.html │ │ ├── index.html │ │ └── sidebar-items.js │ ├── favicon.ico │ ├── implementors │ │ ├── core │ │ │ ├── clone │ │ │ │ └── trait.Clone.js │ │ │ ├── cmp │ │ │ │ └── trait.PartialEq.js │ │ │ ├── convert │ │ │ │ └── trait.From.js │ │ │ ├── default │ │ │ │ └── trait.Default.js │ │ │ ├── fmt │ │ │ │ ├── trait.Debug.js │ │ │ │ └── trait.Display.js │ │ │ ├── iter │ │ │ │ └── traits │ │ │ │ │ └── collect │ │ │ │ │ ├── trait.FromIterator.js │ │ │ │ │ └── trait.IntoIterator.js │ │ │ └── marker │ │ │ │ ├── trait.Copy.js │ │ │ │ ├── trait.Freeze.js │ │ │ │ ├── trait.Send.js │ │ │ │ ├── trait.StructuralPartialEq.js │ │ │ │ ├── trait.Sync.js │ │ │ │ └── trait.Unpin.js │ │ ├── fabric_contract │ │ │ ├── contract │ │ │ │ └── trait.VerifyHashConsistency.js │ │ │ ├── contractapi │ │ │ │ └── contract │ │ │ │ │ ├── trait.Contract.js │ │ │ │ │ ├── trait.Metadata.js │ │ │ │ │ └── trait.Routing.js │ │ │ ├── data │ │ │ │ └── trait.WireBufferFromReturnType.js │ │ │ ├── dataapi │ │ │ │ └── wirebuffer │ │ │ │ │ └── trait.WireBufferFromReturnType.js │ │ │ └── ledgerapi │ │ │ │ └── datatype │ │ │ │ └── trait.DataType.js │ │ ├── prost │ │ │ └── message │ │ │ │ └── trait.Message.js │ │ ├── serde │ │ │ ├── de │ │ │ │ └── trait.Deserialize.js │ │ │ └── ser │ │ │ │ └── trait.Serialize.js │ │ └── std │ │ │ ├── error │ │ │ └── trait.Error.js │ │ │ └── panic │ │ │ ├── trait.RefUnwindSafe.js │ │ │ └── trait.UnwindSafe.js │ ├── light.css │ ├── main.js │ ├── normalize.css │ ├── noscript.css │ ├── rust-logo.png │ ├── rustdoc.css │ ├── search-index.js │ ├── settings.css │ ├── settings.html │ ├── settings.js │ ├── source-files.js │ ├── source-script.js │ ├── src │ │ ├── asset_transfer_private_rs │ │ │ ├── contracts.rs.html │ │ │ ├── contracts │ │ │ │ └── assettransferprivate.rs.html │ │ │ ├── lib.rs.html │ │ │ ├── types.rs.html │ │ │ └── types │ │ │ │ ├── asset.rs.html │ │ │ │ ├── asset_private.rs.html │ │ │ │ ├── price_agreement.rs.html │ │ │ │ └── transfer_receipt.rs.html │ │ ├── asset_transfer_rs │ │ │ ├── contracts.rs.html │ │ │ ├── contracts │ │ │ │ ├── assettransfer.rs.html │ │ │ │ ├── assettransferquery.rs.html │ │ │ │ └── transfercontract.rs.html │ │ │ ├── lib.rs.html │ │ │ ├── types.rs.html │ │ │ └── types │ │ │ │ ├── asset.rs.html │ │ │ │ └── myasset.rs.html │ │ ├── basic_contract_rs │ │ │ ├── assetcontract.rs.html │ │ │ ├── contracts.rs.html │ │ │ ├── contracts │ │ │ │ └── assetcontract.rs.html │ │ │ ├── lib.rs.html │ │ │ ├── myasset.rs.html │ │ │ ├── types.rs.html │ │ │ └── types │ │ │ │ └── myasset.rs.html │ │ ├── contract_macros │ │ │ └── lib.rs.html │ │ ├── demo │ │ │ └── main.rs.html │ │ ├── fabric_contract │ │ │ ├── blockchainapi.rs.html │ │ │ ├── blockchainapi │ │ │ │ ├── clientidentity.rs.html │ │ │ │ ├── transaction.rs.html │ │ │ │ └── transactioncontext.rs.html │ │ │ ├── contractapi.rs.html │ │ │ ├── contractapi │ │ │ │ ├── context.rs.html │ │ │ │ ├── contract.rs.html │ │ │ │ ├── contractdefn.rs.html │ │ │ │ ├── contractmanager.rs.html │ │ │ │ └── transaction.rs.html │ │ │ ├── dataapi.rs.html │ │ │ ├── dataapi │ │ │ │ ├── serializer.rs.html │ │ │ │ ├── typeschema.rs.html │ │ │ │ └── wirebuffer.rs.html │ │ │ ├── error.rs.html │ │ │ ├── home │ │ │ │ └── matthew │ │ │ │ │ └── github.com │ │ │ │ │ ├── hyperledgendary │ │ │ │ │ └── fabric-contract-api-rust │ │ │ │ │ │ └── target │ │ │ │ │ │ └── debug │ │ │ │ │ │ └── build │ │ │ │ │ │ └── fabric_contract-f044e8dc8a4e4765 │ │ │ │ │ │ └── out │ │ │ │ │ │ └── datatypes.rs.html │ │ │ │ │ └── hyperlegdendary │ │ │ │ │ └── fabric-contract-api-rust │ │ │ │ │ └── target │ │ │ │ │ └── debug │ │ │ │ │ └── build │ │ │ │ │ └── fabric_contract-f044e8dc8a4e4765 │ │ │ │ │ └── out │ │ │ │ │ └── datatypes.rs.html │ │ │ ├── ledgerapi.rs.html │ │ │ ├── ledgerapi │ │ │ │ ├── collection.rs.html │ │ │ │ ├── datatype.rs.html │ │ │ │ ├── endorsement.rs.html │ │ │ │ ├── ledger.rs.html │ │ │ │ ├── state.rs.html │ │ │ │ └── statequerylist.rs.html │ │ │ ├── lib.rs.html │ │ │ ├── runtime.rs.html │ │ │ ├── runtime │ │ │ │ ├── register.rs.html │ │ │ │ └── runtime.rs.html │ │ │ ├── runtimeapi.rs.html │ │ │ └── runtimeapi │ │ │ │ ├── ledgerservice.rs.html │ │ │ │ ├── logger.rs.html │ │ │ │ ├── register.rs.html │ │ │ │ └── wapc.rs.html │ │ └── fabric_contract_macros │ │ │ └── lib.rs.html │ ├── storage.js │ ├── theme.js │ └── wheel.svg ├── assets │ └── main.css ├── guides │ ├── MicrofabBuilder.png │ ├── fabric-wasm-rust-1.png │ ├── getting-started-microfab-builder.md │ ├── getting-started-microfab.md │ ├── getting-started-test-network.md │ ├── getting-started.md │ ├── ledger-access.md │ ├── rust-and-wasm.md │ ├── transaction-functions.md │ └── writing-a-rust-contract.md └── index.md ├── fabric_contract ├── Cargo.toml ├── README.md └── src │ ├── blockchainapi.rs │ ├── blockchainapi │ ├── clientidentity.rs │ └── transactioncontext.rs │ ├── contractapi.rs │ ├── contractapi │ ├── contract.rs │ ├── contractdefn.rs │ ├── contractmanager.rs │ └── transaction.rs │ ├── dataapi.rs │ ├── dataapi │ ├── JSONConverter.rs │ ├── serializer.rs │ ├── typeschema.rs │ └── wirebuffer.rs │ ├── error.rs │ ├── ledgerapi.rs │ ├── ledgerapi │ ├── collection.rs │ ├── datatype.rs │ ├── endorsement.rs │ ├── ledger.rs │ ├── state.rs │ └── statequerylist.rs │ ├── lib.rs │ ├── runtimeapi.rs │ ├── runtimeapi │ ├── ledgerservice.rs │ ├── logger.rs │ └── wapc.rs │ └── transaction.rs ├── fabric_contract_macros ├── Cargo.toml ├── README.md └── src │ └── lib.rs ├── justfile └── tests ├── assets ├── chaincode.env └── wasmftw.tgz └── setup.sh /.github/ISSUE_TEMPLATE/discussion-topic.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Discussion Topic 3 | about: Topic 4 | title: How do I....? 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | Please use the issues for feedback and discussion. 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | 5 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 6 | # More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html 7 | Cargo.lock 8 | 9 | # These are backup files generated by rustfmt 10 | **/*.rs.bk 11 | 12 | _bldtmp 13 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | } -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | # ,'asset_transfer_private_rs' 3 | members = [ 4 | "fabric_contract","fabric_contract_macros","basic_contract_rs",'asset_transfer_rs','asset_transfer_secure_private_rs' 5 | ] 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Fabric Rust Contract-API 2 | 3 | "The Fabric Contract API in rust, with Wasm as the compilation target." 4 | 5 | A SmartContract is single crate, containing one or more contract sructs, compiled to a Wasm library. In this repo the `basic_contract_rs` is an example. This is a simple asset based contract based on the standard vs code extension examples. 6 | 7 | [End-to-End Getting Started Guide](https://hyperledgendary.github.io/fabric-contract-api-rust/guides/getting-started.html) 8 | 9 | [Check the API Documentation for fabric_contract](https://hyperledgendary.github.io/fabric-contract-api-rust/apidoc/fabric_contract/index.html) 10 | 11 | [Full Documentation](https://hyperledgendary.github.io/fabric-contract-api-rust/) 12 | 13 | ## Technology Preview 14 | 15 | NOTE this is a technology preview, rather than production ready. Released for feedback and community experimentation. 16 | 17 | ## Tl;Dr; docs 18 | 19 | ### To write and deploy a Smart Contract 20 | 21 | At a very highlevel the steps are 22 | 23 | 0. As the crates are not published yet, clone this entire cargo workspace to build both the fabric_contract and your own crates 24 | 1. Write the Smart Contract in rust, see `basic_contract_rs` for an example 25 | 2. Compile this targetting wasm. `cargo build --target wasm32-unknown-unknown` 26 | 3. Take the resulting Wasm binary and use the `https://github.com/hyperledgendary/fabric-chaincode-wasm` project to encapsualte this Wasm file in the 'Wasm Chaincode Runtime' 27 | 4. Once deployed this you interact with this like another contract 28 | 29 | 30 | For all the steps please follow the [Getting Started Guide](https://hyperledgendary.github.io/fabric-contract-api-rust/guides/getting-started.html) 31 | 32 | ### Summary of how to build for Wasm 33 | 34 | To build a Wasm binary you will need to have rust installed (stable branch is good, nightly is not required). You will need to add the wasm target. 35 | (`rustup target add wasm32-unknown-unknown` if you don't have the Wasm toolchain. Note that wasm-pack is not required here as there is no JavaScript host) 36 | 37 | ``` 38 | cargo build --target wasm32-unknown-unknown 39 | ``` 40 | 41 | File will be in `target/wasm32-unknown-unknown/debug/basic_contract_rs.wasm` 42 | 43 | 44 | To build documentation 45 | 46 | ``` 47 | just docs 48 | ``` 49 | 50 | There is also a `justfile` for quick command running. 51 | 52 | -------------------------------------------------------------------------------- /asset_transfer_rs/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "asset_transfer_rs" 3 | version = "0.1.0" 4 | authors = ["Matthew B White "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [lib] 10 | crate-type = ["cdylib"] 11 | 12 | [dependencies] 13 | fabric_contract = { path = "../fabric_contract" } 14 | sha2 = "0.9.0" 15 | log = "0.4.8" 16 | wapc-guest = "0.3.1" 17 | serde = { version = "1.0", features = ["derive"] } 18 | serde_json = "1.0" -------------------------------------------------------------------------------- /asset_transfer_rs/README.md: -------------------------------------------------------------------------------- 1 | # Asset Transfer 2 | 3 | This is the same model as the Asset Transfer in the hyperledger/fabric-samples -------------------------------------------------------------------------------- /asset_transfer_rs/src/contracts.rs: -------------------------------------------------------------------------------- 1 | 2 | mod assettransfer; 3 | mod assettransferquery; 4 | pub use crate::contracts::assettransfer::AssetTransfer as AssetTransfer; 5 | pub use crate::contracts::assettransferquery::AssetTransferQuery as AssetTransferQuery; 6 | -------------------------------------------------------------------------------- /asset_transfer_rs/src/lib.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | //! Main library module 6 | //! 7 | //! The purpose of this is to do register the contracts. 8 | //! 9 | //! Other setup can take place here but do so with 10 | //! caution. Any failure will terminate the container 11 | //! and there is limited scope for logging at stage in 12 | //! the lifecyle 13 | mod contracts; 14 | pub use crate::contracts::AssetTransfer; 15 | pub use crate::contracts::AssetTransferQuery; 16 | 17 | mod types; 18 | pub use crate::types::Asset; 19 | 20 | // The macro to indicate the function that will be used to register the contracts. 21 | // if there is more than one, use a comma separated list 22 | //, AssetTransferQuery::new 23 | // Provide the function that will create a new instance of the contract strcut 24 | // More than one contract struct can be provided. 25 | fabric_contract::register!( AssetTransfer::new ); -------------------------------------------------------------------------------- /asset_transfer_rs/src/routing.md: -------------------------------------------------------------------------------- 1 | // the following (left for reference) is what the [contract_impl] macro would logically add 2 | // to this code 3 | 4 | // impl Routing for AssetContract { 5 | 6 | // fn route2(&self, ctx: Context, tx_fn: String, args: Vec) -> Result{ 7 | // ctx.log(format!("Inside the contract {} {:?}",tx_fn,args)); 8 | // let _r = match &tx_fn[..] { 9 | // "create_asset" => { 10 | 11 | // let a0 = match args.get(0) { 12 | // Some(a) => Ok(a), 13 | // None => Err(String::from("Missing argument 0")), 14 | // }; 15 | 16 | // let a1 = match args.get(1) { 17 | // Some(a) => Ok(a), 18 | // None => Err(String::from("Missing argument 1")), 19 | // }; 20 | 21 | // let _r=self.create_asset(ctx, a0.unwrap().to_string(), a1.unwrap().to_string()); 22 | // Ok(String::from("")) 23 | // }, 24 | // "read_asset" => { 25 | 26 | // let a0 = match args.get(0) { 27 | // Some(a) => Ok(a), 28 | // None => Err(String::from("Missing argument 0")), 29 | // }; 30 | 31 | // let _r=self.read_asset(ctx, a0.unwrap().to_string()); 32 | // Ok(String::from("")) 33 | // }, 34 | // _ => Err(String::from("Unknown transaction fn ")) 35 | // }; 36 | 37 | // Ok(String::from("200")) 38 | // } 39 | // } -------------------------------------------------------------------------------- /asset_transfer_rs/src/types.rs: -------------------------------------------------------------------------------- 1 | mod asset; 2 | pub use asset::Asset as Asset; -------------------------------------------------------------------------------- /asset_transfer_rs/src/types/asset.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | use fabric_contract::contract::*; 5 | use fabric_contract::data::*; 6 | use serde::{Deserialize, Serialize}; 7 | use std::str::from_utf8; 8 | 9 | // Use the log crate to support logging 10 | use log::{debug}; 11 | 12 | /// 13 | 14 | #[derive(Serialize, Deserialize, Debug, Default)] 15 | pub struct Asset { 16 | id: String, 17 | color: String, 18 | size: i32, 19 | owner: String, 20 | appraised_value: i32, 21 | } 22 | 23 | impl Asset { 24 | pub fn new(id: String, color: String, size: i32, owner: String, appraised_value: i32) -> Asset { 25 | Asset { 26 | id, 27 | color, 28 | size, 29 | owner, 30 | appraised_value, 31 | } 32 | } 33 | 34 | pub fn get_owner(&self) -> String { 35 | self.owner.clone() 36 | } 37 | 38 | pub fn update_owner(&mut self, owner: String) -> () { 39 | self.owner = owner; 40 | } 41 | 42 | pub fn get_color(&self) -> String { 43 | return self.color.clone(); 44 | } 45 | 46 | pub fn get_id(&self) -> String { 47 | return self.id.clone(); 48 | } 49 | } 50 | 51 | /// Very important to implement the DataType Trait for the Asset 52 | /// 53 | /// This provides the ability to store the data in the ledger 54 | impl DataType for Asset { 55 | fn to_state(&self) -> State { 56 | let json = serde_json::to_string(self).unwrap(); 57 | debug!("ToState::{}",&json.as_str()); 58 | let buffer = json.into_bytes(); 59 | State::from((self.id.clone(), buffer)) 60 | } 61 | 62 | fn get_key(&self) -> String { 63 | Asset::form_key(&self.id.clone()) 64 | } 65 | 66 | fn build_from_state(state: State) -> Self { 67 | let b = state.value(); 68 | 69 | let str = match from_utf8(&b) { 70 | Ok(a) => a, 71 | Err(_) => panic!("Err"), 72 | }; 73 | debug!("build_from_state:: {}",&str); 74 | serde_json::from_str(str).unwrap() 75 | } 76 | 77 | 78 | fn form_key(k: &String) -> String { 79 | format!("Asset::{}",k) 80 | } 81 | } 82 | 83 | impl WireBufferFromReturnType for WireBuffer { 84 | fn from_rt(self: &mut Self, s: Asset) { 85 | // we've got a wire buffer object and we need to set the bytes here from the string 86 | let json = serde_json::to_string(&s).unwrap(); 87 | debug!("wire buffer returning the value {}",json.as_str()); 88 | let buffer = json.into_bytes(); 89 | self.buffer = Some(buffer); 90 | } 91 | } 92 | 93 | impl From<&WireBuffer> for Asset { 94 | fn from(wb: &WireBuffer) -> Self { 95 | match &wb.buffer { 96 | Some(buffer) => { 97 | match std::str::from_utf8(&buffer) { 98 | Ok(a) => serde_json::from_str(a).unwrap(), 99 | _ => unreachable!(), 100 | } 101 | } 102 | None => panic!(), 103 | } 104 | } 105 | } -------------------------------------------------------------------------------- /asset_transfer_secure_private_rs/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "asset_transfer_private_rs" 3 | version = "0.1.0" 4 | authors = ["Matthew B White "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [lib] 10 | crate-type = ["cdylib"] 11 | 12 | [dependencies] 13 | fabric_contract = { path = "../fabric_contract" } 14 | sha2 = "0.9.0" 15 | log = "0.4.8" 16 | wapc-guest = "0.3.1" 17 | serde = { version = "1.0", features = ["derive"] } 18 | serde_json = "1.0" -------------------------------------------------------------------------------- /asset_transfer_secure_private_rs/README.md: -------------------------------------------------------------------------------- 1 | # Asset Transfer 2 | 3 | This is the same model as the Asset Transfer in the hyperledger/fabric-samples -------------------------------------------------------------------------------- /asset_transfer_secure_private_rs/src/contracts.rs: -------------------------------------------------------------------------------- 1 | 2 | mod assettransferprivate; 3 | 4 | pub use crate::contracts::assettransferprivate::AssetTransfer as AssetTransfer; 5 | -------------------------------------------------------------------------------- /asset_transfer_secure_private_rs/src/lib.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | //! Main library module 6 | //! 7 | //! The purpose of this is to do register the contracts. 8 | //! 9 | //! Other setup can take place here but do so with 10 | //! caution. Any failure will terminate the container 11 | //! and there is limited scope for logging at stage in 12 | //! the lifecyle 13 | mod contracts; 14 | pub use crate::contracts::AssetTransfer; 15 | 16 | 17 | mod types; 18 | pub use crate::types::{AssetPrivate, Asset, PriceAgreement}; 19 | 20 | // The macro to indicate the function that will be used to register the contracts. 21 | // if there is more than one, use a comma separated list 22 | // 23 | // Provide the function that will create a new instance of the contract strcut 24 | // More than one contract struct can be provided. 25 | fabric_contract::register!( AssetTransfer::new ); -------------------------------------------------------------------------------- /asset_transfer_secure_private_rs/src/routing.md: -------------------------------------------------------------------------------- 1 | // the following (left for reference) is what the [contract_impl] macro would logically add 2 | // to this code 3 | 4 | // impl Routing for AssetContract { 5 | 6 | // fn route2(&self, ctx: Context, tx_fn: String, args: Vec) -> Result{ 7 | // ctx.log(format!("Inside the contract {} {:?}",tx_fn,args)); 8 | // let _r = match &tx_fn[..] { 9 | // "create_asset" => { 10 | 11 | // let a0 = match args.get(0) { 12 | // Some(a) => Ok(a), 13 | // None => Err(String::from("Missing argument 0")), 14 | // }; 15 | 16 | // let a1 = match args.get(1) { 17 | // Some(a) => Ok(a), 18 | // None => Err(String::from("Missing argument 1")), 19 | // }; 20 | 21 | // let _r=self.create_asset(ctx, a0.unwrap().to_string(), a1.unwrap().to_string()); 22 | // Ok(String::from("")) 23 | // }, 24 | // "read_asset" => { 25 | 26 | // let a0 = match args.get(0) { 27 | // Some(a) => Ok(a), 28 | // None => Err(String::from("Missing argument 0")), 29 | // }; 30 | 31 | // let _r=self.read_asset(ctx, a0.unwrap().to_string()); 32 | // Ok(String::from("")) 33 | // }, 34 | // _ => Err(String::from("Unknown transaction fn ")) 35 | // }; 36 | 37 | // Ok(String::from("200")) 38 | // } 39 | // } -------------------------------------------------------------------------------- /asset_transfer_secure_private_rs/src/types.rs: -------------------------------------------------------------------------------- 1 | mod asset; 2 | pub use asset::Asset as Asset; 3 | 4 | mod asset_private; 5 | pub use asset_private::AssetPrivate as AssetPrivate; 6 | 7 | mod price_agreement; 8 | pub use price_agreement::PriceAgreement as PriceAgreement; 9 | 10 | mod transfer_receipt; 11 | pub use transfer_receipt::TransferReceipt as TransferReceipt; 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /asset_transfer_secure_private_rs/src/types/asset_private.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | use fabric_contract::contract::*; 5 | use fabric_contract::data::*; 6 | use serde::{Deserialize, Serialize}; 7 | use std::str::from_utf8; 8 | 9 | // Use the log crate to support logging 10 | use log::{debug}; 11 | 12 | /// 13 | 14 | #[derive(Serialize, Deserialize, Debug, Default)] 15 | pub struct AssetPrivate { 16 | id: String, 17 | appraised_value: u32, 18 | itemcode: String, 19 | description: String 20 | } 21 | 22 | impl AssetPrivate { 23 | pub fn new(id: String, appraised_value: u32, itemcode:String, description: String) -> AssetPrivate { 24 | AssetPrivate { 25 | id, 26 | appraised_value, 27 | itemcode, 28 | description 29 | } 30 | } 31 | } 32 | 33 | /// Very important to implement the DataType Trait for the Asset 34 | /// 35 | /// This provides the ability to store the data in the ledger 36 | impl DataType for AssetPrivate { 37 | fn to_state(&self) -> State { 38 | let json = serde_json::to_string(self).unwrap(); 39 | debug!("ToState::{}",&json.as_str()); 40 | let buffer = json.into_bytes(); 41 | State::from((self.id.clone(), buffer)) 42 | } 43 | 44 | fn get_key(&self) -> String { 45 | self.id.clone() 46 | } 47 | 48 | fn build_from_state(state: State) -> Self { 49 | let b = state.value(); 50 | 51 | let str = match from_utf8(&b) { 52 | Ok(a) => a, 53 | Err(_) => panic!("Err"), 54 | }; 55 | debug!("build_from_state:: {}",&str); 56 | serde_json::from_str(str).unwrap() 57 | } 58 | 59 | fn form_key(k: &String) -> String { 60 | format!("AssetPrivate#{}",k) 61 | } 62 | } 63 | 64 | impl WireBufferFromReturnType for WireBuffer { 65 | fn from_rt(self: &mut Self, s: AssetPrivate) { 66 | // we've got a wire buffer object and we need to set the bytes here from the string 67 | let json = serde_json::to_string(&s).unwrap(); 68 | debug!("wire buffer returning the value {}",json.as_str()); 69 | let buffer = json.into_bytes(); 70 | self.buffer = Some(buffer); 71 | } 72 | } 73 | 74 | impl From<&WireBuffer> for AssetPrivate { 75 | fn from(wb: &WireBuffer) -> Self { 76 | match &wb.buffer { 77 | Some(buffer) => { 78 | match std::str::from_utf8(&buffer) { 79 | Ok(a) => serde_json::from_str(a).unwrap(), 80 | _ => unreachable!(), 81 | } 82 | } 83 | None => panic!(), 84 | } 85 | } 86 | } -------------------------------------------------------------------------------- /asset_transfer_secure_private_rs/src/types/price_agreement.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | use fabric_contract::contract::*; 5 | use fabric_contract::data::*; 6 | use serde::{Deserialize, Serialize}; 7 | use std::str::from_utf8; 8 | 9 | // Use the log crate to support logging 10 | use log::{debug}; 11 | 12 | 13 | #[derive(Serialize, Deserialize, Debug, Default)] 14 | pub struct PriceAgreement { 15 | id: String, 16 | price: u32 17 | } 18 | 19 | impl PriceAgreement { 20 | pub fn new(id: String, price: u32) -> PriceAgreement { 21 | PriceAgreement { 22 | id, 23 | price 24 | } 25 | } 26 | } 27 | 28 | /// Very important to implement the DataType Trait for the Asset 29 | /// 30 | /// This provides the ability to store the data in the ledger 31 | impl DataType for PriceAgreement { 32 | fn to_state(&self) -> State { 33 | let json = serde_json::to_string(self).unwrap(); 34 | debug!("ToState::{}",&json.as_str()); 35 | let buffer = json.into_bytes(); 36 | State::from((self.id.clone(), buffer)) 37 | } 38 | 39 | fn get_key(&self) -> String { 40 | PriceAgreement::form_key(&self.id) 41 | 42 | } 43 | 44 | fn build_from_state(state: State) -> Self { 45 | let b = state.value(); 46 | 47 | let str = match from_utf8(&b) { 48 | Ok(a) => a, 49 | Err(_) => panic!("Err"), 50 | }; 51 | debug!("build_from_state:: {}",&str); 52 | serde_json::from_str(str).unwrap() 53 | } 54 | 55 | 56 | fn form_key(k: &String) -> String { 57 | format!("PriceAgreement#{}",k) 58 | } 59 | } 60 | 61 | impl WireBufferFromReturnType for WireBuffer { 62 | fn from_rt(self: &mut Self, s: PriceAgreement) { 63 | // we've got a wire buffer object and we need to set the bytes here from the string 64 | let json = serde_json::to_string(&s).unwrap(); 65 | debug!("wire buffer returning the value {}",json.as_str()); 66 | let buffer = json.into_bytes(); 67 | self.buffer = Some(buffer); 68 | } 69 | } 70 | 71 | impl From<&WireBuffer> for PriceAgreement { 72 | fn from(wb: &WireBuffer) -> Self { 73 | match &wb.buffer { 74 | Some(buffer) => { 75 | match std::str::from_utf8(&buffer) { 76 | Ok(a) => serde_json::from_str(a).unwrap(), 77 | _ => unreachable!(), 78 | } 79 | } 80 | None => panic!(), 81 | } 82 | } 83 | } -------------------------------------------------------------------------------- /asset_transfer_secure_private_rs/src/types/trade_agreement.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | use fabric_contract::contract::*; 5 | use fabric_contract::data::*; 6 | use serde::{Deserialize, Serialize}; 7 | use std::str::from_utf8; 8 | 9 | // Use the log crate to support logging 10 | use log::debug; 11 | 12 | #[derive(Serialize, Deserialize, Debug, Default)] 13 | pub struct TradeAgreement { 14 | id: String, 15 | price: u32, 16 | trade_id: String, 17 | } 18 | 19 | impl TradeAgreement { 20 | pub fn new(id: String, price: u32, trade_id: String) -> TradeAgreement { 21 | TradeAgreement { 22 | id, 23 | price, 24 | trade_id, 25 | } 26 | } 27 | } 28 | 29 | /// Very important to implement the DataType Trait for the Asset 30 | /// 31 | /// This provides the ability to store the data in the ledger 32 | impl DataType for TradeAgreement { 33 | fn to_state(&self) -> State { 34 | let json = serde_json::to_string(self).unwrap(); 35 | debug!("ToState::{}", &json.as_str()); 36 | let buffer = json.into_bytes(); 37 | State::from((self.id.clone(), buffer)) 38 | } 39 | 40 | fn get_key(&self) -> String { 41 | TradeAgreement::form_key(&self.id) 42 | } 43 | 44 | fn build_from_state(state: State) -> Self { 45 | let b = state.value(); 46 | 47 | let str = match from_utf8(&b) { 48 | Ok(a) => a, 49 | Err(_) => panic!("Err"), 50 | }; 51 | debug!("build_from_state:: {}", &str); 52 | serde_json::from_str(str).unwrap() 53 | } 54 | 55 | fn form_key(k: &String) -> String { 56 | format!("TradeAgreement#{}",k) 57 | } 58 | } 59 | 60 | impl WireBufferFromReturnType for WireBuffer { 61 | fn from_rt(self: &mut Self, s: TradeAgreement) { 62 | // we've got a wire buffer object and we need to set the bytes here from the string 63 | let json = serde_json::to_string(&s).unwrap(); 64 | debug!("wire buffer returning the value {}", json.as_str()); 65 | let buffer = json.into_bytes(); 66 | self.buffer = Some(buffer); 67 | } 68 | } 69 | 70 | impl From<&WireBuffer> for TradeAgreement { 71 | fn from(wb: &WireBuffer) -> Self { 72 | match &wb.buffer { 73 | Some(buffer) => match std::str::from_utf8(&buffer) { 74 | Ok(a) => serde_json::from_str(a).unwrap(), 75 | _ => unreachable!(), 76 | }, 77 | None => panic!(), 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /asset_transfer_secure_private_rs/src/types/transfer_receipt.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | use fabric_contract::contract::*; 5 | use fabric_contract::{blockchain::TransactionContext, data::*}; 6 | use serde::{Deserialize, Serialize}; 7 | use std::str::from_utf8; 8 | 9 | // Use the log crate to support logging 10 | use log::debug; 11 | 12 | #[derive(Serialize, Deserialize, Debug, Default)] 13 | pub struct TransferReceipt { 14 | id: String, 15 | txid: String, 16 | timestamp: String, 17 | } 18 | 19 | impl TransferReceipt { 20 | pub fn new(id: String) -> Self { 21 | let tx = TransactionContext::current_transaction(); 22 | TransferReceipt { 23 | id, 24 | txid: tx.get_id(), 25 | timestamp: tx.get_timestamp(), 26 | } 27 | } 28 | } 29 | 30 | /// Very important to implement the DataType Trait for the Asset 31 | /// 32 | /// This provides the ability to store the data in the ledger 33 | impl DataType for TransferReceipt { 34 | fn to_state(&self) -> State { 35 | let json = serde_json::to_string(self).unwrap(); 36 | debug!("ToState::{}", &json.as_str()); 37 | let buffer = json.into_bytes(); 38 | State::from((self.id.clone(), buffer)) 39 | } 40 | 41 | fn get_key(&self) -> String { 42 | let k = format!("{}:{}",self.id,self.txid); 43 | TransferReceipt::form_key(&k) 44 | } 45 | 46 | fn build_from_state(state: State) -> Self { 47 | let b = state.value(); 48 | 49 | let str = match from_utf8(&b) { 50 | Ok(a) => a, 51 | Err(_) => panic!("Err"), 52 | }; 53 | debug!("build_from_state:: {}", &str); 54 | serde_json::from_str(str).unwrap() 55 | } 56 | 57 | fn form_key(k: &String) -> String { 58 | format!("TransferReceipt::{}",k) 59 | } 60 | } 61 | 62 | impl WireBufferFromReturnType for WireBuffer { 63 | fn from_rt(self: &mut Self, s: TransferReceipt) { 64 | // we've got a wire buffer object and we need to set the bytes here from the string 65 | let json = serde_json::to_string(&s).unwrap(); 66 | debug!("wire buffer returning the value {}", json.as_str()); 67 | let buffer = json.into_bytes(); 68 | self.buffer = Some(buffer); 69 | } 70 | } 71 | 72 | impl From<&WireBuffer> for TransferReceipt { 73 | fn from(wb: &WireBuffer) -> Self { 74 | match &wb.buffer { 75 | Some(buffer) => match std::str::from_utf8(&buffer) { 76 | Ok(a) => serde_json::from_str(a).unwrap(), 77 | _ => unreachable!(), 78 | }, 79 | None => panic!(), 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /azure-pipelines.yml: -------------------------------------------------------------------------------- 1 | # Starter pipeline 2 | # Start with a minimal pipeline that you can customize to build and deploy your code. 3 | # Add steps that build, run tests, deploy, and more: 4 | # https://aka.ms/yaml 5 | 6 | trigger: 7 | - master 8 | 9 | pool: 10 | vmImage: 'ubuntu-latest' 11 | 12 | jobs: 13 | - job: Clippy 14 | container: 'rust:latest' 15 | steps: 16 | - script: rustup component add clippy 17 | displayName: Install Clippy 18 | - script: cargo clippy --all-targets --all-features 19 | displayName: Run clippy 20 | 21 | - job: BuildUT 22 | displayName: 'Generate Rust lib' 23 | steps: 24 | - script: | 25 | curl https://sh.rustup.rs -sSf | sh -s -- -y --no-modify-path --default-toolchain default 26 | echo "##vso[task.prependpath]$HOME/.cargo/bin" 27 | rustup target add wasm32-unknown-unknown 28 | displayName: 'Install rust' 29 | 30 | - script: cargo build --all --target wasm32-unknown-unknown 31 | displayName: Cargo build 32 | 33 | - script: cargo test --all 34 | displayName: Cargo test 35 | 36 | - task: NodeTool@0 37 | inputs: 38 | versionSpec: '12.x' 39 | checkLatest: true 40 | 41 | - script: | 42 | ./tests/setup.sh 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /basic_contract_rs/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "basic_contract_rs" 3 | version = "0.1.0" 4 | authors = ["Matthew B White "] 5 | edition = "2018" 6 | publish = false 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [lib] 10 | crate-type = ["cdylib"] 11 | 12 | [dependencies] 13 | fabric_contract = { path = "../fabric_contract" } 14 | log = "0.4.8" 15 | wapc-guest = "0.3.1" 16 | 17 | serde = { version = "1.0", features = ["derive"] } 18 | serde_json = "1.0" -------------------------------------------------------------------------------- /basic_contract_rs/README.md: -------------------------------------------------------------------------------- 1 | # basic_contract_rs 2 | 3 | To create a basic Smart Contract. 4 | 5 | - Create a Rust library crate 6 | - add the following dependencies 7 | 8 | ``` 9 | fabric_contract = { path = "../fabric_contract" } 10 | log = "0.4.8" 11 | wapc-guest = "0.3.1" 12 | ``` 13 | 14 | - In the lib.rs of the your crate, register the contracts that will be required, by passing the a function that will create a new instance of the contract. 15 | 16 | ```rust 17 | fabric_contract::register!( AssetContract::new ); 18 | ``` 19 | 20 | - All contracts must implement the Contract trait 21 | - The `#[Contract_Impl]` and `#[Transaction()]` macros should be used on the contract implementation, and the transaction functions 22 | - Compile to Wasm -------------------------------------------------------------------------------- /basic_contract_rs/src/contracts.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | mod assetcontract; 6 | pub use crate::contracts::assetcontract::AssetContract; 7 | -------------------------------------------------------------------------------- /basic_contract_rs/src/lib.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | //! A basic Smart Contract 6 | //! 7 | //! Implements Creation, and Retrieval of a simple asset 8 | //! 9 | 10 | mod contracts; 11 | pub use crate::contracts::AssetContract; 12 | 13 | mod types; 14 | pub use crate::types::MyAsset; 15 | 16 | // The macro to indicate the function that will be used to register the contracts. 17 | // if there is more than one, use a comma separated list 18 | // 19 | // Provide the function that will create a new instance of the contract strcut 20 | // More than one contract struct can be provided. 21 | fabric_contract::register!(AssetContract::new); 22 | -------------------------------------------------------------------------------- /basic_contract_rs/src/routing.md: -------------------------------------------------------------------------------- 1 | // the following (left for reference) is what the [contract_impl] macro would logically add 2 | // to this code 3 | 4 | // impl Routing for AssetContract { 5 | 6 | // fn route2(&self, ctx: Context, tx_fn: String, args: Vec) -> Result{ 7 | // ctx.log(format!("Inside the contract {} {:?}",tx_fn,args)); 8 | // let _r = match &tx_fn[..] { 9 | // "create_asset" => { 10 | 11 | // let a0 = match args.get(0) { 12 | // Some(a) => Ok(a), 13 | // None => Err(String::from("Missing argument 0")), 14 | // }; 15 | 16 | // let a1 = match args.get(1) { 17 | // Some(a) => Ok(a), 18 | // None => Err(String::from("Missing argument 1")), 19 | // }; 20 | 21 | // let _r=self.create_asset(ctx, a0.unwrap().to_string(), a1.unwrap().to_string()); 22 | // Ok(String::from("")) 23 | // }, 24 | // "read_asset" => { 25 | 26 | // let a0 = match args.get(0) { 27 | // Some(a) => Ok(a), 28 | // None => Err(String::from("Missing argument 0")), 29 | // }; 30 | 31 | // let _r=self.read_asset(ctx, a0.unwrap().to_string()); 32 | // Ok(String::from("")) 33 | // }, 34 | // _ => Err(String::from("Unknown transaction fn ")) 35 | // }; 36 | 37 | // Ok(String::from("200")) 38 | // } 39 | // } -------------------------------------------------------------------------------- /basic_contract_rs/src/types.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | mod myasset; 6 | pub use myasset::MyAsset; 7 | -------------------------------------------------------------------------------- /basic_contract_rs/src/types/myasset.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | //! Very simple custom Asset object 6 | 7 | // Use the required crates 8 | use fabric_contract::contract::*; 9 | use fabric_contract::data::*; 10 | use serde::{Deserialize, Serialize}; 11 | use std::str::from_utf8; 12 | /// Basic definition of the asset object 13 | /// 14 | #[derive(Serialize, Deserialize, Debug, Default)] 15 | pub struct MyAsset { 16 | id: String, 17 | value: String 18 | } 19 | 20 | /// Standard Implementation 21 | impl MyAsset { 22 | 23 | pub fn new(id: String, value: String) -> MyAsset { 24 | MyAsset { 25 | id, 26 | value, 27 | } 28 | } 29 | 30 | pub fn get_value(&self) -> String { 31 | self.value.clone() 32 | } 33 | } 34 | 35 | /// The DataType trait must be implemented for this struct to be handled 36 | /// by the contract 37 | impl DataType for MyAsset { 38 | fn to_state(&self) -> State { 39 | let json = serde_json::to_string(self).unwrap(); 40 | let buffer = json.into_bytes(); 41 | State::from((MyAsset::form_key(&self.id.clone()), buffer)) 42 | } 43 | 44 | fn get_key(&self) -> String { 45 | MyAsset::form_key(&self.id) 46 | } 47 | 48 | fn build_from_state(state: State) -> Self { 49 | let b = state.value(); 50 | 51 | let str = match from_utf8(&b) { 52 | Ok(a) => a, 53 | Err(_) => panic!("Err"), 54 | }; 55 | serde_json::from_str(str).unwrap() 56 | } 57 | 58 | fn form_key(k: &String) -> String { 59 | format!("MyAsset::{}",k) 60 | } 61 | } 62 | 63 | impl WireBufferFromReturnType for WireBuffer { 64 | fn from_rt(self: &mut Self, s: MyAsset) { 65 | // we've got a wire buffer object and we need to set the bytes here from the string 66 | let json = serde_json::to_string(&s).unwrap(); 67 | 68 | let buffer = json.into_bytes(); 69 | self.buffer = Some(buffer); 70 | } 71 | } 72 | 73 | impl From<&WireBuffer> for MyAsset { 74 | fn from(wb: &WireBuffer) -> Self { 75 | match &wb.buffer { 76 | Some(buffer) => { 77 | match std::str::from_utf8(&buffer) { 78 | Ok(a) => serde_json::from_str(a).unwrap(), 79 | _ => unreachable!(), 80 | } 81 | } 82 | None => panic!(), 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /docs/.gitignore: -------------------------------------------------------------------------------- 1 | _site 2 | -------------------------------------------------------------------------------- /docs/404.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: "404 - Page Not Found" 3 | permalink: /404.html 4 | --- 5 | 6 | ## The page you wanted does not exist 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | gem 'github-pages', group: :jekyll_plugins -------------------------------------------------------------------------------- /docs/_config.yml: -------------------------------------------------------------------------------- 1 | theme: minima 2 | title: "fabric-contract-api-rust" 3 | header_pages: 4 | - guides/getting-started.md 5 | baseurl: /fabric-contract-api-rust -------------------------------------------------------------------------------- /docs/_includes/footer.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledgendary/fabric-contract-api-rust/1b35443a767379f859d6ef65d2e3cf134db2f22a/docs/_includes/footer.html -------------------------------------------------------------------------------- /docs/_includes/header.html: -------------------------------------------------------------------------------- 1 | 23 | -------------------------------------------------------------------------------- /docs/apidoc/COPYRIGHT.txt: -------------------------------------------------------------------------------- 1 | These documentation pages include resources by third parties. This copyright 2 | file applies only to those resources. The following third party resources are 3 | included, and carry their own copyright notices and license terms: 4 | 5 | * Fira Sans (FiraSans-Regular.woff, FiraSans-Medium.woff): 6 | 7 | Copyright (c) 2014, Mozilla Foundation https://mozilla.org/ 8 | with Reserved Font Name Fira Sans. 9 | 10 | Copyright (c) 2014, Telefonica S.A. 11 | 12 | Licensed under the SIL Open Font License, Version 1.1. 13 | See FiraSans-LICENSE.txt. 14 | 15 | * rustdoc.css, main.js, and playpen.js: 16 | 17 | Copyright 2015 The Rust Developers. 18 | Licensed under the Apache License, Version 2.0 (see LICENSE-APACHE.txt) or 19 | the MIT license (LICENSE-MIT.txt) at your option. 20 | 21 | * normalize.css: 22 | 23 | Copyright (c) Nicolas Gallagher and Jonathan Neal. 24 | Licensed under the MIT license (see LICENSE-MIT.txt). 25 | 26 | * Source Code Pro (SourceCodePro-Regular.woff, SourceCodePro-Semibold.woff): 27 | 28 | Copyright 2010, 2012 Adobe Systems Incorporated (http://www.adobe.com/), 29 | with Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark 30 | of Adobe Systems Incorporated in the United States and/or other countries. 31 | 32 | Licensed under the SIL Open Font License, Version 1.1. 33 | See SourceCodePro-LICENSE.txt. 34 | 35 | * Source Serif Pro (SourceSerifPro-Regular.ttf.woff, 36 | SourceSerifPro-Bold.ttf.woff, SourceSerifPro-It.ttf.woff): 37 | 38 | Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/), with 39 | Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark of 40 | Adobe Systems Incorporated in the United States and/or other countries. 41 | 42 | Licensed under the SIL Open Font License, Version 1.1. 43 | See SourceSerifPro-LICENSE.txt. 44 | 45 | This copyright file is intended to be distributed with rustdoc output. 46 | -------------------------------------------------------------------------------- /docs/apidoc/FiraSans-Medium.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledgendary/fabric-contract-api-rust/1b35443a767379f859d6ef65d2e3cf134db2f22a/docs/apidoc/FiraSans-Medium.woff -------------------------------------------------------------------------------- /docs/apidoc/FiraSans-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledgendary/fabric-contract-api-rust/1b35443a767379f859d6ef65d2e3cf134db2f22a/docs/apidoc/FiraSans-Regular.woff -------------------------------------------------------------------------------- /docs/apidoc/LICENSE-MIT.txt: -------------------------------------------------------------------------------- 1 | Permission is hereby granted, free of charge, to any 2 | person obtaining a copy of this software and associated 3 | documentation files (the "Software"), to deal in the 4 | Software without restriction, including without 5 | limitation the rights to use, copy, modify, merge, 6 | publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software 8 | is furnished to do so, subject to the following 9 | conditions: 10 | 11 | The above copyright notice and this permission notice 12 | shall be included in all copies or substantial portions 13 | of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF 16 | ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 17 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 18 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 19 | SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 22 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /docs/apidoc/SourceCodePro-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledgendary/fabric-contract-api-rust/1b35443a767379f859d6ef65d2e3cf134db2f22a/docs/apidoc/SourceCodePro-Regular.woff -------------------------------------------------------------------------------- /docs/apidoc/SourceCodePro-Semibold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledgendary/fabric-contract-api-rust/1b35443a767379f859d6ef65d2e3cf134db2f22a/docs/apidoc/SourceCodePro-Semibold.woff -------------------------------------------------------------------------------- /docs/apidoc/SourceSerifPro-Bold.ttf.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledgendary/fabric-contract-api-rust/1b35443a767379f859d6ef65d2e3cf134db2f22a/docs/apidoc/SourceSerifPro-Bold.ttf.woff -------------------------------------------------------------------------------- /docs/apidoc/SourceSerifPro-It.ttf.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledgendary/fabric-contract-api-rust/1b35443a767379f859d6ef65d2e3cf134db2f22a/docs/apidoc/SourceSerifPro-It.ttf.woff -------------------------------------------------------------------------------- /docs/apidoc/SourceSerifPro-Regular.ttf.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledgendary/fabric-contract-api-rust/1b35443a767379f859d6ef65d2e3cf134db2f22a/docs/apidoc/SourceSerifPro-Regular.ttf.woff -------------------------------------------------------------------------------- /docs/apidoc/aliases.js: -------------------------------------------------------------------------------- 1 | var ALIASES = {}; 2 | ALIASES["basic_contract_rs"] = {}; 3 | ALIASES["contract_macros"] = {}; 4 | ALIASES["fabric_contract"] = {}; 5 | -------------------------------------------------------------------------------- /docs/apidoc/asset_transfer_private_rs/all.html: -------------------------------------------------------------------------------- 1 | List of all items in this crate

[] 2 | 3 | List of all items

Structs

Functions

-------------------------------------------------------------------------------- /docs/apidoc/asset_transfer_private_rs/contracts/assettransferprivate/struct.AssetTransfer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to ../../../asset_transfer_private_rs/struct.AssetTransfer.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/apidoc/asset_transfer_private_rs/fn.__launch.html: -------------------------------------------------------------------------------- 1 | asset_transfer_private_rs::__launch - Rust

[][src]Function asset_transfer_private_rs::__launch

pub fn __launch()
-------------------------------------------------------------------------------- /docs/apidoc/asset_transfer_private_rs/sidebar-items.js: -------------------------------------------------------------------------------- 1 | initSidebarItems({"fn":[["__guest_call",""],["__launch",""],["once_wapc",""]],"struct":[["Asset",""],["AssetPrivate",""],["AssetTransfer","Structure for the AssetContract, on which implemenation transaction functions will be added"],["PriceAgreement",""]]}); -------------------------------------------------------------------------------- /docs/apidoc/asset_transfer_private_rs/types/asset/struct.Asset.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to ../../../asset_transfer_private_rs/struct.Asset.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/apidoc/asset_transfer_private_rs/types/asset_private/struct.AssetPrivate.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to ../../../asset_transfer_private_rs/struct.AssetPrivate.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/apidoc/asset_transfer_private_rs/types/price_agreement/struct.PriceAgreement.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to ../../../asset_transfer_private_rs/struct.PriceAgreement.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/apidoc/asset_transfer_rs/all.html: -------------------------------------------------------------------------------- 1 | List of all items in this crate

[] 2 | 3 | List of all items

Structs

Functions

-------------------------------------------------------------------------------- /docs/apidoc/asset_transfer_rs/contracts/assettransfer/struct.AssetTransfer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to ../../../asset_transfer_rs/struct.AssetTransfer.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/apidoc/asset_transfer_rs/contracts/assettransferquery/struct.AssetTransferQuery.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to ../../../asset_transfer_rs/struct.AssetTransferQuery.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/apidoc/asset_transfer_rs/contracts/transfercontract/struct.TransferContract.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to ../../../asset_transfer_rs/struct.TransferContract.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/apidoc/asset_transfer_rs/fn.__launch.html: -------------------------------------------------------------------------------- 1 | asset_transfer_rs::__launch - Rust

[][src]Function asset_transfer_rs::__launch

pub fn __launch()
-------------------------------------------------------------------------------- /docs/apidoc/asset_transfer_rs/sidebar-items.js: -------------------------------------------------------------------------------- 1 | initSidebarItems({"fn":[["__guest_call",""],["__launch",""],["once_wapc",""]],"struct":[["Asset",""],["AssetTransfer","Structure for the AssetContract, on which implemenation transaction functions will be added"],["AssetTransferQuery","Structure for the AssetContract, on which implemenation transaction functions will be added"]]}); -------------------------------------------------------------------------------- /docs/apidoc/asset_transfer_rs/types/asset/struct.Asset.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to ../../../asset_transfer_rs/struct.Asset.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/apidoc/asset_transfer_rs/types/myasset/struct.MyAsset.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to ../../../asset_transfer_rs/struct.MyAsset.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/apidoc/basic_contract_rs/all.html: -------------------------------------------------------------------------------- 1 | List of all items in this crate

[] 2 | 3 | List of all items

Structs

Functions

-------------------------------------------------------------------------------- /docs/apidoc/basic_contract_rs/contracts/assetcontract/struct.AssetContract.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to ../../../basic_contract_rs/struct.AssetContract.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/apidoc/basic_contract_rs/fn.__launch.html: -------------------------------------------------------------------------------- 1 | basic_contract_rs::__launch - Rust

[][src]Function basic_contract_rs::__launch

pub fn __launch()
-------------------------------------------------------------------------------- /docs/apidoc/basic_contract_rs/sidebar-items.js: -------------------------------------------------------------------------------- 1 | initSidebarItems({"fn":[["__guest_call",""],["__launch",""],["once_wapc",""]],"struct":[["AssetContract","Structure for the AssetContract, on which implemenation transaction functions will be added"],["MyAsset","Basic definition of the asset object"]]}); -------------------------------------------------------------------------------- /docs/apidoc/basic_contract_rs/types/myasset/struct.MyAsset.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to ../../../basic_contract_rs/struct.MyAsset.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/apidoc/brush.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/apidoc/contract_macros/all.html: -------------------------------------------------------------------------------- 1 | List of all items in this crate

[] 2 | 3 | List of all items

Attribute Macros

Derive Macros

-------------------------------------------------------------------------------- /docs/apidoc/contract_macros/attr.property.html: -------------------------------------------------------------------------------- 1 | contract_macros::property - Rust

[][src]Attribute Macro contract_macros::property

#[property]

Define the properties of the datatype

2 |
-------------------------------------------------------------------------------- /docs/apidoc/contract_macros/derive.DataTypeMacro.html: -------------------------------------------------------------------------------- 1 | contract_macros::DataTypeMacro - Rust

[][src]Derive Macro contract_macros::DataTypeMacro

#[derive(DataTypeMacro)]

Use this to mark the structs that serve as complex data types 2 | Need to provide example

3 |
-------------------------------------------------------------------------------- /docs/apidoc/contract_macros/sidebar-items.js: -------------------------------------------------------------------------------- 1 | initSidebarItems({"attr":[["contract_impl","Use this macro to mark the implementation of the your contract structure"],["property","Define the properties of the datatype"],["transaction","Use this to mark the functions that are considered to be transaction functions"]],"derive":[["DataTypeMacro","Use this to mark the structs that serve as complex data types Need to provide example"]]}); -------------------------------------------------------------------------------- /docs/apidoc/demo/all.html: -------------------------------------------------------------------------------- 1 | List of all items in this crate

[] 2 | 3 | List of all items

Functions

-------------------------------------------------------------------------------- /docs/apidoc/demo/fn.main.html: -------------------------------------------------------------------------------- 1 | demo::main - Rust

[][src]Function demo::main

fn main()
-------------------------------------------------------------------------------- /docs/apidoc/demo/index.html: -------------------------------------------------------------------------------- 1 | demo - Rust

[][src]Crate demo

Functions

2 |
main
-------------------------------------------------------------------------------- /docs/apidoc/demo/sidebar-items.js: -------------------------------------------------------------------------------- 1 | initSidebarItems({"fn":[["main",""]]}); -------------------------------------------------------------------------------- /docs/apidoc/down-arrow.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/attr.property.html: -------------------------------------------------------------------------------- 1 | fabric_contract::property - Rust

[]Attribute Macro fabric_contract::property

#[property]

Define the properties of the datatype

2 |
-------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/blockchain/sidebar-items.js: -------------------------------------------------------------------------------- 1 | initSidebarItems({"struct":[["ClientIdentity","Represents the identity that is requesting this transaction"],["TransactionContext","Represents a transaction"]]}); -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/blockchainapi/clientidentity/struct.ClientIdentity.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to ../../../fabric_contract/blockchain/struct.ClientIdentity.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/blockchainapi/transaction/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to ../../../fabric_contract/fabric_blockchain/transaction/index.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/blockchainapi/transaction/struct.Transaction.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to ../../../fabric_contract/blockchain/struct.Transaction.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/blockchainapi/transactioncontext/struct.TransactionContext.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to ../../../fabric_contract/blockchain/struct.TransactionContext.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/contract/sidebar-items.js: -------------------------------------------------------------------------------- 1 | initSidebarItems({"attr":[["Contract_Impl","Use this macro to mark the implementation of the your contract structure"],["Transaction","Use this to mark the functions that are considered to be transaction functions"]],"enum":[["CollectionName","Collection Name"],["Expression","The Expressions - either AND, OR, OUTOF or the actual Principal"],["KeyQueryHandler","Key Queryhandler"],["ROLE","The ROLE definition"]],"struct":[["Collection",""],["ContractError","Contract Error is what the contract will return to indicate an error Typically this would be for contract developers to use to mark that a failure has occured, and give information about what that means in the context of their implementation"],["ContractManager","Contract Manager structure that holds the list contract objects"],["Ledger","Ledger representing high level concept of the Fabric Blockchain network"],["LedgerError","Ledger Error is returned by the API calls made against the ledger api, eg, if a state can be found"],["State","A State is the combination of key and value that are contained within a collection."],["StateBasedEndorsement","Struct to represent the Overal Endorsement"],["StateHash",""],["StateQueryList",""]],"trait":[["Contract","Trait that is implemented for each contract Default implementations here"],["Metadata",""],["Routing",""],["VerifyHashConsistency",""]]}); -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/contractapi/context/sidebar-items.js: -------------------------------------------------------------------------------- 1 | initSidebarItems({"struct":[["Context",""]]}); -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/contractapi/context/struct.Context.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to ../../../fabric_contract/contract/struct.Context.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/contractapi/contract/sidebar-items.js: -------------------------------------------------------------------------------- 1 | initSidebarItems({"trait":[["Contract","Trait that is implemented for each contract Default implementations here"],["Routing",""]]}); -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/contractapi/contract/trait.Contract.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to ../../../fabric_contract/contract/trait.Contract.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/contractapi/contract/trait.Metadata.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to ../../../fabric_contract/contract/trait.Metadata.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/contractapi/contract/trait.Routing.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to ../../../fabric_contract/contract/trait.Routing.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/contractapi/contractdefn/sidebar-items.js: -------------------------------------------------------------------------------- 1 | initSidebarItems({}); -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/contractapi/contractdefn/struct.ContractDefn.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to ../../../fabric_contract/prelude/struct.ContractDefn.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/contractapi/contractmanager/sidebar-items.js: -------------------------------------------------------------------------------- 1 | initSidebarItems({"struct":[["ContractManager","Contract Manager structure that holds the list contract objects"]]}); -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/contractapi/contractmanager/struct.ContractManager.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to ../../../fabric_contract/contract/struct.ContractManager.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/contractapi/sidebar-items.js: -------------------------------------------------------------------------------- 1 | initSidebarItems({"mod":[["context",""],["contract",""],["contractdefn",""],["contractmanager",""],["transaction",""]]}); -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/contractapi/transaction/sidebar-items.js: -------------------------------------------------------------------------------- 1 | initSidebarItems({"struct":[["TransactionFn",""]]}); -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/contractapi/transaction/struct.TransactionFn.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to ../../../fabric_contract/prelude/struct.TransactionFn.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/contractapi/transaction/struct.TransactionFnBuilder.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to ../../../fabric_contract/prelude/struct.TransactionFnBuilder.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/data/attr.Property.html: -------------------------------------------------------------------------------- 1 | fabric_contract::data::Property - Rust

[]Attribute Macro fabric_contract::data::Property

#[Property]

Define the properties of the datatype

2 |
-------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/data/sidebar-items.js: -------------------------------------------------------------------------------- 1 | initSidebarItems({"attr":[["Property","Define the properties of the datatype"]],"struct":[["TypeSchema",""],["WireBuffer",""]],"trait":[["DataType",""],["WireBufferFromReturnType",""]]}); -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/dataapi/typeschema/struct.TypeSchema.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to ../../../fabric_contract/data/struct.TypeSchema.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/dataapi/wirebuffer/struct.WireBuffer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to ../../../fabric_contract/data/struct.WireBuffer.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/dataapi/wirebuffer/trait.WireBufferFromReturnType.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to ../../../fabric_contract/data/trait.WireBufferFromReturnType.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/derive.DataTypeMacro.html: -------------------------------------------------------------------------------- 1 | fabric_contract::DataTypeMacro - Rust

[]Derive Macro fabric_contract::DataTypeMacro

#[derive(DataTypeMacro)]

Use this to mark the structs that serve as complex data types 2 | Need to provide example

3 |
-------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/error/sidebar-items.js: -------------------------------------------------------------------------------- 1 | initSidebarItems({"struct":[["ContractError",""]]}); -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/error/struct.ContractError.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to ../../fabric_contract/contract/struct.ContractError.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/error/struct.LedgerError.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to ../../fabric_contract/contract/struct.LedgerError.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/fabric_blockchain/sidebar-items.js: -------------------------------------------------------------------------------- 1 | initSidebarItems({"struct":[["Transaction","Represents a transaction "]]}); -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/fabric_blockchain/transaction/sidebar-items.js: -------------------------------------------------------------------------------- 1 | initSidebarItems({"struct":[["Transaction","Represents a transaction "]]}); -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/ledgerapi/collection/enum.CollectionName.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to ../../../fabric_contract/contract/enum.CollectionName.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/ledgerapi/collection/enum.KeyQueryHandler.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to ../../../fabric_contract/contract/enum.KeyQueryHandler.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/ledgerapi/collection/sidebar-items.js: -------------------------------------------------------------------------------- 1 | initSidebarItems({"enum":[["CollectionName","CollectionName Can be either the "],["KeyQueryHandler",""]],"struct":[["Collection",""]],"trait":[["CollectionIterator",""]]}); -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/ledgerapi/collection/struct.Collection.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to ../../../fabric_contract/contract/struct.Collection.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/ledgerapi/datatype/trait.DataType.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to ../../../fabric_contract/data/trait.DataType.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/ledgerapi/endorsement/enum.Expression.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to ../../../fabric_contract/contract/enum.Expression.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/ledgerapi/endorsement/enum.ROLE.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to ../../../fabric_contract/contract/enum.ROLE.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/ledgerapi/endorsement/struct.StateBasedEndorsement.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to ../../../fabric_contract/contract/struct.StateBasedEndorsement.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/ledgerapi/ledger/sidebar-items.js: -------------------------------------------------------------------------------- 1 | initSidebarItems({"struct":[["Ledger","Ledger representing high level concept of the Fabric Blockchain network"]]}); -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/ledgerapi/ledger/struct.Ledger.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to ../../../fabric_contract/contract/struct.Ledger.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/ledgerapi/sidebar-items.js: -------------------------------------------------------------------------------- 1 | initSidebarItems({"mod":[["collection",""],["ledger",""],["state",""]]}); -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/ledgerapi/state/sidebar-items.js: -------------------------------------------------------------------------------- 1 | initSidebarItems({"struct":[["State","A State is the combination of key and value that are contained within a collection."]],"trait":[["DataType",""]]}); -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/ledgerapi/state/struct.State.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to ../../../fabric_contract/contract/struct.State.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/ledgerapi/state/struct.StateHash.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to ../../../fabric_contract/contract/struct.StateHash.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/ledgerapi/state/trait.VerifyHashConsistency.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to ../../../fabric_contract/contract/trait.VerifyHashConsistency.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/ledgerapi/statequerylist/struct.StateQueryList.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to ../../../fabric_contract/contract/struct.StateQueryList.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/macro.launch_handler!.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to macro.launch_handler.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/macro.register!.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to macro.register.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/prelude/macro.wapc_handler!.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to macro.wapc_handler.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/prelude/sidebar-items.js: -------------------------------------------------------------------------------- 1 | initSidebarItems({"fn":[["handle_wapc","Map to the ContractService"],["host_call","The function through which all host calls take place."],["host_log",""]],"macro":[["wapc_handler",""]],"struct":[["ContractDefn","Internal definition of a contract"],["TransactionFn",""],["TransactionFnBuilder",""]],"type":[["CallResult",""],["Result","WaPC Guest SDK result type"]]}); -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/runtime/register/sidebar-items.js: -------------------------------------------------------------------------------- 1 | initSidebarItems({"struct":[["ContractRuntime",""]]}); -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/runtime/runtime/items/sidebar-items.js: -------------------------------------------------------------------------------- 1 | initSidebarItems({"struct":[["Arguments",""],["Return",""]]}); -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/runtime/runtime/sidebar-items.js: -------------------------------------------------------------------------------- 1 | initSidebarItems({"fn":[["__guest_call",""],["__log",""],["handle_wapc",""],["log",""]],"mod":[["items",""]]}); -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/runtime/sidebar-items.js: -------------------------------------------------------------------------------- 1 | initSidebarItems({"fn":[["hook","Hook function to capture the panic and route it to the logger"],["init_logger","Called from the register contract macro."]]}); -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/runtimeapi/logger/fn.hook.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to ../../../fabric_contract/runtime/fn.hook.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/runtimeapi/logger/fn.init_logger.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to ../../../fabric_contract/runtime/fn.init_logger.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/runtimeapi/register/struct.ContractRuntime.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to ../../../fabric_contract/runtime/struct.ContractRuntime.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/runtimeapi/wapc/fn.handle_wapc.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to ../../../fabric_contract/prelude/fn.handle_wapc.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/runtimeapi/wapc/fn.log.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Redirecting to ../../../fabric_contract/prelude/fn.host_log.html...

8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/sidebar-items.js: -------------------------------------------------------------------------------- 1 | initSidebarItems({"attr":[["contract_impl","Use this macro to mark the implementation of the your contract structure"],["property","Define the properties of the datatype"],["transaction","Use this to mark the functions that are considered to be transaction functions"]],"derive":[["DataTypeMacro","Use this to mark the structs that serve as complex data types Need to provide example"]],"macro":[["register","Macro to use in the lib.rs file of your contract's crate"]],"mod":[["blockchain","Module to provide APIs to get information about Fabric"],["contract","Module to provide APIs to write contracts and interact with the ledger"],["data","Module to use to define the complex datatypes"],["prelude",""],["runtime","Module to provide 'runtime' services."]]}); -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract/transaction/sidebar-items.js: -------------------------------------------------------------------------------- 1 | initSidebarItems({"struct":[["Transaction","Represents a transaction "]]}); -------------------------------------------------------------------------------- /docs/apidoc/fabric_contract_macros/all.html: -------------------------------------------------------------------------------- 1 | List of all items in this crate

[] 2 | 3 | List of all items

Attribute Macros

Derive Macros

-------------------------------------------------------------------------------- /docs/apidoc/fabric_contract_macros/attr.property.html: -------------------------------------------------------------------------------- 1 | fabric_contract_macros::property - Rust

[][src]Attribute Macro fabric_contract_macros::property

#[property]

Define the properties of the datatype

2 |
-------------------------------------------------------------------------------- /docs/apidoc/fabric_contract_macros/derive.DataTypeMacro.html: -------------------------------------------------------------------------------- 1 | fabric_contract_macros::DataTypeMacro - Rust

[][src]Derive Macro fabric_contract_macros::DataTypeMacro

#[derive(DataTypeMacro)]

Use this to mark the structs that serve as complex data types 2 | Need to provide example

3 |
-------------------------------------------------------------------------------- /docs/apidoc/fabric_contract_macros/sidebar-items.js: -------------------------------------------------------------------------------- 1 | initSidebarItems({"attr":[["contract_impl","Use this macro to mark the implementation of the your contract structure"],["property","Define the properties of the datatype"],["transaction","Use this to mark the functions that are considered to be transaction functions"]],"derive":[["DataTypeMacro","Use this to mark the structs that serve as complex data types Need to provide example"]]}); -------------------------------------------------------------------------------- /docs/apidoc/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledgendary/fabric-contract-api-rust/1b35443a767379f859d6ef65d2e3cf134db2f22a/docs/apidoc/favicon.ico -------------------------------------------------------------------------------- /docs/apidoc/implementors/core/clone/trait.Clone.js: -------------------------------------------------------------------------------- 1 | (function() {var implementors = {}; 2 | implementors["fabric_contract"] = [{"text":"impl Clone for TransactionContext","synthetic":false,"types":["fabric_contract::blockchainapi::transactioncontext::TransactionContext"]},{"text":"impl Clone for TransactionFn","synthetic":false,"types":["fabric_contract::contractapi::transaction::TransactionFn"]},{"text":"impl Clone for TransactionFnBuilder","synthetic":false,"types":["fabric_contract::contractapi::transaction::TransactionFnBuilder"]},{"text":"impl Clone for TypeSchema","synthetic":false,"types":["fabric_contract::dataapi::typeschema::TypeSchema"]},{"text":"impl Clone for ROLE","synthetic":false,"types":["fabric_contract::ledgerapi::endorsement::ROLE"]},{"text":"impl Clone for Expression","synthetic":false,"types":["fabric_contract::ledgerapi::endorsement::Expression"]}]; 3 | if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() -------------------------------------------------------------------------------- /docs/apidoc/implementors/core/cmp/trait.PartialEq.js: -------------------------------------------------------------------------------- 1 | (function() {var implementors = {}; 2 | implementors["fabric_contract"] = [{"text":"impl PartialEq<Arguments> for Arguments","synthetic":false,"types":["fabric_contract::runtime::runtime::items::Arguments"]},{"text":"impl PartialEq<Return> for Return","synthetic":false,"types":["fabric_contract::runtime::runtime::items::Return"]}]; 3 | if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() -------------------------------------------------------------------------------- /docs/apidoc/implementors/core/fmt/trait.Display.js: -------------------------------------------------------------------------------- 1 | (function() {var implementors = {}; 2 | implementors["fabric_contract"] = [{"text":"impl Display for TransactionFn","synthetic":false,"types":["fabric_contract::contractapi::transaction::TransactionFn"]},{"text":"impl Display for TypeSchema","synthetic":false,"types":["fabric_contract::dataapi::typeschema::TypeSchema"]},{"text":"impl Display for ContractError","synthetic":false,"types":["fabric_contract::error::ContractError"]},{"text":"impl Display for LedgerError","synthetic":false,"types":["fabric_contract::error::LedgerError"]},{"text":"impl Display for CollectionName","synthetic":false,"types":["fabric_contract::ledgerapi::collection::CollectionName"]}]; 3 | if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() -------------------------------------------------------------------------------- /docs/apidoc/implementors/core/iter/traits/collect/trait.FromIterator.js: -------------------------------------------------------------------------------- 1 | (function() {var implementors = {}; 2 | implementors["fabric_contract"] = [{"text":"impl FromIterator<State> for StateQueryList","synthetic":false,"types":["fabric_contract::ledgerapi::statequerylist::StateQueryList"]}]; 3 | if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() -------------------------------------------------------------------------------- /docs/apidoc/implementors/core/iter/traits/collect/trait.IntoIterator.js: -------------------------------------------------------------------------------- 1 | (function() {var implementors = {}; 2 | implementors["fabric_contract"] = [{"text":"impl IntoIterator for StateQueryList","synthetic":false,"types":["fabric_contract::ledgerapi::statequerylist::StateQueryList"]}]; 3 | if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() -------------------------------------------------------------------------------- /docs/apidoc/implementors/core/marker/trait.Copy.js: -------------------------------------------------------------------------------- 1 | (function() {var implementors = {}; 2 | implementors["fabric_contract"] = [{"text":"impl Copy for TypeSchema","synthetic":false,"types":["fabric_contract::dataapi::typeschema::TypeSchema"]}]; 3 | if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() -------------------------------------------------------------------------------- /docs/apidoc/implementors/core/marker/trait.StructuralPartialEq.js: -------------------------------------------------------------------------------- 1 | (function() {var implementors = {}; 2 | implementors["fabric_contract"] = [{"text":"impl StructuralPartialEq for Arguments","synthetic":false,"types":["fabric_contract::runtime::runtime::items::Arguments"]},{"text":"impl StructuralPartialEq for Return","synthetic":false,"types":["fabric_contract::runtime::runtime::items::Return"]}]; 3 | if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() -------------------------------------------------------------------------------- /docs/apidoc/implementors/fabric_contract/contract/trait.VerifyHashConsistency.js: -------------------------------------------------------------------------------- 1 | (function() {var implementors = {}; 2 | implementors["fabric_contract"] = []; 3 | if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() -------------------------------------------------------------------------------- /docs/apidoc/implementors/fabric_contract/contractapi/contract/trait.Contract.js: -------------------------------------------------------------------------------- 1 | (function() {var implementors = {}; 2 | implementors["asset_transfer_private_rs"] = [{"text":"impl Contract for AssetTransfer","synthetic":false,"types":["asset_transfer_private_rs::contracts::assettransferprivate::AssetTransfer"]}]; 3 | implementors["asset_transfer_rs"] = [{"text":"impl Contract for AssetTransfer","synthetic":false,"types":["asset_transfer_rs::contracts::assettransfer::AssetTransfer"]},{"text":"impl Contract for AssetTransferQuery","synthetic":false,"types":["asset_transfer_rs::contracts::assettransferquery::AssetTransferQuery"]}]; 4 | implementors["basic_contract_rs"] = [{"text":"impl Contract for AssetContract","synthetic":false,"types":["basic_contract_rs::contracts::assetcontract::AssetContract"]}]; 5 | if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() -------------------------------------------------------------------------------- /docs/apidoc/implementors/fabric_contract/contractapi/contract/trait.Metadata.js: -------------------------------------------------------------------------------- 1 | (function() {var implementors = {}; 2 | implementors["asset_transfer_private_rs"] = [{"text":"impl Metadata for AssetTransfer","synthetic":false,"types":["asset_transfer_private_rs::contracts::assettransferprivate::AssetTransfer"]}]; 3 | implementors["asset_transfer_rs"] = [{"text":"impl Metadata for AssetTransfer","synthetic":false,"types":["asset_transfer_rs::contracts::assettransfer::AssetTransfer"]},{"text":"impl Metadata for AssetTransferQuery","synthetic":false,"types":["asset_transfer_rs::contracts::assettransferquery::AssetTransferQuery"]}]; 4 | implementors["basic_contract_rs"] = [{"text":"impl Metadata for AssetContract","synthetic":false,"types":["basic_contract_rs::contracts::assetcontract::AssetContract"]}]; 5 | if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() -------------------------------------------------------------------------------- /docs/apidoc/implementors/fabric_contract/contractapi/contract/trait.Routing.js: -------------------------------------------------------------------------------- 1 | (function() {var implementors = {}; 2 | implementors["asset_transfer_private_rs"] = [{"text":"impl Routing for AssetTransfer","synthetic":false,"types":["asset_transfer_private_rs::contracts::assettransferprivate::AssetTransfer"]}]; 3 | implementors["asset_transfer_rs"] = [{"text":"impl Routing for AssetTransfer","synthetic":false,"types":["asset_transfer_rs::contracts::assettransfer::AssetTransfer"]},{"text":"impl Routing for AssetTransferQuery","synthetic":false,"types":["asset_transfer_rs::contracts::assettransferquery::AssetTransferQuery"]}]; 4 | implementors["basic_contract_rs"] = [{"text":"impl Routing for AssetContract","synthetic":false,"types":["basic_contract_rs::contracts::assetcontract::AssetContract"]}]; 5 | if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() -------------------------------------------------------------------------------- /docs/apidoc/implementors/fabric_contract/data/trait.WireBufferFromReturnType.js: -------------------------------------------------------------------------------- 1 | (function() {var implementors = {}; 2 | implementors["fabric_contract"] = []; 3 | if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() -------------------------------------------------------------------------------- /docs/apidoc/implementors/fabric_contract/ledgerapi/datatype/trait.DataType.js: -------------------------------------------------------------------------------- 1 | (function() {var implementors = {}; 2 | implementors["asset_transfer_private_rs"] = [{"text":"impl DataType for Asset","synthetic":false,"types":["asset_transfer_private_rs::types::asset::Asset"]},{"text":"impl DataType for AssetPrivate","synthetic":false,"types":["asset_transfer_private_rs::types::asset_private::AssetPrivate"]},{"text":"impl DataType for PriceAgreement","synthetic":false,"types":["asset_transfer_private_rs::types::price_agreement::PriceAgreement"]}]; 3 | implementors["asset_transfer_rs"] = [{"text":"impl DataType for Asset","synthetic":false,"types":["asset_transfer_rs::types::asset::Asset"]}]; 4 | implementors["basic_contract_rs"] = [{"text":"impl DataType for MyAsset","synthetic":false,"types":["basic_contract_rs::types::myasset::MyAsset"]}]; 5 | if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() -------------------------------------------------------------------------------- /docs/apidoc/implementors/prost/message/trait.Message.js: -------------------------------------------------------------------------------- 1 | (function() {var implementors = {}; 2 | implementors["fabric_contract"] = [{"text":"impl Message for Arguments","synthetic":false,"types":["fabric_contract::runtime::runtime::items::Arguments"]},{"text":"impl Message for Return","synthetic":false,"types":["fabric_contract::runtime::runtime::items::Return"]}]; 3 | if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() -------------------------------------------------------------------------------- /docs/apidoc/implementors/serde/de/trait.Deserialize.js: -------------------------------------------------------------------------------- 1 | (function() {var implementors = {}; 2 | implementors["asset_transfer_private_rs"] = [{"text":"impl<'de> Deserialize<'de> for Asset","synthetic":false,"types":["asset_transfer_private_rs::types::asset::Asset"]},{"text":"impl<'de> Deserialize<'de> for AssetPrivate","synthetic":false,"types":["asset_transfer_private_rs::types::asset_private::AssetPrivate"]},{"text":"impl<'de> Deserialize<'de> for PriceAgreement","synthetic":false,"types":["asset_transfer_private_rs::types::price_agreement::PriceAgreement"]}]; 3 | implementors["asset_transfer_rs"] = [{"text":"impl<'de> Deserialize<'de> for Asset","synthetic":false,"types":["asset_transfer_rs::types::asset::Asset"]}]; 4 | implementors["basic_contract_rs"] = [{"text":"impl<'de> Deserialize<'de> for MyAsset","synthetic":false,"types":["basic_contract_rs::types::myasset::MyAsset"]}]; 5 | if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() -------------------------------------------------------------------------------- /docs/apidoc/implementors/serde/ser/trait.Serialize.js: -------------------------------------------------------------------------------- 1 | (function() {var implementors = {}; 2 | implementors["asset_transfer_private_rs"] = [{"text":"impl Serialize for Asset","synthetic":false,"types":["asset_transfer_private_rs::types::asset::Asset"]},{"text":"impl Serialize for AssetPrivate","synthetic":false,"types":["asset_transfer_private_rs::types::asset_private::AssetPrivate"]},{"text":"impl Serialize for PriceAgreement","synthetic":false,"types":["asset_transfer_private_rs::types::price_agreement::PriceAgreement"]}]; 3 | implementors["asset_transfer_rs"] = [{"text":"impl Serialize for Asset","synthetic":false,"types":["asset_transfer_rs::types::asset::Asset"]}]; 4 | implementors["basic_contract_rs"] = [{"text":"impl Serialize for MyAsset","synthetic":false,"types":["basic_contract_rs::types::myasset::MyAsset"]}]; 5 | if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() -------------------------------------------------------------------------------- /docs/apidoc/implementors/std/error/trait.Error.js: -------------------------------------------------------------------------------- 1 | (function() {var implementors = {}; 2 | implementors["fabric_contract"] = [{"text":"impl Error for ContractError","synthetic":false,"types":["fabric_contract::error::ContractError"]},{"text":"impl Error for LedgerError","synthetic":false,"types":["fabric_contract::error::LedgerError"]}]; 3 | if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})() -------------------------------------------------------------------------------- /docs/apidoc/normalize.css: -------------------------------------------------------------------------------- 1 | /*! normalize.css v3.0.0 | MIT License | git.io/normalize */ 2 | html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}[hidden],template{display:none}a{background:transparent}a:active,a:hover{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:bold}dfn{font-style:italic}h1{font-size:2em;margin:.67em 0}mark{background:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:1em 40px}hr{-moz-box-sizing:content-box;box-sizing:content-box;height:0}pre{overflow:auto}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}button,input,optgroup,select,textarea{color:inherit;font:inherit;margin:0}button{overflow:visible}button,select{text-transform:none}button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer}button[disabled],html input[disabled]{cursor:default}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}input{line-height:normal}input[type="checkbox"],input[type="radio"]{box-sizing:border-box;padding:0}input[type="number"]::-webkit-inner-spin-button,input[type="number"]::-webkit-outer-spin-button{height:auto}input[type="search"]{-webkit-appearance:textfield;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none}fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}legend{border:0;padding:0}textarea{overflow:auto}optgroup{font-weight:bold}table{border-collapse:collapse;border-spacing:0}td,th{padding:0} -------------------------------------------------------------------------------- /docs/apidoc/noscript.css: -------------------------------------------------------------------------------- 1 | #main>h2+div,#main>h2+h3,#main>h3+div{display:block;}.loading-content{display:none;}#main>h2+div,#main>h3+div{display:block;}#main>h2+h3{display:flex;} -------------------------------------------------------------------------------- /docs/apidoc/rust-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledgendary/fabric-contract-api-rust/1b35443a767379f859d6ef65d2e3cf134db2f22a/docs/apidoc/rust-logo.png -------------------------------------------------------------------------------- /docs/apidoc/settings.css: -------------------------------------------------------------------------------- 1 | .setting-line{padding:5px;position:relative;}.setting-line>div{max-width:calc(100% - 74px);display:inline-block;vertical-align:top;font-size:17px;padding-top:2px;}.setting-line>.title{font-size:19px;width:100%;max-width:none;border-bottom:1px solid;}.toggle{position:relative;display:inline-block;width:45px;height:27px;margin-right:20px;}.toggle input{display:none;}.slider{position:absolute;cursor:pointer;top:0;left:0;right:0;bottom:0;background-color:#ccc;-webkit-transition:.3s;transition:.3s;}.slider:before{position:absolute;content:"";height:19px;width:19px;left:4px;bottom:4px;background-color:white;-webkit-transition:.3s;transition:.3s;}input:checked+.slider{background-color:#2196F3;}input:focus+.slider{box-shadow:0 0 1px #2196F3;}input:checked+.slider:before{-webkit-transform:translateX(19px);-ms-transform:translateX(19px);transform:translateX(19px);}.setting-line>.sub-settings{padding-left:42px;width:100%;display:block;} -------------------------------------------------------------------------------- /docs/apidoc/settings.js: -------------------------------------------------------------------------------- 1 | (function(){function changeSetting(settingName,isEnabled){updateLocalStorage('rustdoc-'+settingName,isEnabled)}function getSettingValue(settingName){return getCurrentValue('rustdoc-'+settingName)}function setEvents(){var elems=document.getElementsByClassName("slider");if(!elems||elems.length===0){return}for(var i=0;icontracts.rs.html -- source
1
 2 | 2
 3 | 3
 4 | 4
 5 | 
 6 | 
 7 | mod assettransferprivate;
 8 | 
 9 | pub use crate::contracts::assettransferprivate::AssetTransfer as AssetTransfer;
10 | 
11 |
-------------------------------------------------------------------------------- /docs/apidoc/src/asset_transfer_rs/types.rs.html: -------------------------------------------------------------------------------- 1 | types.rs.html -- source
1
2 | 2
3 | 
4 | mod asset;
5 | pub use asset::Asset as Asset;
6 |
-------------------------------------------------------------------------------- /docs/apidoc/src/basic_contract_rs/contracts.rs.html: -------------------------------------------------------------------------------- 1 | contracts.rs.html -- source
1
 2 | 2
 3 | 3
 4 | 4
 5 | 5
 6 | 6
 7 | 
 8 | /*
 9 |  * SPDX-License-Identifier: Apache-2.0
10 |  */
11 | 
12 | mod assetcontract;
13 | pub use crate::contracts::assetcontract::AssetContract;
14 | 
15 |
-------------------------------------------------------------------------------- /docs/apidoc/src/basic_contract_rs/types.rs.html: -------------------------------------------------------------------------------- 1 | types.rs.html -- source
1
 2 | 2
 3 | 3
 4 | 4
 5 | 5
 6 | 6
 7 | 
 8 | /*
 9 |  * SPDX-License-Identifier: Apache-2.0
10 |  */
11 | 
12 | mod myasset;
13 | pub use myasset::MyAsset;
14 | 
15 |
-------------------------------------------------------------------------------- /docs/apidoc/src/fabric_contract/blockchainapi.rs.html: -------------------------------------------------------------------------------- 1 | blockchainapi.rs.html -- source
1
 2 | 2
 3 | 3
 4 | 4
 5 | 5
 6 | 6
 7 | 
 8 | /*
 9 |  * SPDX-License-Identifier: Apache-2.0
10 |  */
11 | 
12 | pub mod clientidentity;
13 | pub mod transactioncontext;
14 | 
15 |
-------------------------------------------------------------------------------- /docs/apidoc/src/fabric_contract/runtime.rs.html: -------------------------------------------------------------------------------- 1 | runtime.rs.html -- source
1
 2 | 2
 3 | 3
 4 | 4
 5 | 5
 6 | 6
 7 | 
 8 | /*
 9 |  * SPDX-License-Identifier: Apache-2.0
10 |  */
11 | 
12 | pub mod register;
13 | pub mod runtime;
14 |
-------------------------------------------------------------------------------- /docs/apidoc/storage.js: -------------------------------------------------------------------------------- 1 | var resourcesSuffix="";var currentTheme=document.getElementById("themeStyle");var mainTheme=document.getElementById("mainThemeStyle");var savedHref=[];function hasClass(elem,className){return elem&&elem.classList&&elem.classList.contains(className)}function addClass(elem,className){if(!elem||!elem.classList){return}elem.classList.add(className)}function removeClass(elem,className){if(!elem||!elem.classList){return}elem.classList.remove(className)}function onEach(arr,func,reversed){if(arr&&arr.length>0&&func){var length=arr.length;var i;if(reversed!==true){for(i=0;i=0;--i){if(func(arr[i])===true){return true}}}}return false}function onEachLazy(lazyArray,func,reversed){return onEach(Array.prototype.slice.call(lazyArray),func,reversed)}function hasOwnProperty(obj,property){return Object.prototype.hasOwnProperty.call(obj,property)}function usableLocalStorage(){if(typeof Storage==="undefined"){return false}try{return window.localStorage!==null&&window.localStorage!==undefined}catch(err){return false}}function updateLocalStorage(name,value){if(usableLocalStorage()){localStorage[name]=value}else{}}function getCurrentValue(name){if(usableLocalStorage()&&localStorage[name]!==undefined){return localStorage[name]}return null}function switchTheme(styleElem,mainStyleElem,newTheme,saveTheme){var fullBasicCss="rustdoc"+resourcesSuffix+".css";var fullNewTheme=newTheme+resourcesSuffix+".css";var newHref=mainStyleElem.href.replace(fullBasicCss,fullNewTheme);if(styleElem.href===newHref){return}var found=false;if(savedHref.length===0){onEachLazy(document.getElementsByTagName("link"),function(el){savedHref.push(el.href)})}onEach(savedHref,function(el){if(el===newHref){found=true;return true}});if(found===true){styleElem.href=newHref;if(saveTheme===true){updateLocalStorage("rustdoc-theme",newTheme)}}}function getSystemValue(){var property=getComputedStyle(document.documentElement).getPropertyValue('content');return property.replace(/[\"\']/g,"")}switchTheme(currentTheme,mainTheme,getCurrentValue("rustdoc-theme")||getSystemValue()||"light",false) -------------------------------------------------------------------------------- /docs/apidoc/theme.js: -------------------------------------------------------------------------------- 1 | var themes=document.getElementById("theme-choices");var themePicker=document.getElementById("theme-picker");function showThemeButtonState(){themes.style.display="block";themePicker.style.borderBottomRightRadius="0";themePicker.style.borderBottomLeftRadius="0"}function hideThemeButtonState(){themes.style.display="none";themePicker.style.borderBottomRightRadius="3px";themePicker.style.borderBottomLeftRadius="3px"}function switchThemeButtonState(){if(themes.style.display==="block"){hideThemeButtonState()}else{showThemeButtonState()}};function handleThemeButtonsBlur(e){var active=document.activeElement;var related=e.relatedTarget;if(active.id!=="themePicker"&&(!active.parentNode||active.parentNode.id!=="theme-choices")&&(!related||(related.id!=="themePicker"&&(!related.parentNode||related.parentNode.id!=="theme-choices")))){hideThemeButtonState()}}themePicker.onclick=switchThemeButtonState;themePicker.onblur=handleThemeButtonsBlur;["dark","light"].forEach(function(item){var but=document.createElement('button');but.textContent=item;but.onclick=function(el){switchTheme(currentTheme,mainTheme,item,true)};but.onblur=handleThemeButtonsBlur;themes.appendChild(but)}) -------------------------------------------------------------------------------- /docs/guides/MicrofabBuilder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledgendary/fabric-contract-api-rust/1b35443a767379f859d6ef65d2e3cf134db2f22a/docs/guides/MicrofabBuilder.png -------------------------------------------------------------------------------- /docs/guides/fabric-wasm-rust-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledgendary/fabric-contract-api-rust/1b35443a767379f859d6ef65d2e3cf134db2f22a/docs/guides/fabric-wasm-rust-1.png -------------------------------------------------------------------------------- /docs/guides/rust-and-wasm.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Rust and Wasm 3 | layout: page 4 | category: guides 5 | --- 6 | 7 | Some thoughts from our journey into Rust and Wasm that may help if you're learning either of these technologies. (Note personal views here) 8 | 9 | ## Learning Rust 10 | 11 | It's fair to say that Rust itself is an amazing language; however it is also fair to say that Rust's learning curve is, well, steep. But the views from top.... wow! 12 | For a quick script to parse some trace data then it's not your preferred tool. However after (between the two of us who've worked on this) 40+ years programming experience our _personal view_ this is the language we'd want to use for rock-solid enterprise production software. 13 | 14 | ## Learning Wasm 15 | 16 | WebAssembly is in idea that in some ways have been around and tried before; the concept is still as valuable even more so today. And the direction Wasm is taking is very exciting. 17 | 18 | ### Resources 19 | 20 | For things rusty 21 | 22 | - [Main Rust Website](https://www.rust-lang.org/learn) - Start here it's a solid introduction 23 | - For information on [Rust and Wasm ](https://rustwasm.github.io/docs/book/). 24 | - Please note that section on [what crates may and may not work](https://rustwasm.github.io/docs/book/reference/which-crates-work-with-wasm.html) with Wasm for any dependencies that you use) 25 | - [A gentle introduction to Rust](https://stevedonovan.github.io/rust-gentle-intro/) 26 | - [Easy Rust](https://github.com/Dhghomon/easy_rust) 27 | 28 | Would also suggest that you look at [Rust In Action](https://www.manning.com/books/rust-in-action) by [Tim McNamara](https://twitter.com/timClicks) 29 | 30 | For Wasm 31 | 32 | - [A cartoon introduction](https://hacks.mozilla.org/2017/02/a-cartoon-intro-to-webassembly/) 33 | - [Awesome list](https://github.com/mbasso/awesome-wasm) -------------------------------------------------------------------------------- /docs/guides/transaction-functions.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Transaction Functions 3 | layout: page 4 | category: guides 5 | --- 6 | 7 | This guide explains how individual functions can be marked as transaction functions. This means that they are invokeable from the Client SDKs. 8 | 9 | ## Marking as a transaction function 10 | 11 | Use the macro `#[Transaction]` on the functions, the functions must be public and not associated functions. Marking any function this was does not prohibit it being called as a 'normal' function, any ledger work down will be under the same Fabric Transaction. 12 | 13 | **Arguments and Return** 14 | 15 | These should be either the primitive types, (number and string) or a type that implements the DataType trait. For example: 16 | 17 | ```rust 18 | pub fn change_public_description( 19 | &self, 20 | asset_id: String, 21 | public_desc: String, 22 | ) 23 | ``` 24 | 25 | 26 | The return should be a Result, passing a ContractError and any other return type needed. 27 | `Result<(), ContractError>` or `Result` 28 | 29 | **Submit or Evaluate** 30 | To indicate if this should a tranasction that is submited for ordering, or just evaluated (query type) . Use the transaction macro as follows. `#[Transaction(submit)]` or `#[Transaction(evaluate)]` 31 | Submit is the default if it's not specified. 32 | 33 | **Transient Data** 34 | 35 | Transient data is passed to the transaction function as 36 | 37 | ``` 38 | #[Transaction(submit, transient = "price")] 39 | pub fn agree_to_sell(&self, asset_id: String, price: u32) -> Result<(), ContractError> { .. } 40 | ``` -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: home 3 | title: Rust Smart Contract API 4 | --- 5 | 6 | This **Technology Preview** provides an updated Contract and Ledger API in Rust. It is targetted to be compiled to WebAssembly and run in the `fabric-chaincode-wasm` engine. 7 | 8 | The API presented here is the evolution of the APIs available in the other SDKs to support developing smart contracts (chaincode). There are three other smart contract SDKs available for Go, Node.js, and Java SDK: 9 | 10 | * [Go SDK documentation](https://godoc.org/github.com/hyperledger/fabric/core/chaincode/shim) 11 | * [Node.js SDK documentation](https://hyperledger.github.io/fabric-chaincode-node/) 12 | * [Java documentation](https://hyperledger.github.io/fabric-chaincode-java/) 13 | 14 | ## Getting setup 15 | 16 | You'll need some tools installed, some you might already have: 17 | 18 | - [docker](https://docs.docker.com/get-docker/) & [docker-compose](https://docs.docker.com/compose/install/) 19 | - rust and the Wasm toolchain 20 | - Stable Rust is sufficient, nightly is not required. Instructions at the [rust-lang.org](https://www.rust-lang.org/tools/install) 21 | - To build a Wasm binary you will need to have the wasm target. Note that wasm-pack is not required here as there is no JavaScript host. 22 | - `rustup target add wasm32-unknown-unknown` 23 | - [git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) 24 | - [just](https://github.com/casey/just) for use as a script running tool 25 | 26 | [VSCode](https://code.visualstudio.com/download) is our preferred editor, with the [Rust Extension](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust) using the [Rust Analyser](https://github.com/rust-analyzer/rust-analyzer). You may, of course, have your own favourite editor. 27 | 28 | This also has been developed on Linux; but development should be possible on other platforms. 29 | 30 | ## Guides 31 | 32 | Essential reading, each guide around a single topic. 33 | 34 | - [API Documentation](./apidoc/fabric_contract/index.html) 35 | {% for doc in site.pages %} {% if doc.category =='guides' %} 36 | - [{{ doc.title }}]({{site.baseurl}}{{ doc.url }}) 37 | {% endif %} 38 | {% endfor %} 39 | 40 | ## Samples 41 | 42 | Two examples are available in this repo. 43 | 44 | - [Basic Asset Transfer](https://github.com/hyperledgendary/fabric-contract-api-rust/tree/master/basic_contract_rs) 45 | - [Secure Asset Transfer](https://github.com/hyperledgendary/fabric-contract-api-rust/tree/master/asset_transfer_rs) 46 | 47 | Note that 'Secure Asset Transfer' is a work in progress and will not yet compile 48 | -------------------------------------------------------------------------------- /fabric_contract/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "fabric_contract" 3 | description = "Hyperledger Fabric Contract API in Rust" 4 | version = "0.1.3" 5 | authors = ["Hyperledger Fabric Developers"] 6 | edition = "2018" 7 | repository = "https://github.com/hyperledgendary/fabric-contract-api-rust" 8 | license = "Apache-2.0" 9 | documentation = "https://hyperledgendary.github.io/fabric-contract-api-rust/" 10 | readme = "README.md" 11 | 12 | [lib] 13 | #crate-type = ["cdylib"] 14 | 15 | [profile.release] 16 | # Optimize for small code size 17 | opt-level = "s" 18 | 19 | [dependencies] 20 | wapc-guest = "0.3.1" 21 | #fabric_contract_macros = { version = "0.1.3" } 22 | fabric_contract_macros = { path = "../fabric_contract_macros" } 23 | fabric_ledger_protos = "0.7.0" 24 | log = "0.4.8" 25 | protobuf = "2.14.0" 26 | # protobuf handling 27 | prost = "0.6.1" 28 | lazy_static = "1.4.0" 29 | 30 | [dev-dependencies] 31 | wasm-bindgen-test = "0.2" 32 | mockall = "0.7.2" 33 | claim = "0.3" 34 | 35 | [build-dependencies] 36 | prost-build = { version = "0.6.1" } 37 | -------------------------------------------------------------------------------- /fabric_contract/README.md: -------------------------------------------------------------------------------- 1 | # fabric_contract_macros 2 | 3 | This is the the library crate for... 4 | 5 | # Fabric Rust Contract-API 6 | 7 | "The Fabric Contract API in rust, with Wasm as the compilation target." 8 | 9 | A SmartContract is single crate, containing one or more contract sructs, compiled to a Wasm library. In this repo the `basic_contract_rs` is an example. This is a simple asset based contract based on the standard vs code extension examples. 10 | 11 | [End-to-End Getting Started Guide](https://hyperledgendary.github.io/fabric-contract-api-rust/guides/getting-started.html) 12 | 13 | [Check the API Documentation for fabric_contract](https://hyperledgendary.github.io/fabric-contract-api-rust/apidoc/fabric_contract/index.html) 14 | 15 | [Full Documentation](https://hyperledgendary.github.io/fabric-contract-api-rust/) 16 | -------------------------------------------------------------------------------- /fabric_contract/src/blockchainapi.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | pub mod clientidentity; 6 | pub mod transactioncontext; 7 | -------------------------------------------------------------------------------- /fabric_contract/src/blockchainapi/clientidentity.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | #![allow(dead_code)] 5 | /// Represents the identity that is requesting this transaction 6 | /// 7 | pub struct ClientIdentity {} 8 | 9 | impl ClientIdentity { 10 | fn new() -> ClientIdentity { 11 | ClientIdentity {} 12 | } 13 | 14 | /// The String id associated with this identiy 15 | pub fn get_id(&self) -> String { 16 | todo!("get_id"); 17 | } 18 | 19 | /// The MSP Identifier of this identity 20 | /// 21 | pub fn get_mspid(&self) -> String { 22 | todo!("get_mspid") 23 | } 24 | 25 | /// Returns the value of the client's attribute named `attrName`. 26 | /// 27 | pub fn get_attribute(&self, attr_name: String) -> Option { 28 | todo!("get_attributed") 29 | } 30 | 31 | // GetX509Certificate returns the X509 certificate associated with the client, 32 | // or nil if it was not identified by an X509 certificate. 33 | // GetX509Certificate() (*x509.Certificate, error) 34 | } 35 | -------------------------------------------------------------------------------- /fabric_contract/src/blockchainapi/transactioncontext.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | use crate::blockchainapi::clientidentity::ClientIdentity; 6 | use fabric_ledger_protos::common_messages::TransactionContext as TxCtx; 7 | 8 | /// Represents a transaction 9 | /// 10 | /// This can be used to obtain information about the current transaction 11 | /// that trigger a contract function to be executed. 12 | /// 13 | /// Timestamp and MSPID are two important fields 14 | /// 15 | /// # Example 16 | /// 17 | /// ``` 18 | /// pub fn myTransactionFn(){ 19 | /// let tx = fabric_contract::blockchain::TransactionContext::current_transaction(); 20 | /// 21 | /// let id = tx.get_id(); 22 | /// let timestamp = tx.get_timestamp(); 23 | /// let mspid = tx.get_peer_mspid(); 24 | /// } 25 | /// ``` 26 | /// 27 | #[derive(Default,Clone)] 28 | pub struct TransactionContext { 29 | tx_id: std::string::String, 30 | channel_id: std::string::String, 31 | // timestamp: String, 32 | 33 | } 34 | 35 | impl TransactionContext { 36 | pub fn new(ctx: &TxCtx) -> TransactionContext { 37 | TransactionContext { 38 | channel_id: ctx.channel_id.clone(), 39 | tx_id: ctx.transaction_id.clone(), 40 | // timestamp: 41 | } 42 | } 43 | 44 | /// Gets the transaction id 45 | /// 46 | /// Full transaction id 47 | pub fn get_id(&self) -> String { 48 | self.tx_id.clone() 49 | } 50 | 51 | /// Gets the timestamp of this transaction 52 | /// 53 | /// Format is ISO - need better type here 54 | pub fn get_timestamp(&self) -> String { 55 | todo!("get_id") 56 | } 57 | 58 | pub fn get_channelid(&self) -> std::string::String { 59 | self.channel_id.clone() 60 | } 61 | 62 | /// The MSP Identifier of the originating organization 63 | /// 64 | pub fn get_peer_mspid(&self) -> String { 65 | todo!("get_id") 66 | } 67 | 68 | /// Get 69 | pub fn get_submitting_identity(&self) -> Result { 70 | todo!("get_submitting_identity"); 71 | } 72 | 73 | /// Get the current transaction 74 | pub fn current_transaction() -> TransactionContext { 75 | todo!("get_id") 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /fabric_contract/src/contractapi.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | pub mod contract; 6 | pub mod contractdefn; 7 | pub mod contractmanager; 8 | pub mod transaction; 9 | -------------------------------------------------------------------------------- /fabric_contract/src/contractapi/contract.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | use crate::{ 5 | blockchain::TransactionContext, 6 | contract::ContractError, 7 | dataapi::{TypeSchema, WireBuffer}, 8 | prelude::TransactionFn, 9 | }; 10 | 11 | // trait that is implemented by macro for each struct that does the final step in the routing to 12 | // the transaction functions 13 | pub trait Routing { 14 | fn route3( 15 | &self, 16 | tx_fn: String, 17 | args: Vec, 18 | return_wb: TypeSchema, 19 | ) -> Result; 20 | } 21 | 22 | pub trait Metadata { 23 | /// Gets the detail of the functions, which is vector of strings 24 | fn get_fn_metadata(&self) -> Vec; 25 | } 26 | 27 | /// Trait that is implemented for each contract 28 | /// Default implementations here 29 | pub trait Contract: Routing + Metadata { 30 | fn name(&self) -> String; 31 | // fn before_transaction(&self, ctx: Context); 32 | // fn after_transaction(&self, _ctx: Context) { 33 | // println!("Default After Tranasction"); 34 | // } 35 | 36 | /// Verify the client MSPID and the Peers MSPID are the same 37 | fn get_verified_client_org(&self) -> Result { 38 | let tx = TransactionContext::current_transaction(); 39 | 40 | let peers_msp = tx.get_peer_mspid(); 41 | let client_msp = tx.get_submitting_identity()?.get_mspid(); 42 | if peers_msp != client_msp { 43 | Err(ContractError::from( 44 | "Mismatch of Organization names".to_string(), 45 | )) 46 | } else { 47 | Ok(client_msp) 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /fabric_contract/src/dataapi.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | pub mod typeschema; 6 | pub use typeschema::TypeSchema; 7 | 8 | pub mod wirebuffer; 9 | pub use wirebuffer::WireBuffer; 10 | pub use wirebuffer::WireBufferFromReturnType; 11 | 12 | pub mod serializer; 13 | pub use serializer::Converter; 14 | -------------------------------------------------------------------------------- /fabric_contract/src/dataapi/JSONConverter.rs: -------------------------------------------------------------------------------- 1 | #[derive(Debug, Clone, Copy)] 2 | pub struct JSONConverter { 3 | 4 | } 5 | 6 | impl Converter for JSONConverter { 7 | 8 | // straight conversion 9 | fn into_string(&self, buffer: &Vec, ts: &TypeSchema) -> String { 10 | match ts.contract_type { 11 | CTString => { String::from_utf8(buffer.to_vec()).unwrap() } 12 | _ => { "".to_string() } 13 | } 14 | } 15 | 16 | } -------------------------------------------------------------------------------- /fabric_contract/src/dataapi/serializer.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | use super::typeschema::ContractType::*; 5 | use super::TypeSchema; 6 | pub trait Converter { 7 | fn into_string(&self, buffer: &[u8], ts: &TypeSchema) -> String; 8 | } 9 | 10 | #[derive(Debug, Clone, Copy)] 11 | pub struct JSONConverter {} 12 | 13 | impl Converter for JSONConverter { 14 | // straight conversion 15 | fn into_string(&self, buffer: &[u8], ts: &TypeSchema) -> String { 16 | match ts.contract_type { 17 | CTString => String::from_utf8(buffer.to_vec()).unwrap(), 18 | _ => "".to_string(), 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /fabric_contract/src/dataapi/typeschema.rs: -------------------------------------------------------------------------------- 1 | use std::fmt; 2 | #[derive(Debug, Copy, Clone)] 3 | pub enum ContractType { 4 | Integer, 5 | Long, 6 | Float, 7 | Double, 8 | CTString, 9 | Byte, 10 | Boolean, 11 | Date, 12 | DateTime, 13 | } 14 | 15 | impl fmt::Display for ContractType { 16 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 17 | write!(f, "{:?}", self) 18 | // or, alternatively: 19 | // fmt::Debug::fmt(self, f) 20 | } 21 | } 22 | 23 | impl std::str::FromStr for ContractType { 24 | type Err = (); 25 | 26 | fn from_str(s: &str) -> Result { 27 | match s { 28 | "Integer" | "i32" | "u32" => Ok(ContractType::Integer), 29 | "Long" | "i64" | "u64" => Ok(ContractType::Long), 30 | "Float" | "f32" => Ok(ContractType::Float), 31 | "Double" | "d32" => Ok(ContractType::Double), 32 | "String" => Ok(ContractType::CTString), 33 | "Byte" | "i8" | "u8" => Ok(ContractType::Byte), 34 | "Boolean" | "bool" => Ok(ContractType::Boolean), 35 | "Date" => Ok(ContractType::Date), 36 | "DateTime" => Ok(ContractType::DateTime), 37 | _ => Err(()), 38 | } 39 | } 40 | } 41 | 42 | #[derive(Debug, Copy, Clone)] 43 | pub enum Format { 44 | Other, 45 | } 46 | 47 | #[derive(Debug, Copy, Clone)] 48 | pub struct TypeSchema { 49 | pub contract_type: ContractType, 50 | pub format: Option, 51 | } 52 | 53 | impl Default for TypeSchema { 54 | fn default() -> Self { 55 | Self { 56 | contract_type: ContractType::CTString, 57 | format: Option::None, 58 | } 59 | } 60 | } 61 | 62 | impl std::fmt::Display for TypeSchema { 63 | fn fmt(&self, f: &mut std::fmt::Formatter) -> fmt::Result { 64 | write!(f, "{:?}", self.contract_type) 65 | } 66 | } 67 | 68 | impl TypeSchema {} 69 | -------------------------------------------------------------------------------- /fabric_contract/src/error.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | use std::error; 6 | use std::fmt; 7 | 8 | /// Contract Error is what the contract will return to indicate an error 9 | /// Typically this would be for contract developers to use to mark that a failure 10 | /// has occured, and give information about what that means in the context 11 | /// of their implementation 12 | #[derive(Debug)] 13 | pub struct ContractError { 14 | msg: String, 15 | ledger_error: Option, 16 | } 17 | 18 | impl std::convert::From for ContractError { 19 | fn from(msg: String) -> Self { 20 | Self { 21 | msg, 22 | ledger_error: Option::None, 23 | } 24 | } 25 | } 26 | 27 | impl std::convert::From<(String,LedgerError)> for ContractError { 28 | fn from((msg,err): (String, LedgerError)) -> Self { 29 | Self { 30 | msg, 31 | ledger_error: Some(err), 32 | } 33 | } 34 | } 35 | 36 | impl std::convert::From for ContractError { 37 | fn from(ledger_error: LedgerError) -> Self { 38 | Self { 39 | msg: "Error caused by LedgerError".to_string(), 40 | ledger_error: Some(ledger_error), 41 | } 42 | } 43 | } 44 | 45 | impl fmt::Display for ContractError { 46 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 47 | match &self.ledger_error { 48 | Some(le) => write!(f, "{} caused by {}", self.msg, le), 49 | None => write!(f, "{}", self.msg), 50 | } 51 | } 52 | } 53 | 54 | impl error::Error for ContractError { 55 | fn source(&self) -> Option<&(dyn error::Error + 'static)> { 56 | Some(self) 57 | } 58 | } 59 | 60 | /// Ledger Error is returned by the API calls made against the ledger 61 | /// api, eg, if a state can be found 62 | #[derive(Debug)] 63 | pub struct LedgerError { 64 | msg: String, 65 | } 66 | 67 | impl error::Error for LedgerError { 68 | fn source(&self) -> Option<&(dyn error::Error + 'static)> { 69 | Some(self) 70 | } 71 | } 72 | 73 | impl std::convert::From for LedgerError { 74 | fn from(msg: String) -> Self { 75 | Self { msg } 76 | } 77 | } 78 | 79 | impl fmt::Display for LedgerError { 80 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 81 | write!(f, "{}", self.msg) 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /fabric_contract/src/ledgerapi.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | pub mod collection; 6 | pub mod datatype; 7 | pub mod ledger; 8 | pub mod state; 9 | pub mod statequerylist; 10 | pub mod endorsement; 11 | 12 | pub use collection::CollectionName; 13 | pub use collection::*; 14 | pub use datatype::DataType; 15 | pub use ledger::Ledger; 16 | pub use state::*; 17 | pub use statequerylist::StateQueryList; 18 | pub use endorsement::*; 19 | -------------------------------------------------------------------------------- /fabric_contract/src/ledgerapi/datatype.rs: -------------------------------------------------------------------------------- 1 | #![allow(unused_variables)] 2 | 3 | use crate::ledgerapi::state::State; 4 | 5 | pub trait DataType: Default { 6 | /// Converts into a state that can be handled and put into 7 | /// the ledger and private collections 8 | fn to_state(&self) -> State; 9 | 10 | /// 11 | fn get_key(&self) -> String; 12 | 13 | /// 14 | fn build_from_state(state: State) -> Self; 15 | 16 | /// 17 | fn form_key(k: &String) -> String; 18 | } 19 | -------------------------------------------------------------------------------- /fabric_contract/src/ledgerapi/endorsement.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | /// The ROLE definition 6 | #[derive(Debug, Clone)] 7 | pub enum ROLE { 8 | MEMBER, 9 | PEER, 10 | ADMIN, 11 | CLIENT, 12 | } 13 | 14 | /// The Expressions - either AND, OR, OUTOF or the actual Principal 15 | #[derive(Debug, Clone)] 16 | pub enum Expression { 17 | AND(Vec), 18 | OR(Vec), 19 | OUTOF(Vec, usize), 20 | Principal(String, ROLE), 21 | } 22 | 23 | /// Struct to represent the Overal Endorsement 24 | #[derive(Debug)] 25 | pub struct StateBasedEndorsement { 26 | pub root: Expression, 27 | } 28 | 29 | impl StateBasedEndorsement { 30 | pub fn build(expr: Expression) -> Self { 31 | StateBasedEndorsement { root: expr } 32 | } 33 | } -------------------------------------------------------------------------------- /fabric_contract/src/ledgerapi/ledger.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | use crate::ledgerapi::collection::*; 5 | 6 | /// 7 | /// Ledger representing high level concept of the Fabric Blockchain network 8 | /// 9 | /// Provides the access points for 10 | /// - getting access to data in both world state and peer's private collections 11 | /// - invoking chaincode on this and other networks 12 | /// 13 | /// When a transaction is invoked, it takes place under a 'transactional context' 14 | /// This context can be queried to provide the current transaction id, and information 15 | /// about the identity requesting the transaction. 16 | /// 17 | /// All operations need to be done under this transactional context, therefore 18 | /// the context needs to be passed to obtain the Ledger instance 19 | /// 20 | /// # Example 21 | /// 22 | /// ```ignore 23 | /// use fabric_contract::contract::*; 24 | /// 25 | /// 26 | /// pub fn asset_exists(my_assset_id: String) -> Result { 27 | /// let ledger = Ledger::access_ledger(); 28 | /// 29 | /// let world = ledger.get_collection(CollectionName::World); 30 | /// 31 | /// Ok(world.state_exists(&my_assset_id)) 32 | /// 33 | /// } 34 | /// ``` 35 | pub struct Ledger {} 36 | 37 | impl Ledger { 38 | 39 | /// Get the Ledger based on the current transactional context 40 | /// 41 | /// The Tranasctional Context is available via the [Transaction API](../../transaction/struct.Transaction.html) 42 | /// 43 | pub fn access_ledger() -> Ledger { 44 | Ledger::new() 45 | } 46 | 47 | // Private new function 48 | fn new() -> Ledger { 49 | Ledger {} 50 | } 51 | 52 | /// Return the collection based on the name 53 | /// 54 | /// The collection provides access to the put & get Fabric 55 | /// semantics of the underlying world state, or private data 56 | /// that is specified by the Collection name. 57 | /// 58 | /// # Example 59 | /// ```ignore 60 | /// use fabric_contract::contract::*; 61 | /// let ledger = Ledger::access_ledger(); 62 | /// 63 | /// // get the collectin that is backed by the World State 64 | /// let world = ledger.get_collection(CollectionName::World); 65 | /// 66 | /// // get the collection that is backed by the Organization's Implicity Private Data Collection 67 | /// let orgs_collection = ledger.get_collection(CollectionName::Organization(String::from("org1"))); 68 | /// 69 | /// // get the collection that is backed by the named Private Data Collection 70 | /// let private_collection = ledger.get_collection(CollectionName::Private(String::from("my_private_details"))); 71 | /// ``` 72 | pub fn get_collection(&self, name: CollectionName) -> Collection { 73 | Collection::new(name) 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /fabric_contract/src/runtimeapi.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0in 3 | */ 4 | 5 | pub mod wapc; 6 | pub use wapc::*; 7 | pub mod logger; 8 | pub use logger::*; 9 | pub mod ledgerservice; 10 | pub use ledgerservice::*; 11 | -------------------------------------------------------------------------------- /fabric_contract/src/runtimeapi/logger.rs: -------------------------------------------------------------------------------- 1 | use crate::runtimeapi::wapc::log; 2 | use log::{error, Level, LevelFilter, Metadata, Record}; 3 | use std::panic; 4 | 5 | /// Logger used for runtime purposes 6 | /// 7 | /// Default to the Info level. 8 | /// 9 | static LOGGER: RuntimeLogger = RuntimeLogger { 10 | level: Level::Trace, 11 | }; 12 | 13 | struct RuntimeLogger { 14 | level: Level, 15 | } 16 | 17 | /// Use the log crate for internal logging, and contract logging 18 | /// 19 | /// following the example at https://docs.rs/log/0.4.8/log/fn.set_logger.html 20 | impl log::Log for RuntimeLogger { 21 | fn enabled(&self, metadata: &Metadata) -> bool { 22 | metadata.level() <= self.level 23 | } 24 | 25 | fn log(&self, record: &Record) { 26 | if self.enabled(record.metadata()) { 27 | log(&format!("{} - {}", record.level(), record.args())[..]); 28 | } 29 | } 30 | 31 | fn flush(&self) {} 32 | } 33 | 34 | /// Called from the register contract macro. 35 | /// 36 | /// Initalize the settings of the logger etc. 37 | pub fn init_logger() { 38 | log::set_logger(&LOGGER).unwrap(); 39 | log::set_max_level(LevelFilter::Trace); 40 | 41 | // configure the panic hook, otherwise any panics 42 | // when running in Wasm will be lost 43 | panic::set_hook(Box::new(hook)); 44 | } 45 | 46 | /// Hook function to capture the panic and route it 47 | /// to the logger 48 | pub fn hook(info: &panic::PanicInfo) { 49 | let msg = info.to_string(); 50 | 51 | // Finally, log the panic via waPC 52 | error!("[Panic]{}[/Panic]", msg); 53 | } 54 | -------------------------------------------------------------------------------- /fabric_contract/src/transaction.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * SPDX-License-Identifier: Apache-2.0 3 | */ 4 | 5 | //! All the ContractApi modules 6 | pub mod transaction; -------------------------------------------------------------------------------- /fabric_contract_macros/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "fabric_contract_macros" 3 | description = "Hyperledger Fabric Contract API in Rust" 4 | version = "0.1.3" 5 | edition = "2018" 6 | autotests = false 7 | authors = ["Hyperledger Fabric Developers"] 8 | repository = "https://github.com/hyperledgendary/fabric-contract-api-rust" 9 | license = "Apache-2.0" 10 | documentation = "https://hyperledgendary.github.io/fabric-contract-api-rust/" 11 | readme = "README.md" 12 | 13 | [lib] 14 | proc-macro = true 15 | 16 | [dependencies] 17 | syn = { version = "1.0.27", features = ["extra-traits","full"] } 18 | quote = "1.0.6" 19 | proc-macro2 = "1.0.17" 20 | -------------------------------------------------------------------------------- /fabric_contract_macros/README.md: -------------------------------------------------------------------------------- 1 | # fabric_contract_macros 2 | 3 | This is the the macros crate for... 4 | 5 | # Fabric Rust Contract-API 6 | 7 | "The Fabric Contract API in rust, with Wasm as the compilation target." 8 | 9 | A SmartContract is single crate, containing one or more contract sructs, compiled to a Wasm library. In this repo the `basic_contract_rs` is an example. This is a simple asset based contract based on the standard vs code extension examples. 10 | 11 | [End-to-End Getting Started Guide](https://hyperledgendary.github.io/fabric-contract-api-rust/guides/getting-started.html) 12 | 13 | [Check the API Documentation for fabric_contract](https://hyperledgendary.github.io/fabric-contract-api-rust/apidoc/fabric_contract/index.html) 14 | 15 | [Full Documentation](https://hyperledgendary.github.io/fabric-contract-api-rust/) 16 | -------------------------------------------------------------------------------- /justfile: -------------------------------------------------------------------------------- 1 | # Run using just (make deriative written in Rust) 2 | # 3 | # https://github.com/casey/just 4 | # 5 | 6 | wasm: 7 | cargo build --target wasm32-unknown-unknown 8 | 9 | amd64: 10 | cargo build 11 | 12 | docs: 13 | cargo doc --no-deps --open 14 | cp -r ./target/doc/* ./docs/apidoc/ 15 | 16 | # use expand with the expand crate when debugging macros 17 | expand: 18 | cargo expand --package basic_contract_rs 19 | 20 | clippy: 21 | cargo clippy --all-targets --all-features 22 | 23 | fmt: 24 | cargo fmt --all 25 | 26 | clean: 27 | cargo clean 28 | 29 | all: clean wasm fmt clippy docs 30 | -------------------------------------------------------------------------------- /tests/assets/chaincode.env: -------------------------------------------------------------------------------- 1 | # CHAINCODE_SERVER_ADDRESS must be set to the host and port where the peer can 2 | # connect to the chaincode server 3 | CHAINCODE_SERVER_ADDRESS=wasmcc.example.com:9999 4 | 5 | # CHAINCODE_ID must be set to the Package ID that is assigned to the chaincode 6 | # on install. The `peer lifecycle chaincode queryinstalled` command can be 7 | # used to get the ID after install if required 8 | CHAINCODE_ID=wasmftw:eeae07c6e9455f329e28f9a0eed977ae3549be68e68247018f71dc5a5f511c0d 9 | 10 | # CHAINCODE_WASM_FILE must be set to the fully qualified pathname of the Wasm 11 | # chaincode 12 | CHAINCODE_WASM_FILE=/local/basic_contract_rs.wasm 13 | -------------------------------------------------------------------------------- /tests/assets/wasmftw.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyperledgendary/fabric-contract-api-rust/1b35443a767379f859d6ef65d2e3cf134db2f22a/tests/assets/wasmftw.tgz --------------------------------------------------------------------------------