├── .gitattributes
├── .github
└── workflows
│ └── main.yml
├── .gitignore
├── BUG_BOUNTY.md
├── CONTRIBUTING.md
├── INTERFACE.md
├── LICENCE
├── README.md
├── SECURITY.md
├── assets
├── cover-sub.png
├── cover.png
├── ethereum.png
├── logo-bitski.svg
├── logo-metamask.svg
└── wanchain.png
├── common
├── config
│ └── rush
│ │ ├── .npmrc
│ │ ├── command-line.json
│ │ ├── common-versions.json
│ │ ├── npm-shrinkwrap.json
│ │ └── version-policies.json
├── conventions-v1
│ ├── token-mock.json
│ └── xcert-mock.json
├── logs
│ └── .keep
└── scripts
│ ├── build-conventions.sh
│ ├── deploy-protocol.sh
│ ├── install-run-rush.js
│ ├── install-run-rushx.js
│ ├── install-run.js
│ ├── package-lock.json
│ └── package.json
├── dist
├── 0xcert-cert.min.js
├── 0xcert-ethereum-asset-ledger.min.js
├── 0xcert-ethereum-asset-ledger.min.js.LICENSE.txt
├── 0xcert-ethereum-gateway.min.js
├── 0xcert-ethereum-gateway.min.js.LICENSE.txt
├── 0xcert-ethereum-http-provider.min.js
├── 0xcert-ethereum-http-provider.min.js.LICENSE.txt
├── 0xcert-ethereum-metamask-provider.min.js
├── 0xcert-ethereum-metamask-provider.min.js.LICENSE.txt
├── 0xcert-ethereum-value-ledger.min.js
├── 0xcert-ethereum-value-ledger.min.js.LICENSE.txt
├── 0xcert-ethereum.min.js
├── 0xcert-ethereum.min.js.LICENSE.txt
├── 0xcert-wanchain-asset-ledger.min.js
├── 0xcert-wanchain-asset-ledger.min.js.LICENSE.txt
├── 0xcert-wanchain-gateway.min.js
├── 0xcert-wanchain-gateway.min.js.LICENSE.txt
├── 0xcert-wanchain-http-provider.min.js
├── 0xcert-wanchain-http-provider.min.js.LICENSE.txt
├── 0xcert-wanchain-value-ledger.min.js
├── 0xcert-wanchain-value-ledger.min.js.LICENSE.txt
├── 0xcert-wanchain.min.js
└── 0xcert-wanchain.min.js.LICENSE.txt
├── packages
├── 0xcert-cert
│ ├── .eslintrc.js
│ ├── CHANGELOG.json
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── nodemon.json
│ ├── package.json
│ ├── src
│ │ ├── core
│ │ │ ├── cert.ts
│ │ │ └── prop.ts
│ │ ├── index.ts
│ │ ├── tests
│ │ │ ├── core
│ │ │ │ ├── cert
│ │ │ │ │ ├── calculate-instance-method.test.ts
│ │ │ │ │ ├── disclose-instance-method.test.ts
│ │ │ │ │ ├── expose-instance-method.test.ts
│ │ │ │ │ ├── identify-instance-method.test.ts
│ │ │ │ │ ├── imprint-instance-method.test.ts
│ │ │ │ │ └── notarize-instance-method.test.ts
│ │ │ │ └── helpers
│ │ │ │ │ └── schemas.ts
│ │ │ ├── index.test.ts
│ │ │ └── utils
│ │ │ │ └── data
│ │ │ │ ├── read-path-method.test.ts
│ │ │ │ ├── step-paths-method.test.ts
│ │ │ │ ├── to-string-method.test.ts
│ │ │ │ └── write-path-method.test.ts
│ │ └── utils
│ │ │ └── data.ts
│ └── tsconfig.json
├── 0xcert-conventions
│ ├── .eslintrc.js
│ ├── CHANGELOG.json
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── nodemon.json
│ ├── package.json
│ ├── src
│ │ ├── assets
│ │ │ ├── 86-base-asset.ts
│ │ │ ├── 87-asset-evidence.ts
│ │ │ ├── 88-crypto-collectible.ts
│ │ │ ├── erc721.ts
│ │ │ └── xcert-schema.ts
│ │ ├── index.ts
│ │ └── tests
│ │ │ ├── 86-base-asset.test.ts
│ │ │ ├── 87-base-asset.test.ts
│ │ │ ├── 88-base-asset.test.ts
│ │ │ ├── erc721.test.ts
│ │ │ ├── index.test.ts
│ │ │ └── xcert-schema.test.ts
│ ├── tsconfig.json
│ └── tslint.json
├── 0xcert-ethereum-asset-ledger
│ ├── .eslintrc.js
│ ├── CHANGELOG.json
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── nodemon.json
│ ├── package.json
│ ├── src
│ │ ├── core
│ │ │ └── ledger.ts
│ │ ├── index.ts
│ │ ├── lib
│ │ │ ├── abilities.ts
│ │ │ └── capabilities.ts
│ │ ├── mutations
│ │ │ ├── approve-account.ts
│ │ │ ├── create-asset.ts
│ │ │ ├── deploy.ts
│ │ │ ├── destroy-asset.ts
│ │ │ ├── grant-abilities.ts
│ │ │ ├── revoke-abilities.ts
│ │ │ ├── revoke-asset.ts
│ │ │ ├── safe-transfer.ts
│ │ │ ├── set-abilities.ts
│ │ │ ├── set-approval-for-all.ts
│ │ │ ├── set-enabled.ts
│ │ │ ├── transfer.ts
│ │ │ ├── update-asset.ts
│ │ │ └── update.ts
│ │ ├── queries
│ │ │ ├── get-abilities.ts
│ │ │ ├── get-account-asset-id-at.ts
│ │ │ ├── get-approved-account.ts
│ │ │ ├── get-asset-account.ts
│ │ │ ├── get-asset-id-at.ts
│ │ │ ├── get-asset.ts
│ │ │ ├── get-balance.ts
│ │ │ ├── get-capabilities.ts
│ │ │ ├── get-info.ts
│ │ │ ├── is-approved-for-all.ts
│ │ │ ├── is-enabled.ts
│ │ │ └── kitty-index-to-approved.ts
│ │ └── tests
│ │ │ ├── core
│ │ │ └── ledger
│ │ │ │ ├── approve-account-instance-method.test.ts
│ │ │ │ ├── approve-operator-instance-method.test.ts
│ │ │ │ ├── create-asset-instance-method.test.ts
│ │ │ │ ├── deploy-static-method.test.ts
│ │ │ │ ├── destroy-asset-instance-method.test.ts
│ │ │ │ ├── disapprove-account-instance-method.test.ts
│ │ │ │ ├── disapprove-operator-instance-method.test.ts
│ │ │ │ ├── get-abilities-instance-method.test.ts
│ │ │ │ ├── get-account-asset-id-at-method.test.ts
│ │ │ │ ├── get-approved-account-instance-method.test.ts
│ │ │ │ ├── get-asset-account-instance-method.test.ts
│ │ │ │ ├── get-asset-id-at-method.test.ts
│ │ │ │ ├── get-asset-instance-method.test.ts
│ │ │ │ ├── get-balance-instance-method.test.ts
│ │ │ │ ├── get-capabilities-instance-method.test.ts
│ │ │ │ ├── get-info-instance-method.test.ts
│ │ │ │ ├── get-transfer-state-instance-method.test.ts
│ │ │ │ ├── grant-abilities-instance-method.test.ts
│ │ │ │ ├── is-approved-account-instance-method.test.ts
│ │ │ │ ├── is-approved-operator-instance-method.test.ts
│ │ │ │ ├── revoke-abilities-instance-method.test.ts
│ │ │ │ ├── revoke-asset-instance-method.test.ts
│ │ │ │ ├── set-abilities-instance-method.test.ts
│ │ │ │ ├── set-transfer-state-instance-method.test.ts
│ │ │ │ ├── transfer-asset-instance-method.test.ts
│ │ │ │ ├── update-asset-instance-method.test.ts
│ │ │ │ └── update-instance-method.test.ts
│ │ │ └── index.test.ts
│ └── tsconfig.json
├── 0xcert-ethereum-erc20-contracts
│ ├── .eslintrc.js
│ ├── .solhint.json
│ ├── CHANGELOG.json
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── nodemon.json
│ ├── package.json
│ ├── src
│ │ ├── contracts
│ │ │ ├── dapp-token.sol
│ │ │ ├── erc20.sol
│ │ │ ├── migration-receiver.sol
│ │ │ ├── mocks
│ │ │ │ ├── dapp-token-mock.sol
│ │ │ │ └── token-mock.sol
│ │ │ ├── token.sol
│ │ │ ├── zxc-burner.sol
│ │ │ └── zxc.sol
│ │ ├── core
│ │ │ └── types.ts
│ │ ├── index.ts
│ │ └── tests
│ │ │ ├── dapp-token.test.ts
│ │ │ ├── helpers
│ │ │ └── common.ts
│ │ │ ├── mocks
│ │ │ └── zxc-mock.sol
│ │ │ ├── token.test.ts
│ │ │ └── zxc-burner.test.ts
│ └── tsconfig.json
├── 0xcert-ethereum-erc721-contracts
│ ├── .eslintrc.js
│ ├── .solhint.json
│ ├── CHANGELOG.json
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── nodemon.json
│ ├── package.json
│ ├── src
│ │ ├── contracts
│ │ │ ├── erc721-enumerable.sol
│ │ │ ├── erc721-metadata.sol
│ │ │ ├── erc721-token-receiver.sol
│ │ │ ├── erc721.sol
│ │ │ ├── mocks
│ │ │ │ ├── nf-token-enumerable-mock.sol
│ │ │ │ ├── nf-token-metadata-enumerable-mock.sol
│ │ │ │ ├── nf-token-metadata-mock.sol
│ │ │ │ └── nf-token-mock.sol
│ │ │ ├── nf-token-enumerable.sol
│ │ │ ├── nf-token-metadata-enumerable.sol
│ │ │ ├── nf-token-metadata.sol
│ │ │ └── nf-token.sol
│ │ └── tests
│ │ │ ├── mocks
│ │ │ ├── nf-token-enumerable-test-mock.sol
│ │ │ ├── nf-token-metadata-enumerable-test-mock.sol
│ │ │ ├── nf-token-metadata-test-mock.sol
│ │ │ ├── nf-token-receiver-test-mock.sol
│ │ │ └── nf-token-test-mock.sol
│ │ │ ├── nf-token-enumerable.test.ts
│ │ │ ├── nf-token-metadata-enumerable.test.ts
│ │ │ ├── nf-token-metadata.test.ts
│ │ │ └── nf-token.test.ts
│ └── tsconfig.json
├── 0xcert-ethereum-gateway-contracts
│ ├── .eslintrc.js
│ ├── .solhint.json
│ ├── CHANGELOG.json
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── nodemon.json
│ ├── package.json
│ ├── src
│ │ ├── contracts
│ │ │ ├── actions-gateway.sol
│ │ │ ├── token-deploy-gateway.sol
│ │ │ └── xcert-deploy-gateway.sol
│ │ ├── core
│ │ │ └── types.ts
│ │ ├── index.ts
│ │ └── tests
│ │ │ ├── actions-gateway
│ │ │ ├── burn-instance-method
│ │ │ │ ├── burn-fail.test.ts
│ │ │ │ └── burn-perform.test.ts
│ │ │ ├── create-instance-method
│ │ │ │ ├── create-perform-fail.test.ts
│ │ │ │ └── create-perform.test.ts
│ │ │ ├── manage-abilitites-instance-method
│ │ │ │ ├── manage-abilities-perform-fail.test.ts
│ │ │ │ └── manage-abilities-perform.test.ts
│ │ │ ├── misc
│ │ │ │ ├── cancel.test.ts
│ │ │ │ ├── claims.test.ts
│ │ │ │ ├── fail.test.ts
│ │ │ │ ├── multi.test.ts
│ │ │ │ └── proxies.test.ts
│ │ │ ├── transfer-erc20-instance-method
│ │ │ │ ├── transfer-erc20-fail.test.ts
│ │ │ │ └── transfer-erc20.test.ts
│ │ │ ├── transfer-erc721-instance-method
│ │ │ │ ├── transfer-erc721-fail.test.ts
│ │ │ │ └── transfer-erc721.test.ts
│ │ │ └── update-instance-method
│ │ │ │ ├── update-fail.test.ts
│ │ │ │ └── update-perform.test.ts
│ │ │ ├── helpers
│ │ │ ├── common.ts
│ │ │ └── signature.ts
│ │ │ ├── token-deploy-gateway
│ │ │ ├── cancel-instance-method.test.ts
│ │ │ ├── perform-any-taker-instance-method.test.ts
│ │ │ ├── perform-instance-method.test.ts
│ │ │ └── set-proxy-instance-method.test.ts
│ │ │ └── xcert-deploy-gateway
│ │ │ ├── cancel-instance-method.test.ts
│ │ │ ├── perform-any-taker-instance-method.test.ts
│ │ │ ├── perform-instance-method.test.ts
│ │ │ └── set-proxy-instance-method.test.ts
│ └── tsconfig.json
├── 0xcert-ethereum-gateway
│ ├── .eslintrc.js
│ ├── CHANGELOG.json
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── nodemon.json
│ ├── package.json
│ ├── src
│ │ ├── core
│ │ │ ├── gateway.ts
│ │ │ └── types.ts
│ │ ├── index.ts
│ │ ├── lib
│ │ │ ├── actions-order.ts
│ │ │ ├── asset-ledger-deploy-order.ts
│ │ │ ├── asset-set-operator-order.ts
│ │ │ ├── dapp-value-approve-order.ts
│ │ │ └── value-ledger-deploy-order.ts
│ │ ├── mutations
│ │ │ ├── actions-order
│ │ │ │ ├── cancel.ts
│ │ │ │ └── perform.ts
│ │ │ ├── asset-ledger-deploy-order
│ │ │ │ ├── cancel.ts
│ │ │ │ └── perform.ts
│ │ │ ├── asset-set-operator-order
│ │ │ │ ├── cancel.ts
│ │ │ │ └── perform.ts
│ │ │ ├── dapp-value-approve-order
│ │ │ │ ├── cancel.ts
│ │ │ │ └── perform.ts
│ │ │ └── value-ledger-deploy-order
│ │ │ │ ├── cancel.ts
│ │ │ │ └── perform.ts
│ │ ├── queries
│ │ │ ├── actions-order
│ │ │ │ ├── claim-eth-sign.ts
│ │ │ │ ├── claim-personal-sign.ts
│ │ │ │ ├── get-order-data-claim.ts
│ │ │ │ ├── get-proxy-account-id.ts
│ │ │ │ └── is-valid-signature.ts
│ │ │ ├── asset-ledger-deploy-order
│ │ │ │ ├── claim-eth-sign.ts
│ │ │ │ ├── claim-personal-sign.ts
│ │ │ │ ├── get-order-data-claim.ts
│ │ │ │ └── is-valid-signature.ts
│ │ │ ├── asset-set-operator-order
│ │ │ │ ├── claim-eth-sign.ts
│ │ │ │ ├── claim-personal-sign.ts
│ │ │ │ ├── get-order-data-claim.ts
│ │ │ │ └── is-valid-signature.ts
│ │ │ ├── dapp-value-approve-order
│ │ │ │ ├── claim-eth-sign.ts
│ │ │ │ ├── claim-personal-sign.ts
│ │ │ │ ├── get-order-data-claim.ts
│ │ │ │ └── is-valid-signature.ts
│ │ │ └── value-ledger-deploy-order
│ │ │ │ ├── claim-eth-sign.ts
│ │ │ │ ├── claim-personal-sign.ts
│ │ │ │ ├── get-order-data-claim.ts
│ │ │ │ └── is-valid-signature.ts
│ │ └── tests
│ │ │ ├── core
│ │ │ └── gateway
│ │ │ │ ├── actions-order
│ │ │ │ ├── cancel-instance-method.test.ts
│ │ │ │ ├── get-order-data-claim-instance-method.test.ts
│ │ │ │ ├── get-proxy-account-id-instance-method.test.ts
│ │ │ │ ├── is-valid-signature-instance-method.test.ts
│ │ │ │ └── perform-instance-method.test.ts
│ │ │ │ ├── asset-ledger-deploy-order
│ │ │ │ ├── cancel-instance-method.test.ts
│ │ │ │ ├── get-order-data-claim-method-instance.test.ts
│ │ │ │ ├── is-valid-signature-instance-method.test.ts
│ │ │ │ └── perform-instance-method.test.ts
│ │ │ │ ├── asset-set-operator-order
│ │ │ │ ├── cancel-instance-method.test.ts
│ │ │ │ ├── get-order-data-claim-method-instance.test.ts
│ │ │ │ ├── is-valid-signature-instance-method.test.ts
│ │ │ │ └── perform-instance-method.test.ts
│ │ │ │ ├── dapp-value-approve-order
│ │ │ │ ├── cancel-instance-method.test.ts
│ │ │ │ ├── get-order-data-claim-method-instance.test.ts
│ │ │ │ ├── is-valid-signature-instance-method.test.ts
│ │ │ │ └── perform-instance-method.test.ts
│ │ │ │ └── value-ledger-deploy-order
│ │ │ │ ├── cancel-instance-method.test.ts
│ │ │ │ ├── get-order-data-claim-method-instance.test.ts
│ │ │ │ ├── is-valid-signature-instance-method.test.ts
│ │ │ │ └── perform-instance-method.test.ts
│ │ │ ├── index.test.ts
│ │ │ └── lib
│ │ │ └── actions-order
│ │ │ └── normalize-order-ids-method.test.ts
│ └── tsconfig.json
├── 0xcert-ethereum-generic-provider
│ ├── .eslintrc.js
│ ├── CHANGELOG.json
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── nodemon.json
│ ├── package.json
│ ├── src
│ │ ├── core
│ │ │ ├── errors.ts
│ │ │ ├── helpers.ts
│ │ │ ├── mutation.ts
│ │ │ ├── provider.ts
│ │ │ └── types.ts
│ │ ├── index.ts
│ │ └── tests
│ │ │ ├── core
│ │ │ ├── helpers
│ │ │ │ └── build-gateway-config-instance-method.test.ts
│ │ │ ├── mutation
│ │ │ │ ├── cancel-instance-method.test.ts
│ │ │ │ ├── complete-instance-method.test.ts
│ │ │ │ ├── resolve-instance-method.test.ts
│ │ │ │ └── retry-instance-method.test.ts
│ │ │ └── provider
│ │ │ │ ├── account-change-event.test.ts
│ │ │ │ ├── account-id-instance-variable.test.ts
│ │ │ │ ├── gateway-config-instance-variable.test.ts
│ │ │ │ ├── get-available-accounts-instance-variable.test.ts
│ │ │ │ ├── get-network-version-instance-method.test.ts
│ │ │ │ ├── is-current-account-instance-variable.test.ts
│ │ │ │ ├── is-unsafe-recipient-id-instance-variable.test.ts
│ │ │ │ ├── post-instance-method.test.ts
│ │ │ │ ├── sign-instance-method.test.ts
│ │ │ │ └── unsafe-recipient-ids-instance-variable.test.ts
│ │ │ └── index.test.ts
│ └── tsconfig.json
├── 0xcert-ethereum-http-provider
│ ├── .eslintrc.js
│ ├── CHANGELOG.json
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── nodemon.json
│ ├── package.json
│ ├── src
│ │ ├── core
│ │ │ └── provider.ts
│ │ ├── index.ts
│ │ └── tests
│ │ │ ├── index.test.ts
│ │ │ └── provider
│ │ │ ├── get-network-version-instance-method.test.ts
│ │ │ └── send-instance-method.test.ts
│ └── tsconfig.json
├── 0xcert-ethereum-metamask-provider
│ ├── .eslintrc.js
│ ├── CHANGELOG.json
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── nodemon.json
│ ├── package.json
│ ├── src
│ │ ├── core
│ │ │ └── provider.ts
│ │ ├── index.ts
│ │ └── tests
│ │ │ └── index.test.ts
│ └── tsconfig.json
├── 0xcert-ethereum-proxy-contracts
│ ├── .eslintrc.js
│ ├── .solhint.json
│ ├── CHANGELOG.json
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── nodemon.json
│ ├── package.json
│ ├── src
│ │ ├── contracts
│ │ │ ├── abilitable-manage-proxy.sol
│ │ │ ├── iproxy.sol
│ │ │ ├── nftoken-safe-transfer-proxy.sol
│ │ │ ├── nftoken-transfer-proxy.sol
│ │ │ ├── token-custom.sol
│ │ │ ├── token-deploy-proxy.sol
│ │ │ ├── token-transfer-proxy.sol
│ │ │ ├── xcert-burn-proxy.sol
│ │ │ ├── xcert-create-proxy.sol
│ │ │ ├── xcert-custom.sol
│ │ │ ├── xcert-deploy-proxy.sol
│ │ │ └── xcert-update-proxy.sol
│ │ ├── core
│ │ │ └── types.ts
│ │ ├── index.ts
│ │ └── tests
│ │ │ ├── burn.test.ts
│ │ │ ├── create.test.ts
│ │ │ ├── manage.test.ts
│ │ │ ├── nftokens-safe.test.ts
│ │ │ ├── nftokens.test.ts
│ │ │ ├── token-custom.test.ts
│ │ │ ├── token-deploy-proxy.test.ts
│ │ │ ├── tokens.test.ts
│ │ │ ├── update.test.ts
│ │ │ ├── xcert-custom.test.ts
│ │ │ └── xcert-deploy-proxy.test.ts
│ └── tsconfig.json
├── 0xcert-ethereum-sandbox
│ ├── .eslintrc.js
│ ├── CHANGELOG.json
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── nodemon.json
│ ├── package.json
│ ├── src
│ │ ├── README.md
│ │ ├── config
│ │ │ └── contracts.ts
│ │ ├── core
│ │ │ ├── protocol.ts
│ │ │ └── sandbox.ts
│ │ ├── index.ts
│ │ ├── lib
│ │ │ └── deploy.ts
│ │ └── tests
│ │ │ ├── core
│ │ │ └── sandbox.test.ts
│ │ │ └── index.test.ts
│ └── tsconfig.json
├── 0xcert-ethereum-utils-contracts
│ ├── .eslintrc.js
│ ├── .solhint.json
│ ├── CHANGELOG.json
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── nodemon.json
│ ├── package.json
│ ├── src
│ │ ├── contracts
│ │ │ ├── permission
│ │ │ │ ├── abilitable.sol
│ │ │ │ ├── claimable.sol
│ │ │ │ └── ownable.sol
│ │ │ └── utils
│ │ │ │ ├── address-utils.sol
│ │ │ │ ├── bytes-type.sol
│ │ │ │ ├── erc165.sol
│ │ │ │ └── supports-interface.sol
│ │ └── tests
│ │ │ ├── abilitable.test.ts
│ │ │ ├── address-utils.test.ts
│ │ │ ├── bytes-to-types.test.ts
│ │ │ ├── claimable.test.ts
│ │ │ ├── mocks
│ │ │ ├── abilitable-test-mock.sol
│ │ │ ├── address-utils-mock.sol
│ │ │ └── unpack-test-mock.sol
│ │ │ ├── ownable.test.ts
│ │ │ └── supports-interface.test.ts
│ └── tsconfig.json
├── 0xcert-ethereum-utils
│ ├── .eslintrc.js
│ ├── CHANGELOG.json
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── nodemon.json
│ ├── package.json
│ ├── src
│ │ ├── index.ts
│ │ ├── lib
│ │ │ ├── abi.ts
│ │ │ ├── big-number.ts
│ │ │ ├── encoder.ts
│ │ │ ├── hex-to-bytes.ts
│ │ │ ├── left-pad.ts
│ │ │ ├── normalize-address.ts
│ │ │ ├── right-pad.ts
│ │ │ ├── string-to-hex.ts
│ │ │ └── zero-address.ts
│ │ ├── tests
│ │ │ ├── encode-parameters.test.ts
│ │ │ └── normalize-address.test.ts
│ │ └── types
│ │ │ └── utils.ts
│ └── tsconfig.json
├── 0xcert-ethereum-value-ledger
│ ├── .eslintrc.js
│ ├── CHANGELOG.json
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── nodemon.json
│ ├── package.json
│ ├── src
│ │ ├── core
│ │ │ └── ledger.ts
│ │ ├── index.ts
│ │ ├── mutations
│ │ │ ├── approve-account.ts
│ │ │ ├── deploy.ts
│ │ │ ├── transfer-from.ts
│ │ │ └── transfer.ts
│ │ ├── queries
│ │ │ ├── get-allowance.ts
│ │ │ ├── get-balance.ts
│ │ │ └── get-info.ts
│ │ └── tests
│ │ │ ├── core
│ │ │ └── ledger
│ │ │ │ ├── approve-value-instance-method.test.ts
│ │ │ │ ├── deploy-static-method.test.ts
│ │ │ │ ├── disapprove-value-instance-method.test.ts
│ │ │ │ ├── get-account-approved-value-method.test.ts
│ │ │ │ ├── get-balance-instance-method.test.ts
│ │ │ │ ├── get-info-instance-method.test.ts
│ │ │ │ ├── is-approved-value-method.test.ts
│ │ │ │ └── transfer-value-method.test.ts
│ │ │ └── index.test.ts
│ └── tsconfig.json
├── 0xcert-ethereum-xcert-contracts
│ ├── .eslintrc.js
│ ├── .solhint.json
│ ├── CHANGELOG.json
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── nodemon.json
│ ├── package.json
│ ├── src
│ │ ├── contracts
│ │ │ ├── ierc-2477.sol
│ │ │ ├── ixcert-burnable.sol
│ │ │ ├── ixcert-mutable.sol
│ │ │ ├── ixcert-pausable.sol
│ │ │ ├── ixcert-revokable.sol
│ │ │ ├── ixcert.sol
│ │ │ ├── mocks
│ │ │ │ └── xcert-mock.sol
│ │ │ ├── utils
│ │ │ │ └── selector.sol
│ │ │ └── xcert.sol
│ │ ├── core
│ │ │ └── types.ts
│ │ ├── index.ts
│ │ └── tests
│ │ │ ├── destroyable-xcert.test.ts
│ │ │ ├── full-xcert.test.ts
│ │ │ ├── helpers
│ │ │ └── common.ts
│ │ │ ├── mutable-xcert.test.ts
│ │ │ ├── pausable-xcert.test.ts
│ │ │ ├── revokable-xcert.test.ts
│ │ │ ├── utils
│ │ │ └── selector.test.ts
│ │ │ └── xcert.test.ts
│ └── tsconfig.json
├── 0xcert-merkle
│ ├── .eslintrc.js
│ ├── CHANGELOG.json
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── nodemon.json
│ ├── package.json
│ ├── src
│ │ ├── core
│ │ │ └── merkle.ts
│ │ ├── index.ts
│ │ └── tests
│ │ │ ├── core
│ │ │ └── merkle
│ │ │ │ ├── disclose-instance-method.test.ts
│ │ │ │ ├── imprint-instance-method.test.ts
│ │ │ │ └── notarize-instance-method.test.ts
│ │ │ └── index.test.ts
│ └── tsconfig.json
├── 0xcert-scaffold
│ ├── .eslintrc.js
│ ├── CHANGELOG.json
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── nodemon.json
│ ├── package.json
│ ├── src
│ │ ├── assets
│ │ │ └── metadata.ts
│ │ ├── core
│ │ │ ├── asset-ledger.ts
│ │ │ ├── gateway.ts
│ │ │ ├── issues.ts
│ │ │ ├── messages.ts
│ │ │ ├── mutation.ts
│ │ │ ├── provider.ts
│ │ │ └── value-ledger.ts
│ │ ├── index.ts
│ │ └── tests
│ │ │ └── index.test.ts
│ └── tsconfig.json
├── 0xcert-utils
│ ├── .eslintrc.js
│ ├── CHANGELOG.json
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── nodemon.json
│ ├── package.json
│ ├── src
│ │ ├── index.ts
│ │ ├── methods
│ │ │ ├── fetch.ts
│ │ │ ├── keccak.ts
│ │ │ ├── sha.ts
│ │ │ ├── to-float.ts
│ │ │ ├── to-integer.ts
│ │ │ ├── to-seconds.ts
│ │ │ ├── to-string.ts
│ │ │ └── to-tuple.ts
│ │ └── tests
│ │ │ ├── index.test.ts
│ │ │ ├── methods
│ │ │ ├── fetch.test.ts
│ │ │ ├── keccak.test.ts
│ │ │ ├── sha.test.ts
│ │ │ ├── to-float.test.ts
│ │ │ ├── to-integer.test.ts
│ │ │ ├── to-seconds.test.ts
│ │ │ ├── to-string.test.ts
│ │ │ └── to-tuple.test.ts
│ │ │ └── mocks
│ │ │ └── xcert-mock.json
│ └── tsconfig.json
├── 0xcert-vue-example
│ ├── .gitignore
│ ├── README.md
│ ├── nuxt.config.js
│ ├── package.json
│ ├── pages
│ │ └── index.vue
│ └── plugins
│ │ └── 0xcert.js
├── 0xcert-vue-plugin
│ ├── .eslintrc.js
│ ├── CHANGELOG.json
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── nodemon.json
│ ├── package.json
│ ├── src
│ │ ├── core
│ │ │ ├── client.ts
│ │ │ └── plugin.ts
│ │ ├── index.ts
│ │ └── tests
│ │ │ └── index.test.ts
│ └── tsconfig.json
├── 0xcert-wanchain-asset-ledger
│ ├── .eslintrc.js
│ ├── CHANGELOG.json
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── nodemon.json
│ ├── package.json
│ ├── src
│ │ ├── core
│ │ │ └── ledger.ts
│ │ ├── index.ts
│ │ └── tests
│ │ │ └── index.test.ts
│ └── tsconfig.json
├── 0xcert-wanchain-gateway
│ ├── .eslintrc.js
│ ├── CHANGELOG.json
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── nodemon.json
│ ├── package.json
│ ├── src
│ │ ├── core
│ │ │ └── gateway.ts
│ │ ├── index.ts
│ │ └── tests
│ │ │ └── index.test.ts
│ └── tsconfig.json
├── 0xcert-wanchain-generic-provider
│ ├── .eslintrc.js
│ ├── CHANGELOG.json
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── nodemon.json
│ ├── package.json
│ ├── src
│ │ ├── core
│ │ │ ├── helpers.ts
│ │ │ ├── provider.ts
│ │ │ └── types.ts
│ │ ├── index.ts
│ │ └── tests
│ │ │ ├── core
│ │ │ ├── helpers
│ │ │ │ └── build-gateway-config-instance-method.test.ts
│ │ │ └── provider
│ │ │ │ └── config.test.ts
│ │ │ └── index.test.ts
│ └── tsconfig.json
├── 0xcert-wanchain-http-provider
│ ├── .eslintrc.js
│ ├── CHANGELOG.json
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── nodemon.json
│ ├── package.json
│ ├── src
│ │ ├── core
│ │ │ └── provider.ts
│ │ ├── index.ts
│ │ └── tests
│ │ │ ├── index.test.ts
│ │ │ └── provider
│ │ │ ├── get-network-version-instance-method.test.ts
│ │ │ ├── normalize-address.test.ts
│ │ │ └── send-instance-method.test.ts
│ └── tsconfig.json
├── 0xcert-wanchain-utils
│ ├── .eslintrc.js
│ ├── CHANGELOG.json
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── nodemon.json
│ ├── package.json
│ ├── src
│ │ ├── index.ts
│ │ ├── lib
│ │ │ └── encoder.ts
│ │ └── tests
│ │ │ └── normalize-address.test.ts
│ └── tsconfig.json
├── 0xcert-wanchain-value-ledger
│ ├── .eslintrc.js
│ ├── CHANGELOG.json
│ ├── CHANGELOG.md
│ ├── README.md
│ ├── nodemon.json
│ ├── package.json
│ ├── src
│ │ ├── core
│ │ │ └── ledger.ts
│ │ ├── index.ts
│ │ └── tests
│ │ │ └── index.test.ts
│ └── tsconfig.json
└── 0xcert-webpack
│ ├── README.md
│ ├── example
│ └── index.html
│ ├── nodemon.json
│ ├── package.json
│ ├── src
│ ├── 0xcert-cert.js
│ ├── 0xcert-ethereum-asset-ledger.js
│ ├── 0xcert-ethereum-gateway.js
│ ├── 0xcert-ethereum-http-provider.js
│ ├── 0xcert-ethereum-metamask-provider.js
│ ├── 0xcert-ethereum-value-ledger.js
│ ├── 0xcert-ethereum.js
│ ├── 0xcert-wanchain-asset-ledger.js
│ ├── 0xcert-wanchain-gateway.js
│ ├── 0xcert-wanchain-http-provider.js
│ ├── 0xcert-wanchain-value-ledger.js
│ └── 0xcert-wanchain.js
│ └── webpack.config.js
└── rush.json
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Don't allow people to merge changes to these generated files, because the result
2 | # may be invalid. You need to run "rush update" again.
3 | shrinkwrap.yaml merge=binary
4 | npm-shrinkwrap.json merge=binary
5 | yarn.lock merge=binary
6 | *.sol linguist-language=Solidity
7 |
--------------------------------------------------------------------------------
/LICENCE:
--------------------------------------------------------------------------------
1 | The MIT License
2 |
3 | Copyright (c) 2018 0xcert.org.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/SECURITY.md:
--------------------------------------------------------------------------------
1 | # Security Policy
2 |
3 | ## Supported versions
4 |
5 | Only the latest minor version of 0xcert Framework is supported with security updates. These updates are published as new patch versions. All versioning follows Semantic Versioning. You can find the latest version [released on GitHub](https://github.com/0xcert/framework/releases) and simultaneously published on NPM under individual packages.
6 |
7 | | Release | Supported |
8 | | ------- | ------------------ |
9 | | [master branch](https://github.com/0xcert/framework) | :white_check_mark: |
10 | | [Latest GitHub release](https://github.com/0xcert/framework) (excluding "prerelease" versions) | :white_check_mark: |
11 | | Latest NPM release (excluding "prerelease" versions) | :white_check_mark: |
12 | | Earlier minor releases | :x: |
13 |
14 | ## Reporting a vulnerability
15 |
16 | We really appreciate your help in finding bugs and vulnerabilities in this repository. Please report bugs and vulnerabilities using [GitHub Issues](https://github.com/0xcert/framework/issues) and we will pay you according to [our bug bounty](BUG_BOUNTY.md). If you wish to report issues privately, you can still enter into our bug bounty program. Please see additional details on the above-mentioned page.
17 |
--------------------------------------------------------------------------------
/assets/cover-sub.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xcert/framework/88c8ec7107a86b5aecd2ac943a4df100ba602bac/assets/cover-sub.png
--------------------------------------------------------------------------------
/assets/cover.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xcert/framework/88c8ec7107a86b5aecd2ac943a4df100ba602bac/assets/cover.png
--------------------------------------------------------------------------------
/assets/ethereum.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xcert/framework/88c8ec7107a86b5aecd2ac943a4df100ba602bac/assets/ethereum.png
--------------------------------------------------------------------------------
/assets/wanchain.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xcert/framework/88c8ec7107a86b5aecd2ac943a4df100ba602bac/assets/wanchain.png
--------------------------------------------------------------------------------
/common/config/rush/.npmrc:
--------------------------------------------------------------------------------
1 | # Rush uses this file to configure the package registry, regardless of whether the
2 | # package manager is PNPM, NPM, or Yarn. Prior to invoking the package manager,
3 | # Rush will always copy this file to the folder where installation is performed.
4 | # When NPM is the package manager, Rush works around NPM's processing of
5 | # undefined environment variables by deleting any lines that reference undefined
6 | # environment variables.
7 | #
8 | # DO NOT SPECIFY AUTHENTICATION CREDENTIALS IN THIS FILE. It should only be used
9 | # to configure registry sources.
10 |
11 | registry=https://registry.npmjs.org/
12 | always-auth=false
13 |
--------------------------------------------------------------------------------
/common/config/rush/command-line.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://developer.microsoft.com/json-schemas/rush/v5/command-line.schema.json",
3 | "commands": [
4 | {
5 | "commandKind": "bulk",
6 | "name": "test",
7 | "summary": "Test packages.",
8 | "description": "Executes automated tests.",
9 | "enableParallelism": true
10 | }
11 | ],
12 | "parameters": []
13 | }
14 |
--------------------------------------------------------------------------------
/common/config/rush/version-policies.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "policyName": "patchAll",
4 | "definitionName": "lockStepVersion",
5 | "version": "2.1.1",
6 | "nextBump": "patch"
7 | }
8 | ]
9 |
--------------------------------------------------------------------------------
/common/logs/.keep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/0xcert/framework/88c8ec7107a86b5aecd2ac943a4df100ba602bac/common/logs/.keep
--------------------------------------------------------------------------------
/common/scripts/install-run-rushx.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 | // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
3 | // See the @microsoft/rush package's LICENSE file for license information.
4 | Object.defineProperty(exports, "__esModule", { value: true });
5 | // THIS FILE WAS GENERATED BY A TOOL. ANY MANUAL MODIFICATIONS WILL GET OVERWRITTEN WHENEVER RUSH IS UPGRADED.
6 | //
7 | // This script is intended for usage in an automated build environment where the Rush command may not have
8 | // been preinstalled, or may have an unpredictable version. This script will automatically install the version of Rush
9 | // specified in the rush.json configuration file (if not already installed), and then pass a command-line to the
10 | // rushx command.
11 | //
12 | // An example usage would be:
13 | //
14 | // node common/scripts/install-run-rushx.js custom-command
15 | //
16 | // For more information, see: https://rushjs.io/pages/maintainer/setup_new_repo/
17 | require("./install-run-rush");
18 | //# sourceMappingURL=install-run-rushx.js.map
--------------------------------------------------------------------------------
/common/scripts/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@0xcert/scripts",
3 | "version": "0.0.1",
4 | "description": "Common scripts.",
5 | "scripts": {
6 | "test": "echo \"Error: no test specified\" && exit 1"
7 | },
8 | "author": "0xcert",
9 | "license": "MIT",
10 | "dependencies": {
11 | "web3": "1.2.6"
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/dist/0xcert-ethereum-asset-ledger.min.js.LICENSE.txt:
--------------------------------------------------------------------------------
1 | /**
2 | * [js-sha3]{@link https://github.com/emn178/js-sha3}
3 | *
4 | * @version 0.5.7
5 | * @author Chen, Yi-Cyuan [emn178@gmail.com]
6 | * @copyright Chen, Yi-Cyuan 2015-2016
7 | * @license MIT
8 | */
9 |
--------------------------------------------------------------------------------
/dist/0xcert-ethereum-gateway.min.js.LICENSE.txt:
--------------------------------------------------------------------------------
1 | /**
2 | * [js-sha3]{@link https://github.com/emn178/js-sha3}
3 | *
4 | * @version 0.5.7
5 | * @author Chen, Yi-Cyuan [emn178@gmail.com]
6 | * @copyright Chen, Yi-Cyuan 2015-2016
7 | * @license MIT
8 | */
9 |
--------------------------------------------------------------------------------
/dist/0xcert-ethereum-http-provider.min.js.LICENSE.txt:
--------------------------------------------------------------------------------
1 | /**
2 | * [js-sha3]{@link https://github.com/emn178/js-sha3}
3 | *
4 | * @version 0.5.7
5 | * @author Chen, Yi-Cyuan [emn178@gmail.com]
6 | * @copyright Chen, Yi-Cyuan 2015-2016
7 | * @license MIT
8 | */
9 |
--------------------------------------------------------------------------------
/dist/0xcert-ethereum-metamask-provider.min.js.LICENSE.txt:
--------------------------------------------------------------------------------
1 | /**
2 | * [js-sha3]{@link https://github.com/emn178/js-sha3}
3 | *
4 | * @version 0.5.7
5 | * @author Chen, Yi-Cyuan [emn178@gmail.com]
6 | * @copyright Chen, Yi-Cyuan 2015-2016
7 | * @license MIT
8 | */
9 |
--------------------------------------------------------------------------------
/dist/0xcert-ethereum-value-ledger.min.js.LICENSE.txt:
--------------------------------------------------------------------------------
1 | /**
2 | * [js-sha3]{@link https://github.com/emn178/js-sha3}
3 | *
4 | * @version 0.5.7
5 | * @author Chen, Yi-Cyuan [emn178@gmail.com]
6 | * @copyright Chen, Yi-Cyuan 2015-2016
7 | * @license MIT
8 | */
9 |
--------------------------------------------------------------------------------
/dist/0xcert-ethereum.min.js.LICENSE.txt:
--------------------------------------------------------------------------------
1 | /**
2 | * [js-sha3]{@link https://github.com/emn178/js-sha3}
3 | *
4 | * @version 0.5.7
5 | * @author Chen, Yi-Cyuan [emn178@gmail.com]
6 | * @copyright Chen, Yi-Cyuan 2015-2016
7 | * @license MIT
8 | */
9 |
--------------------------------------------------------------------------------
/dist/0xcert-wanchain-asset-ledger.min.js.LICENSE.txt:
--------------------------------------------------------------------------------
1 | /**
2 | * [js-sha3]{@link https://github.com/emn178/js-sha3}
3 | *
4 | * @version 0.5.7
5 | * @author Chen, Yi-Cyuan [emn178@gmail.com]
6 | * @copyright Chen, Yi-Cyuan 2015-2016
7 | * @license MIT
8 | */
9 |
--------------------------------------------------------------------------------
/dist/0xcert-wanchain-gateway.min.js.LICENSE.txt:
--------------------------------------------------------------------------------
1 | /**
2 | * [js-sha3]{@link https://github.com/emn178/js-sha3}
3 | *
4 | * @version 0.5.7
5 | * @author Chen, Yi-Cyuan [emn178@gmail.com]
6 | * @copyright Chen, Yi-Cyuan 2015-2016
7 | * @license MIT
8 | */
9 |
--------------------------------------------------------------------------------
/dist/0xcert-wanchain-http-provider.min.js.LICENSE.txt:
--------------------------------------------------------------------------------
1 | /**
2 | * [js-sha3]{@link https://github.com/emn178/js-sha3}
3 | *
4 | * @version 0.5.7
5 | * @author Chen, Yi-Cyuan [emn178@gmail.com]
6 | * @copyright Chen, Yi-Cyuan 2015-2016
7 | * @license MIT
8 | */
9 |
--------------------------------------------------------------------------------
/dist/0xcert-wanchain-value-ledger.min.js.LICENSE.txt:
--------------------------------------------------------------------------------
1 | /**
2 | * [js-sha3]{@link https://github.com/emn178/js-sha3}
3 | *
4 | * @version 0.5.7
5 | * @author Chen, Yi-Cyuan [emn178@gmail.com]
6 | * @copyright Chen, Yi-Cyuan 2015-2016
7 | * @license MIT
8 | */
9 |
--------------------------------------------------------------------------------
/dist/0xcert-wanchain.min.js.LICENSE.txt:
--------------------------------------------------------------------------------
1 | /**
2 | * [js-sha3]{@link https://github.com/emn178/js-sha3}
3 | *
4 | * @version 0.5.7
5 | * @author Chen, Yi-Cyuan [emn178@gmail.com]
6 | * @copyright Chen, Yi-Cyuan 2015-2016
7 | * @license MIT
8 | */
9 |
--------------------------------------------------------------------------------
/packages/0xcert-cert/nodemon.json:
--------------------------------------------------------------------------------
1 | {
2 | "ignore": ["dist/*"],
3 | "ext": "js,ts"
4 | }
5 |
--------------------------------------------------------------------------------
/packages/0xcert-cert/src/core/prop.ts:
--------------------------------------------------------------------------------
1 | import { MerkleNode, MerkleValue } from '@0xcert/merkle';
2 |
3 | /**
4 | * Property (level) recipe interface.
5 | */
6 | export interface PropRecipe {
7 | path: PropPath;
8 | values: PropValue[];
9 | nodes: PropNode[];
10 | }
11 |
12 | /**
13 | * Property value interface.
14 | */
15 | export interface PropValue extends MerkleValue {}
16 |
17 | /**
18 | * Property node interface.
19 | */
20 | export interface PropNode extends MerkleNode {}
21 |
22 | /**
23 | * Property path type.
24 | */
25 | export type PropPath = PropKey[];
26 |
27 | /**
28 | * Property path key type.
29 | */
30 | export type PropKey = string | number;
31 |
--------------------------------------------------------------------------------
/packages/0xcert-cert/src/index.ts:
--------------------------------------------------------------------------------
1 | export * from './core/cert';
2 | export * from './core/prop';
3 |
--------------------------------------------------------------------------------
/packages/0xcert-cert/src/tests/core/cert/expose-instance-method.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@hayspec/spec';
2 | import { Cert } from '../../../core/cert';
3 | import { defaultData } from '../helpers/schemas';
4 |
5 | const spec = new Spec();
6 |
7 | spec.test('returns truncated data object with name', async (ctx) => {
8 | const cert = new Cert({
9 | schema: {},
10 | });
11 | const metadata = cert.expose(defaultData, [
12 | ['name'],
13 | ]);
14 | ctx.deepEqual(metadata, {
15 | name: 'B',
16 | });
17 | });
18 |
19 | spec.test('returns truncated data object with event.organizer.name and email', async (ctx) => {
20 | const cert = new Cert({
21 | schema: {},
22 | });
23 | const metadata = cert.expose(defaultData, [
24 | ['event', 'organizer', 'name'],
25 | ['email'],
26 | ]);
27 | ctx.deepEqual(metadata, {
28 | event: {
29 | organizer: {
30 | name: 'B',
31 | },
32 | },
33 | email: 'A',
34 | });
35 | });
36 |
37 | spec.test('returns truncated data object with tags.1', async (ctx) => {
38 | const cert = new Cert({
39 | schema: {},
40 | });
41 | const metadata = cert.expose(defaultData, [
42 | ['tags', 1],
43 | ]);
44 | ctx.deepEqual(metadata, {
45 | tags: [null, 2],
46 | });
47 | });
48 |
49 | export default spec;
50 |
--------------------------------------------------------------------------------
/packages/0xcert-cert/src/tests/core/cert/imprint-instance-method.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@hayspec/spec';
2 | import { Cert } from '../../../core/cert';
3 | import { defaultData, defaultSchema } from '../helpers/schemas';
4 |
5 | const spec = new Spec();
6 |
7 | spec.test('calculates imprint for complete data object', async (ctx) => {
8 | const cert = new Cert({
9 | schema: defaultSchema,
10 | });
11 | const imprint = await cert.imprint(defaultData);
12 | ctx.is(imprint, '048c8f3384d5600792a4c8279d2c933fa43c26b81f2cab63462b72dd7488baad');
13 | });
14 |
15 | export default spec;
16 |
--------------------------------------------------------------------------------
/packages/0xcert-cert/src/tests/index.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@hayspec/spec';
2 | import * as certification from '..';
3 |
4 | const spec = new Spec();
5 |
6 | spec.test('exposes objects', (ctx) => {
7 | ctx.true(!!certification.Cert);
8 | });
9 |
10 | export default spec;
11 |
--------------------------------------------------------------------------------
/packages/0xcert-cert/src/tests/utils/data/read-path-method.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@hayspec/spec';
2 | import { readPath } from '../../../utils/data';
3 |
4 | const spec = new Spec();
5 |
6 | spec.test('reads JSON property at path', async (ctx) => {
7 | ctx.is(readPath(['a'], { a: 'a' }), 'a');
8 | ctx.is(readPath(['a', 'b'], { a: { b: 'b' } }), 'b');
9 | ctx.is(readPath(['a', 1, 'b'], { a: [[], { b: 'b' }] }), 'b');
10 | });
11 |
12 | export default spec;
13 |
--------------------------------------------------------------------------------
/packages/0xcert-cert/src/tests/utils/data/step-paths-method.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@hayspec/spec';
2 | import { stepPaths } from '../../../utils/data';
3 |
4 | const spec = new Spec();
5 |
6 | spec.test('converts a value to string', async (ctx) => {
7 | ctx.deepEqual(
8 | stepPaths([['a', 'b', 'c']]),
9 | [[], ['a'], ['a', 'b'], ['a', 'b', 'c']],
10 | );
11 | ctx.deepEqual(
12 | stepPaths([['a', 'b', 'c'], ['a', 'b']]),
13 | [[], ['a'], ['a', 'b'], ['a', 'b', 'c']],
14 | );
15 | });
16 |
17 | export default spec;
18 |
--------------------------------------------------------------------------------
/packages/0xcert-cert/src/tests/utils/data/to-string-method.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@hayspec/spec';
2 | import { toString } from '../../../utils/data';
3 |
4 | const spec = new Spec();
5 |
6 | spec.test('converts a value to string', async (ctx) => {
7 | ctx.is(toString(true), 'true');
8 | ctx.is(toString(false), 'false');
9 | ctx.is(toString(undefined), '');
10 | ctx.is(toString(null), '');
11 | ctx.is(toString(1), '1');
12 | ctx.is(toString(-1), '-1');
13 | ctx.is(toString(1.234), '1.234');
14 | ctx.is(toString(9999999999999999999999999), '1e+25');
15 | ctx.is(toString(1e+25), '1e+25');
16 | });
17 |
18 | export default spec;
19 |
--------------------------------------------------------------------------------
/packages/0xcert-cert/src/tests/utils/data/write-path-method.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@hayspec/spec';
2 | import { writePath } from '../../../utils/data';
3 |
4 | const spec = new Spec();
5 |
6 | spec.test('writes JSON property at path', async (ctx) => {
7 | ctx.deepEqual(writePath(['a'], 1, {}), { a: 1 });
8 | ctx.deepEqual(writePath(['b', 1], 'foo', {}), { b: [null, 'foo'] });
9 | ctx.deepEqual(writePath(['c', 1, 'd'], 'foo', {}), { c: [null, { d: 'foo'}] });
10 | ctx.deepEqual(writePath(['c', 2, 'd'], 'foo', { c: [{ d: 'bar'}] }), { c: [{ d: 'bar'}, null, { d: 'foo'}] });
11 | ctx.deepEqual(writePath(['b', 0], 'foo', { 'a': 'bar' }), { a: 'bar', b: ['foo'] });
12 | });
13 |
14 | export default spec;
15 |
--------------------------------------------------------------------------------
/packages/0xcert-cert/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "es6",
5 | "noImplicitAny": false,
6 | "removeComments": true,
7 | "sourceMap": true,
8 | "outDir": "dist",
9 | "declaration": true,
10 | "experimentalDecorators": true,
11 | "allowSyntheticDefaultImports": true
12 | }
13 | }
--------------------------------------------------------------------------------
/packages/0xcert-conventions/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | # 🧱 Conventions Module
4 |
5 | *The TypeScript implementation of all confirmed 0xcert conventions*
6 |
7 | ## Purpose
8 |
9 | This module provides TypeScript interfaces for all the confirmed application data conventions.
10 |
11 | Yes, the 0xcert Conventions are just simply JSON objects. And you could create them yourself. But we have created this simple module to bring you type-safe TypeScript goodness.
12 |
13 | ## The big picture
14 |
15 | The [0xcert Framework](https://docs.0xcert.org) is a free and open-source JavaScript library that provides tools for building powerful decentralized applications. Please refer to the [official documentation](https://docs.0xcert.org) for more details.
16 |
17 | This module is one of the bricks of the [0xcert Framework](https://docs.0xcert.org). It’s written with [TypeScript](https://www.typescriptlang.org) and it’s actively maintained. The source code is available on [GitHub](https://github.com/0xcert/framework) where you can also find our [issue tracker](https://github.com/0xcert/framework/issues).
18 |
--------------------------------------------------------------------------------
/packages/0xcert-conventions/nodemon.json:
--------------------------------------------------------------------------------
1 | {
2 | "ignore": ["dist/*"],
3 | "ext": "js,ts"
4 | }
5 |
--------------------------------------------------------------------------------
/packages/0xcert-conventions/src/assets/86-base-asset.ts:
--------------------------------------------------------------------------------
1 | import { SchemaErc721, schemaErc721 } from './erc721';
2 |
3 | /**
4 | * Base asset data object interface.
5 | */
6 | export interface Schema86 extends SchemaErc721 {
7 | $evidence?: string;
8 | $schema: string;
9 | description?: string;
10 | image?: string;
11 | name?: string;
12 | }
13 |
14 | /**
15 | * Base asset data object JSON Schema.
16 | */
17 | export const schema86 = {
18 | $schema: 'https://conventions.0xcert.org/xcert-schema.json',
19 | description: 'An abstract digital asset schema.',
20 | properties: {
21 | $evidence: {
22 | description: 'A path to the evidence JSON with data needed to verify the asset.',
23 | type: 'string',
24 | },
25 | $schema: {
26 | description: 'A path to JSON Schema definition file.',
27 | type: 'string',
28 | },
29 | ...schemaErc721.properties,
30 | },
31 | title: 'Base Asset',
32 | type: 'object',
33 | };
34 |
--------------------------------------------------------------------------------
/packages/0xcert-conventions/src/assets/88-crypto-collectible.ts:
--------------------------------------------------------------------------------
1 | import { Schema86, schema86 } from './86-base-asset';
2 |
3 | /**
4 | * Crypto collectible asset data object interface.
5 | */
6 | export interface Schema88 extends Schema86 {
7 | $evidence?: string;
8 | $schema: string;
9 | description: string;
10 | image: string;
11 | name: string;
12 | }
13 |
14 | /**
15 | * Crypto collectible asset data object JSON Schema.
16 | */
17 | export const schema88 = {
18 | $schema: 'https://conventions.0xcert.org/xcert-schema.json',
19 | description: 'An abstract digital asset schema.',
20 | properties: {
21 | ...schema86.properties,
22 | },
23 | title: 'Crypto Collectible',
24 | type: 'object',
25 | };
26 |
--------------------------------------------------------------------------------
/packages/0xcert-conventions/src/index.ts:
--------------------------------------------------------------------------------
1 | export * from './assets/86-base-asset';
2 | export * from './assets/87-asset-evidence';
3 | export * from './assets/88-crypto-collectible';
4 | export * from './assets/erc721';
5 | export * from './assets/xcert-schema';
6 |
--------------------------------------------------------------------------------
/packages/0xcert-conventions/src/tests/86-base-asset.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@hayspec/spec';
2 | import { Validator } from 'jsonschema';
3 | import { Schema86, schema86 } from '../assets/86-base-asset';
4 |
5 | const spec = new Spec<{
6 | validator: Validator;
7 | }>();
8 |
9 | spec.before((stage) => {
10 | stage.set('validator', new Validator());
11 | });
12 |
13 | spec.test('passes for valid data', (ctx) => {
14 | const data: Schema86 = {
15 | '$evidence': 'https://troopersgame.com/dog/evidence',
16 | '$schema': 'http://json-schema.org/draft-07/schema',
17 | 'description': 'A weapon for the Troopers game which can severely injure the enemy.',
18 | 'image': 'https://troopersgame.com/dog.jpg',
19 | 'name': 'Troopers game',
20 | };
21 | ctx.true(ctx.get('validator').validate(data, schema86).valid);
22 | });
23 |
24 | spec.test('fails for valid data', (ctx) => {
25 | const data = {
26 | '$evidence': 'https://troopersgame.com/dog/evidence',
27 | '$schema': 'http://json-schema.org/draft-07/schema',
28 | 'description': 'A weapon for the Troopers game which can severely injure the enemy.',
29 | 'image': 'https://troopersgame.com/dog.jpg',
30 | 'name': 12,
31 | };
32 | ctx.false(ctx.get('validator').validate(data, schema86).valid);
33 | });
34 |
35 | export default spec;
36 |
--------------------------------------------------------------------------------
/packages/0xcert-conventions/src/tests/88-base-asset.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@hayspec/spec';
2 | import { Validator } from 'jsonschema';
3 | import { Schema88, schema88 } from '../assets/88-crypto-collectible';
4 |
5 | const spec = new Spec<{
6 | validator: Validator;
7 | }>();
8 |
9 | spec.before((stage) => {
10 | stage.set('validator', new Validator());
11 | });
12 |
13 | spec.test('passes for valid data', (ctx) => {
14 | const data: Schema88 = {
15 | '$evidence': 'https://troopersgame.com/dog/evidence',
16 | '$schema': 'http://json-schema.org/draft-07/schema',
17 | 'description': 'A weapon for the Troopers game which can severely injure the enemy.',
18 | 'image': 'https://troopersgame.com/dog.jpg',
19 | 'name': 'Troopers game',
20 | };
21 | ctx.true(ctx.get('validator').validate(data, schema88).valid);
22 | });
23 |
24 | spec.test('fails for valid data', (ctx) => {
25 | const data = {
26 | '$evidence': 'https://troopersgame.com/dog/evidence',
27 | '$schema': 'http://json-schema.org/draft-07/schema',
28 | 'description': 'A weapon for the Troopers game which can severely injure the enemy.',
29 | 'image': 'https://troopersgame.com/dog.jpg',
30 | 'name': 12,
31 | };
32 | ctx.false(ctx.get('validator').validate(data, schema88).valid);
33 | });
34 |
35 | export default spec;
36 |
--------------------------------------------------------------------------------
/packages/0xcert-conventions/src/tests/erc721.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@hayspec/spec';
2 | import { Validator } from 'jsonschema';
3 | import { SchemaErc721, schemaErc721 } from '../assets/erc721';
4 |
5 | const spec = new Spec<{
6 | validator: Validator;
7 | }>();
8 |
9 | spec.before((stage) => {
10 | stage.set('validator', new Validator());
11 | });
12 |
13 | spec.test('passes for valid data', (ctx) => {
14 | const data: SchemaErc721 = {
15 | 'description': 'A weapon for the Troopers game which can severely injure the enemy.',
16 | 'image': 'https://troopersgame.com/dog.jpg',
17 | 'name': 'Troopers game',
18 | };
19 | ctx.true(ctx.get('validator').validate(data, schemaErc721).valid);
20 | });
21 |
22 | spec.test('fails for valid data', (ctx) => {
23 | const data = {
24 | 'description': 'A weapon for the Troopers game which can severely injure the enemy.',
25 | 'image': 'https://troopersgame.com/dog.jpg',
26 | 'name': 12,
27 | };
28 | ctx.false(ctx.get('validator').validate(data, schemaErc721).valid);
29 | });
30 |
31 | export default spec;
32 |
--------------------------------------------------------------------------------
/packages/0xcert-conventions/src/tests/index.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@hayspec/spec';
2 | import * as conventions from '..';
3 |
4 | const spec = new Spec();
5 |
6 | spec.test('exposes objects', (ctx) => {
7 | ctx.true(!!conventions.schema86);
8 | ctx.true(!!conventions.schema87);
9 | ctx.true(!!conventions.schema88);
10 | ctx.true(!!conventions.schemaErc721);
11 | ctx.true(!!conventions.xcertSchema);
12 | });
13 |
14 | export default spec;
15 |
--------------------------------------------------------------------------------
/packages/0xcert-conventions/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "es6",
5 | "noImplicitAny": false,
6 | "removeComments": true,
7 | "sourceMap": true,
8 | "outDir": "dist",
9 | "declaration": true,
10 | "experimentalDecorators": true,
11 | "allowSyntheticDefaultImports": true
12 | }
13 | }
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-asset-ledger/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | > Asset ledger module for asset management on the Ethereum blockchain.
4 |
5 | The [0xcert Framework](https://docs.0xcert.org) is a free and open-source JavaScript library that provides tools for building powerful decentralized applications. Please refer to the [official documentation](https://docs.0xcert.org) for more details.
6 |
7 | This module is one of the bricks of the [0xcert Framework](https://docs.0xcert.org). It's written with [TypeScript](https://www.typescriptlang.org) and it's actively maintained. The source code is available on [GitHub](https://github.com/0xcert/framework) where you can also find our [issue tracker](https://github.com/0xcert/framework/issues).
8 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-asset-ledger/nodemon.json:
--------------------------------------------------------------------------------
1 | {
2 | "ignore": ["dist/*"],
3 | "ext": "js,ts"
4 | }
5 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-asset-ledger/src/index.ts:
--------------------------------------------------------------------------------
1 | export { AssetLedgerBase, AssetLedgerDeployRecipe, AssetLedgerAbility, GeneralAssetLedgerAbility,
2 | SuperAssetLedgerAbility, AssetLedgerItem, AssetLedgerCapability, AssetLedgerInfo,
3 | AssetLedgerItemRecipe, AssetLedgerTransferRecipe, AssetLedgerObjectUpdateRecipe,
4 | AssetLedgerUpdateRecipe } from '@0xcert/scaffold';
5 | export * from './core/ledger';
6 | export * from './lib/capabilities';
7 | export * from './lib/abilities';
8 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-asset-ledger/src/lib/abilities.ts:
--------------------------------------------------------------------------------
1 | import { bigNumberify } from '@0xcert/ethereum-utils';
2 | import { AssetLedgerAbility } from '@0xcert/scaffold';
3 |
4 | /**
5 | * Converts array of abilities into its bitfield representation.
6 | * @param abilities Array of abilitites.
7 | */
8 | export function getBitfieldFromAbilities(abilities: AssetLedgerAbility[]): string {
9 | let bitAbilities = bigNumberify(0);
10 | abilities.forEach((ability) => {
11 | bitAbilities = bitAbilities.add(ability);
12 | });
13 | return bitAbilities.toHexString();
14 | }
15 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-asset-ledger/src/lib/capabilities.ts:
--------------------------------------------------------------------------------
1 | import { AssetLedgerCapability } from '@0xcert/scaffold';
2 |
3 | /**
4 | * Converts capability code into Xcert interface.
5 | * @param capability Capability code.
6 | */
7 | export function getInterfaceCode(capability: AssetLedgerCapability): string {
8 | if (capability == AssetLedgerCapability.DESTROY_ASSET) {
9 | return '0x9d118770';
10 | } else if (capability == AssetLedgerCapability.REVOKE_ASSET) {
11 | return '0x20c5429b';
12 | } else if (capability == AssetLedgerCapability.UPDATE_ASSET) {
13 | return '0x0d04c3b8';
14 | } else if (capability == AssetLedgerCapability.TOGGLE_TRANSFERS) {
15 | return '0xbedb86fb';
16 | } else {
17 | return null;
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-asset-ledger/src/mutations/approve-account.ts:
--------------------------------------------------------------------------------
1 | import { Mutation } from '@0xcert/ethereum-generic-provider';
2 | import { AssetLedger } from '../core/ledger';
3 |
4 | const functionSignature = '0x095ea7b3';
5 | const inputTypes = ['address', 'uint256'];
6 |
7 | /**
8 | * Approves an account for transferring a specific token.
9 | * @param ledger Asset ledger instance.
10 | * @param accountId Account address.
11 | * @param assetId Token id.
12 | */
13 | export default async function(ledger: AssetLedger, accountId: string, assetId: string) {
14 | const attrs = {
15 | from: ledger.provider.accountId,
16 | to: ledger.id,
17 | data: functionSignature + ledger.provider.encoder.encodeParameters(inputTypes, [accountId, assetId]).substr(2),
18 | };
19 | const res = await ledger.provider.post({
20 | method: 'eth_sendTransaction',
21 | params: [attrs],
22 | });
23 | return new Mutation(ledger.provider, res.result, ledger);
24 | }
25 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-asset-ledger/src/mutations/create-asset.ts:
--------------------------------------------------------------------------------
1 | import { Mutation } from '@0xcert/ethereum-generic-provider';
2 | import { AssetLedger } from '../core/ledger';
3 |
4 | const functionSignature = '0xb0e329e4';
5 | const inputTypes = ['address', 'uint256', 'bytes32'];
6 |
7 | /**
8 | * Creates a new asset and gives ownership to the specified account.
9 | * @param ledger Asset ledger instance.
10 | * @param receiverId Address that will receive the new asset.
11 | * @param id Asset id.
12 | * @param imprint Imprint (Merkle tree root) of the asset.
13 | */
14 | export default async function(ledger: AssetLedger, receiverId: string, id: string, imprint: string) {
15 | const attrs = {
16 | from: ledger.provider.accountId,
17 | to: ledger.id,
18 | data: functionSignature + ledger.provider.encoder.encodeParameters(inputTypes, [receiverId, id, imprint]).substr(2),
19 | };
20 | const res = await ledger.provider.post({
21 | method: 'eth_sendTransaction',
22 | params: [attrs],
23 | });
24 | return new Mutation(ledger.provider, res.result, ledger);
25 | }
26 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-asset-ledger/src/mutations/deploy.ts:
--------------------------------------------------------------------------------
1 | import { GenericProvider, Mutation } from '@0xcert/ethereum-generic-provider';
2 | import { AssetLedgerDeployRecipe } from '@0xcert/scaffold';
3 | import { fetchJson } from '@0xcert/utils';
4 | import { getInterfaceCode } from '../lib/capabilities';
5 |
6 | const inputTypes = ['string', 'string', 'string', 'string', 'bytes32', 'bytes4[]'];
7 |
8 | /**
9 | * Deploys a new asset ledger.
10 | * @param provider Instance of the provider.
11 | * @param param1 Data needed to deploy a new asset ledger.
12 | */
13 | export default async function(provider: GenericProvider, { name, symbol, uriPrefix, uriPostfix, schemaId, capabilities }: AssetLedgerDeployRecipe) {
14 | const contract = await fetchJson(provider.assetLedgerSource);
15 | const source = contract.XcertMock.evm.bytecode.object;
16 | const codes = (capabilities || []).map((c) => getInterfaceCode(c));
17 | const attrs = {
18 | from: provider.accountId,
19 | data: `0x${source}${provider.encoder.encodeParameters(inputTypes, [name, symbol, uriPrefix, uriPostfix, `0x${schemaId}`, codes]).substr(2)}`,
20 | };
21 | const res = await provider.post({
22 | method: 'eth_sendTransaction',
23 | params: [attrs],
24 | });
25 | return new Mutation(provider, res.result);
26 | }
27 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-asset-ledger/src/mutations/destroy-asset.ts:
--------------------------------------------------------------------------------
1 | import { Mutation } from '@0xcert/ethereum-generic-provider';
2 | import { AssetLedger } from '../core/ledger';
3 |
4 | const functionSignature = '0x9d118770';
5 | const inputTypes = ['uint256'];
6 |
7 | /**
8 | * Destroys an assets (removes it from blockchain, its history is still accessable).
9 | * @param ledger Asset ledger instance.
10 | * @param assetId Asset id.
11 | */
12 | export default async function(ledger: AssetLedger, assetId: string) {
13 | const attrs = {
14 | from: ledger.provider.accountId,
15 | to: ledger.id,
16 | data: functionSignature + ledger.provider.encoder.encodeParameters(inputTypes, [assetId]).substr(2),
17 | };
18 | const res = await ledger.provider.post({
19 | method: 'eth_sendTransaction',
20 | params: [attrs],
21 | });
22 | return new Mutation(ledger.provider, res.result, ledger);
23 | }
24 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-asset-ledger/src/mutations/grant-abilities.ts:
--------------------------------------------------------------------------------
1 | import { Mutation } from '@0xcert/ethereum-generic-provider';
2 | import { AssetLedger } from '../core/ledger';
3 |
4 | const functionSignature = '0x0ab319e8';
5 | const inputTypes = ['address', 'uint256'];
6 |
7 | /**
8 | * Assigns abilities to an account.
9 | * @param ledger Asset ledger instance.
10 | * @param accountId Account address.
11 | * @param abilities Abilities as number representing bitfield.
12 | */
13 | export default async function(ledger: AssetLedger, accountId: string, abilities: string) {
14 | const attrs = {
15 | from: ledger.provider.accountId,
16 | to: ledger.id,
17 | data: functionSignature + ledger.provider.encoder.encodeParameters(inputTypes, [accountId, abilities]).substr(2),
18 | };
19 | const res = await ledger.provider.post({
20 | method: 'eth_sendTransaction',
21 | params: [attrs],
22 | });
23 | return new Mutation(ledger.provider, res.result, ledger);
24 | }
25 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-asset-ledger/src/mutations/revoke-abilities.ts:
--------------------------------------------------------------------------------
1 | import { Mutation } from '@0xcert/ethereum-generic-provider';
2 | import { AssetLedger } from '../core/ledger';
3 |
4 | const functionSignature = '0xf394b6df';
5 | const inputTypes = ['address', 'uint256'];
6 |
7 | /**
8 | * Revokes(removes) abilities from account.
9 | * @param ledger Asset ledger instance.
10 | * @param accountId Address of the account for which abilities will be revoked.
11 | * @param abilities Abilities as number representing bitfield.
12 | */
13 | export default async function(ledger: AssetLedger, accountId: string, abilities: string) {
14 | const attrs = {
15 | from: ledger.provider.accountId,
16 | to: ledger.id,
17 | data: functionSignature + ledger.provider.encoder.encodeParameters(inputTypes, [accountId, abilities]).substr(2),
18 | };
19 | const res = await ledger.provider.post({
20 | method: 'eth_sendTransaction',
21 | params: [attrs],
22 | });
23 | return new Mutation(ledger.provider, res.result, ledger);
24 | }
25 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-asset-ledger/src/mutations/revoke-asset.ts:
--------------------------------------------------------------------------------
1 | import { Mutation } from '@0xcert/ethereum-generic-provider';
2 | import { AssetLedger } from '../core/ledger';
3 |
4 | const functionSignature = '0x20c5429b';
5 | const inputTypes = ['uint256'];
6 |
7 | /**
8 | * Destroys an asset the same way as destoryAsset does but only an account with revoke ability can
9 | * call it.
10 | * @param ledger Asset ledger instance.
11 | * @param assetId Asset id.
12 | */
13 | export default async function(ledger: AssetLedger, assetId: string) {
14 | const attrs = {
15 | from: ledger.provider.accountId,
16 | to: ledger.id,
17 | data: functionSignature + ledger.provider.encoder.encodeParameters(inputTypes, [assetId]).substr(2),
18 | };
19 | const res = await ledger.provider.post({
20 | method: 'eth_sendTransaction',
21 | params: [attrs],
22 | });
23 | return new Mutation(ledger.provider, res.result, ledger);
24 | }
25 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-asset-ledger/src/mutations/set-abilities.ts:
--------------------------------------------------------------------------------
1 | import { Mutation } from '@0xcert/ethereum-generic-provider';
2 | import { AssetLedger } from '../core/ledger';
3 |
4 | const functionSignature = '0x15ec3b8b';
5 | const inputTypes = ['address', 'uint256'];
6 |
7 | /**
8 | * Revokes(removes) abilities from account.
9 | * @param ledger Asset ledger instance.
10 | * @param accountId Address of the account for which abilities will be revoked.
11 | * @param abilities Abilities as number representing bitfield.
12 | */
13 | export default async function(ledger: AssetLedger, accountId: string, abilities: string) {
14 | const attrs = {
15 | from: ledger.provider.accountId,
16 | to: ledger.id,
17 | data: functionSignature + ledger.provider.encoder.encodeParameters(inputTypes, [accountId, abilities]).substr(2),
18 | };
19 | const res = await ledger.provider.post({
20 | method: 'eth_sendTransaction',
21 | params: [attrs],
22 | });
23 | return new Mutation(ledger.provider, res.result, ledger);
24 | }
25 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-asset-ledger/src/mutations/set-approval-for-all.ts:
--------------------------------------------------------------------------------
1 | import { Mutation } from '@0xcert/ethereum-generic-provider';
2 | import { AssetLedger } from '../core/ledger';
3 |
4 | const functionSignature = '0xa22cb465';
5 | const inputTypes = ['address', 'bool'];
6 |
7 | /**
8 | * Sets approval for an account to have control over all assets.
9 | * @param ledger Asset ledger instance.
10 | * @param accountId Account id.
11 | * @param approved Is approved or not.
12 | */
13 | export default async function(ledger: AssetLedger, accountId: string, approved: boolean) {
14 | const attrs = {
15 | from: ledger.provider.accountId,
16 | to: ledger.id,
17 | data: functionSignature + ledger.provider.encoder.encodeParameters(inputTypes, [accountId, approved]).substr(2),
18 | };
19 | const res = await ledger.provider.post({
20 | method: 'eth_sendTransaction',
21 | params: [attrs],
22 | });
23 | return new Mutation(ledger.provider, res.result, ledger);
24 | }
25 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-asset-ledger/src/mutations/set-enabled.ts:
--------------------------------------------------------------------------------
1 | import { Mutation } from '@0xcert/ethereum-generic-provider';
2 | import { AssetLedger } from '../core/ledger';
3 |
4 | const functionSignature = '0xbedb86fb';
5 | const inputTypes = ['bool'];
6 |
7 | /**
8 | * Allows or freezes the option of transferring assets in specifies asset ledger.
9 | * @param ledger Asset ledger instance.
10 | * @param enabled Enable state.
11 | */
12 | export default async function(ledger: AssetLedger, enabled: boolean) {
13 | const attrs = {
14 | from: ledger.provider.accountId,
15 | to: ledger.id,
16 | data: functionSignature + ledger.provider.encoder.encodeParameters(inputTypes, [!enabled]).substr(2),
17 | };
18 | const res = await ledger.provider.post({
19 | method: 'eth_sendTransaction',
20 | params: [attrs],
21 | });
22 | return new Mutation(ledger.provider, res.result, ledger);
23 | }
24 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-asset-ledger/src/mutations/transfer.ts:
--------------------------------------------------------------------------------
1 | import { Mutation } from '@0xcert/ethereum-generic-provider';
2 | import { AssetLedger } from '../core/ledger';
3 |
4 | const functionSignature = '0x23b872dd';
5 | const inputTypes = ['address', 'address', 'uint256'];
6 |
7 | /**
8 | * Transfers asset from one account to another.
9 | * @param ledger Asset ledger instance.
10 | * @param receiverId Address that will receive the asset.
11 | * @param id Asset id.
12 | */
13 | export default async function(ledger: AssetLedger, senderId: string, receiverId: string, id: string) {
14 | const attrs = {
15 | from: ledger.provider.accountId,
16 | to: ledger.id,
17 | data: functionSignature + ledger.provider.encoder.encodeParameters(inputTypes, [senderId, receiverId, id]).substr(2),
18 | };
19 | const res = await ledger.provider.post({
20 | method: 'eth_sendTransaction',
21 | params: [attrs],
22 | });
23 | return new Mutation(ledger.provider, res.result, ledger);
24 | }
25 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-asset-ledger/src/mutations/update-asset.ts:
--------------------------------------------------------------------------------
1 | import { Mutation } from '@0xcert/ethereum-generic-provider';
2 | import { AssetLedger } from '../core/ledger';
3 |
4 | const functionSignature = '0x0d04c3b8';
5 | const inputTypes = ['uint256', 'bytes32'];
6 |
7 | /**
8 | * Updates asset imprint.
9 | * @param ledger Asset ledger instance.
10 | * @param assetId Asset id.
11 | * @param imprint New imprint.
12 | */
13 | export default async function(ledger: AssetLedger, assetId: string, imprint: string) {
14 | const attrs = {
15 | from: ledger.provider.accountId,
16 | to: ledger.id,
17 | data: functionSignature + ledger.provider.encoder.encodeParameters(inputTypes, [assetId, imprint]).substr(2),
18 | };
19 | const res = await ledger.provider.post({
20 | method: 'eth_sendTransaction',
21 | params: [attrs],
22 | });
23 | return new Mutation(ledger.provider, res.result, ledger);
24 | }
25 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-asset-ledger/src/mutations/update.ts:
--------------------------------------------------------------------------------
1 | import { Mutation } from '@0xcert/ethereum-generic-provider';
2 | import { AssetLedger } from '../core/ledger';
3 |
4 | const functionSignature = '0x89b73ec0';
5 | const inputTypes = ['string', 'string'];
6 |
7 | /**
8 | * Updates asset ledger URI base.
9 | * @param ledger Asset ledger instance.
10 | * @param uriPrefix New URI base.
11 | */
12 | export default async function(ledger: AssetLedger, uriPrefix: string, uriPostfix: string) {
13 | const attrs = {
14 | from: ledger.provider.accountId,
15 | to: ledger.id,
16 | data: functionSignature + ledger.provider.encoder.encodeParameters(inputTypes, [uriPrefix, uriPostfix]).substr(2),
17 | };
18 | const res = await ledger.provider.post({
19 | method: 'eth_sendTransaction',
20 | params: [attrs],
21 | });
22 | return new Mutation(ledger.provider, res.result, ledger);
23 | }
24 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-asset-ledger/src/queries/get-account-asset-id-at.ts:
--------------------------------------------------------------------------------
1 | import { AssetLedger } from '../core/ledger';
2 |
3 | const functionSignature = '0x2f745c59';
4 | const inputTypes = ['address', 'uint256'];
5 | const outputTypes = ['uint256'];
6 |
7 | /**
8 | * Get the ID of the asset at specified index for specified account
9 | * @param ledger Asset ledger instance.
10 | * @param accountId Account address.
11 | * @param index Asset index.
12 | */
13 | export default async function(ledger: AssetLedger, accountId: string, index: number) {
14 | try {
15 | const attrs = {
16 | to: ledger.id,
17 | data: functionSignature + ledger.provider.encoder.encodeParameters(inputTypes, [accountId, index]).substr(2),
18 | };
19 | const res = await ledger.provider.post({
20 | method: 'eth_call',
21 | params: [attrs, 'latest'],
22 | });
23 | return ledger.provider.encoder.decodeParameters(outputTypes, res.result)[0];
24 | } catch (error) {
25 | ledger.provider.log(error);
26 | return null;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-asset-ledger/src/queries/get-approved-account.ts:
--------------------------------------------------------------------------------
1 | import { AssetLedger } from '../core/ledger';
2 | import kittyIndexToApproved from './kitty-index-to-approved';
3 |
4 | const functionSignature = '0x081812fc';
5 | const inputTypes = ['uint256'];
6 | const outputTypes = ['address'];
7 |
8 | /**
9 | * Gets the account that is approved for transferring a specific asset.
10 | * @param ledger Asset ledger instance.
11 | * @param assetId Asset id.
12 | */
13 | export default async function(ledger: AssetLedger, assetId: string) {
14 | try {
15 | const attrs = {
16 | to: ledger.id,
17 | data: functionSignature + ledger.provider.encoder.encodeParameters(inputTypes, [assetId]).substr(2),
18 | };
19 | const res = await ledger.provider.post({
20 | method: 'eth_call',
21 | params: [attrs, 'latest'],
22 | });
23 | return ledger.provider.encoder.decodeParameters(outputTypes, res.result)[0];
24 | } catch (error) {
25 | ledger.provider.log(error);
26 | return kittyIndexToApproved(ledger, assetId);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-asset-ledger/src/queries/get-asset-account.ts:
--------------------------------------------------------------------------------
1 | import { AssetLedger } from '../core/ledger';
2 |
3 | const functionSignature = '0x6352211e';
4 | const inputTypes = ['uint256'];
5 | const outputTypes = ['address'];
6 |
7 | /**
8 | * Gets the account that owns the specific asset.
9 | * @param ledger Asset ledger instance.
10 | * @param assetId Asset id.
11 | */
12 | export default async function(ledger: AssetLedger, assetId: string) {
13 | try {
14 | const attrs = {
15 | to: ledger.id,
16 | data: functionSignature + ledger.provider.encoder.encodeParameters(inputTypes, [assetId]).substr(2),
17 | };
18 | const res = await ledger.provider.post({
19 | method: 'eth_call',
20 | params: [attrs, 'latest'],
21 | });
22 | return ledger.provider.encoder.decodeParameters(outputTypes, res.result)[0];
23 | } catch (error) {
24 | ledger.provider.log(error);
25 | return null;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-asset-ledger/src/queries/get-asset-id-at.ts:
--------------------------------------------------------------------------------
1 | import { AssetLedger } from '../core/ledger';
2 |
3 | const functionSignature = '0x4f6ccce7';
4 | const inputTypes = ['uint256'];
5 | const outputTypes = ['uint256'];
6 |
7 | /**
8 | * Get the ID of the asset at specified index
9 | * @param ledger Asset ledger instance.
10 | * @param index Asset index.
11 | */
12 | export default async function(ledger: AssetLedger, index: number) {
13 | try {
14 | const attrs = {
15 | to: ledger.id,
16 | data: functionSignature + ledger.provider.encoder.encodeParameters(inputTypes, [index]).substr(2),
17 | };
18 | const res = await ledger.provider.post({
19 | method: 'eth_call',
20 | params: [attrs, 'latest'],
21 | });
22 | return ledger.provider.encoder.decodeParameters(outputTypes, res.result)[0];
23 | } catch (error) {
24 | ledger.provider.log(error);
25 | return null;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-asset-ledger/src/queries/get-balance.ts:
--------------------------------------------------------------------------------
1 | import { AssetLedger } from '../core/ledger';
2 |
3 | const functionSignature = '0x70a08231';
4 | const inputTypes = ['address'];
5 | const outputTypes = ['uint256'];
6 |
7 | /**
8 | * Gets the amount of assets the account owns.
9 | * @param ledger Asset ledger instance.
10 | * @param accountId Account id.
11 | */
12 | export default async function(ledger: AssetLedger, accountId: string) {
13 | try {
14 | const attrs = {
15 | to: ledger.id,
16 | data: functionSignature + ledger.provider.encoder.encodeParameters(inputTypes, [accountId]).substr(2),
17 | };
18 | const res = await ledger.provider.post({
19 | method: 'eth_call',
20 | params: [attrs, 'latest'],
21 | });
22 | return ledger.provider.encoder.decodeParameters(outputTypes, res.result)[0].toString();
23 | } catch (error) {
24 | ledger.provider.log(error);
25 | return null;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-asset-ledger/src/queries/is-approved-for-all.ts:
--------------------------------------------------------------------------------
1 | import { AssetLedger } from '../core/ledger';
2 |
3 | const functionSignature = '0xe985e9c5';
4 | const inputTypes = ['address', 'address'];
5 | const outputTypes = ['bool'];
6 |
7 | /**
8 | * Checks if an account is approved for controling all assets of another account.
9 | * @param ledger Asset ledger instance.
10 | * @param accountId Account id.
11 | * @param operatorId Operator account id.
12 | */
13 | export default async function(ledger: AssetLedger, accountId: string, operatorId: string) {
14 | try {
15 | const attrs = {
16 | to: ledger.id,
17 | data: functionSignature + ledger.provider.encoder.encodeParameters(inputTypes, [accountId, operatorId]).substr(2),
18 | };
19 | const res = await ledger.provider.post({
20 | method: 'eth_call',
21 | params: [attrs, 'latest'],
22 | });
23 | return ledger.provider.encoder.decodeParameters(outputTypes, res.result)[0];
24 | } catch (error) {
25 | ledger.provider.log(error);
26 | return null;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-asset-ledger/src/queries/is-enabled.ts:
--------------------------------------------------------------------------------
1 | import { AssetLedger } from '../core/ledger';
2 |
3 | const functionSignature = '0xb187bd26';
4 | const inputTypes = [];
5 | const outputTypes = ['bool'];
6 |
7 | /**
8 | * Checks if the transfer is enabled.
9 | * @param ledger Asset ledger instance.
10 | */
11 | export default async function(ledger: AssetLedger) {
12 | try {
13 | const attrs = {
14 | to: ledger.id,
15 | data: functionSignature + ledger.provider.encoder.encodeParameters(inputTypes, []).substr(2),
16 | };
17 | const res = await ledger.provider.post({
18 | method: 'eth_call',
19 | params: [attrs, 'latest'],
20 | });
21 | return !ledger.provider.encoder.decodeParameters(outputTypes, res.result)[0];
22 | } catch (error) {
23 | ledger.provider.log(error);
24 | return null;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-asset-ledger/src/queries/kitty-index-to-approved.ts:
--------------------------------------------------------------------------------
1 | import { AssetLedger } from '../core/ledger';
2 |
3 | const functionSignature = '0x481af3d3';
4 | const inputTypes = ['uint256'];
5 | const outputTypes = ['address'];
6 |
7 | /**
8 | * Gets the account that is approved for transferring a specific asset.
9 | * @param ledger Asset ledger instance.
10 | * @param assetId Asset id.
11 | */
12 | export default async function(ledger: AssetLedger, assetId: string) {
13 | try {
14 | const attrs = {
15 | to: ledger.id,
16 | data: functionSignature + ledger.provider.encoder.encodeParameters(inputTypes, [assetId]).substr(2),
17 | };
18 | const res = await ledger.provider.post({
19 | method: 'eth_call',
20 | params: [attrs, 'latest'],
21 | });
22 | return ledger.provider.encoder.decodeParameters(outputTypes, res.result)[0];
23 | } catch (error) {
24 | ledger.provider.log(error);
25 | return null;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-asset-ledger/src/tests/index.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@specron/spec';
2 | import * as ledger from '..';
3 |
4 | const spec = new Spec();
5 |
6 | spec.test('exposes objects', (ctx) => {
7 | ctx.true(!!ledger.AssetLedger);
8 | ctx.true(!!ledger.GeneralAssetLedgerAbility);
9 | ctx.true(!!ledger.SuperAssetLedgerAbility);
10 | ctx.true(!!ledger.AssetLedgerCapability);
11 | });
12 |
13 | export default spec;
14 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-asset-ledger/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "es6",
5 | "noImplicitAny": false,
6 | "removeComments": true,
7 | "sourceMap": true,
8 | "outDir": "dist",
9 | "declaration": true,
10 | "experimentalDecorators": true,
11 | "allowSyntheticDefaultImports": true
12 | }
13 | }
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-erc20-contracts/.solhint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "solhint:default",
3 | "rules": {
4 | "max-line-length": ["warn", 100]
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-erc20-contracts/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | > Smart contract implementation of the ERC-20 standard on the Ethereum blockchain.
4 |
5 | The [0xcert Framework](https://docs.0xcert.org) is a free and open-source JavaScript library that provides tools for building powerful decentralized applications. Please refer to the [official documentation](https://docs.0xcert.org) for more details.
6 |
7 | This module is one of the bricks of the [0xcert Framework](https://docs.0xcert.org). It's written with [TypeScript](https://www.typescriptlang.org) and it's actively maintained. The source code is available on [GitHub](https://github.com/0xcert/framework) where you can also find our [issue tracker](https://github.com/0xcert/framework/issues).
8 |
9 | # Build
10 |
11 | By default, the contracts in this package are built for Constantinople EVM. If you would like to use these smart contracts for `Wanchain` or other blockchains using EVM for a different version, you will need to rebuild them for the desired version.
12 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-erc20-contracts/nodemon.json:
--------------------------------------------------------------------------------
1 | {
2 | "ignore": ["dist/*"],
3 | "ext": "js,ts"
4 | }
5 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-erc20-contracts/src/contracts/migration-receiver.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 |
3 | pragma solidity 0.8.6;
4 |
5 | /**
6 | * Interface for accepting migrations.
7 | */
8 | interface MigrationReceiver {
9 |
10 | /**
11 | * @dev Handle the receipt of a migration. The dapp token calls this function on the migration
12 | * address when migrating. Return of other than the magic value MUST result in the transaction
13 | * being reverted. Returns `bytes4(keccak256("onMigrationReceived(address,uint256)"))` unless
14 | * throwing.
15 | * @param _migrator The address which called `migrate` function.
16 | * @param _amount Amount of tokens being migrated.
17 | * @return magicValue Returns `bytes4(keccak256("onMigrationReceived(address,uint256)"))`.
18 | */
19 | function onMigrationReceived(
20 | address _migrator,
21 | uint256 _amount
22 | )
23 | external
24 | returns(bytes4 magicValue);
25 | }
26 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-erc20-contracts/src/contracts/mocks/dapp-token-mock.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 |
3 | pragma solidity 0.8.6;
4 |
5 | import "../dapp-token.sol";
6 |
7 | /**
8 | * @dev This is an example contract implementation of DappToken.
9 | */
10 | contract DappTokenMock is
11 | DappToken
12 | {
13 | constructor(
14 | string memory _name,
15 | string memory _symbol,
16 | uint8 _decimals,
17 | address _barteredToken,
18 | address _tokenTransferProxy
19 | )
20 | {
21 | tokenName = _name;
22 | tokenSymbol = _symbol;
23 | tokenDecimals = _decimals;
24 | barteredToken = ERC20(_barteredToken);
25 | tokenTransferProxy = _tokenTransferProxy;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-erc20-contracts/src/contracts/mocks/token-mock.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 |
3 | pragma solidity 0.8.6;
4 |
5 | import "../token.sol";
6 |
7 | /**
8 | * @dev This is an example contract implementation of Token.
9 | */
10 | contract TokenMock is
11 | Token
12 | {
13 | constructor(
14 | string memory _name,
15 | string memory _symbol,
16 | uint8 _decimals,
17 | uint256 _supply
18 | )
19 | {
20 | tokenName = _name;
21 | tokenSymbol = _symbol;
22 | tokenDecimals = _decimals;
23 | tokenTotalSupply = _supply;
24 | balances[msg.sender] = tokenTotalSupply;
25 | emit Transfer(address(0), msg.sender, tokenTotalSupply);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-erc20-contracts/src/contracts/zxc-burner.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 |
3 | pragma solidity 0.8.6;
4 |
5 | import "./zxc.sol";
6 |
7 | /**
8 | * @title This is a contract that allows anyone to burn ZXC tokens.
9 | * @dev This contract has ownership over ZXC smart contract and as such allows anyone to burn their
10 | * ZXC tokens.
11 | */
12 | contract ZxcBurner
13 | {
14 | /**
15 | * @dev ZXC token contract.
16 | */
17 | Zxc zxcToken;
18 |
19 | /**
20 | * @param _zxcAddress ZXC contract address.
21 | */
22 | constructor(address _zxcAddress)
23 | {
24 | zxcToken = Zxc(_zxcAddress);
25 | }
26 |
27 | /**
28 | * @dev Claims ownership of ZXC token contract.
29 | */
30 | function claim()
31 | external
32 | {
33 | zxcToken.claimOwnership();
34 | }
35 |
36 | /**
37 | * @dev Allows anyone to burn tokens that they own. First you need to approve this contract for
38 | * token amount then call this function with the amount you want to burn.
39 | * @param _value Amount of tokens you want to burn.
40 | */
41 | function burn(
42 | uint256 _value
43 | )
44 | external
45 | {
46 | zxcToken.transferFrom(msg.sender, address(this), _value);
47 | zxcToken.burn(_value);
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-erc20-contracts/src/core/types.ts:
--------------------------------------------------------------------------------
1 | export enum DappTokenAbilities {
2 | MANAGE_ABILITIES = 1,
3 | ALLOW_MANAGE_ABILITIES = 2,
4 | SET_WHITELISTED = 16,
5 | SET_MIGRATE_ADDRESS = 32,
6 | SET_MIGRATION_CALLER = 64,
7 | }
8 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-erc20-contracts/src/index.ts:
--------------------------------------------------------------------------------
1 | export * from './core/types';
2 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-erc20-contracts/src/tests/helpers/common.ts:
--------------------------------------------------------------------------------
1 | export function getCurrentTime() {
2 | return Math.floor((new Date().getTime() / 1000));
3 | }
4 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-erc20-contracts/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "es6",
5 | "noImplicitAny": false,
6 | "removeComments": true,
7 | "sourceMap": true,
8 | "outDir": "dist",
9 | "declaration": true,
10 | "experimentalDecorators": true,
11 | "allowSyntheticDefaultImports": true
12 | }
13 | }
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-erc721-contracts/.solhint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "solhint:default",
3 | "rules": {
4 | "max-line-length": ["warn", 100]
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-erc721-contracts/nodemon.json:
--------------------------------------------------------------------------------
1 | {
2 | "ignore": ["dist/*"],
3 | "ext": "js,ts"
4 | }
5 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-erc721-contracts/src/contracts/erc721-metadata.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 |
3 | pragma solidity 0.8.6;
4 |
5 | /**
6 | * @dev Optional metadata extension for ERC-721 non-fungible token standard.
7 | * See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md.
8 | */
9 | interface ERC721Metadata
10 | {
11 |
12 | /**
13 | * @dev Returns a descriptive name for a collection of NFTs in this contract.
14 | * @return _name Representing name.
15 | */
16 | function name()
17 | external
18 | view
19 | returns (string memory _name);
20 |
21 | /**
22 | * @dev Returns a abbreviated name for a collection of NFTs in this contract.
23 | * @return _symbol Representing symbol.
24 | */
25 | function symbol()
26 | external
27 | view
28 | returns (string memory _symbol);
29 |
30 | /**
31 | * @dev Returns a distinct Uniform Resource Identifier (URI) for a given asset. It Throws if
32 | * `_tokenId` is not a valid NFT. URIs are defined in RFC3986. The URI may point to a JSON file
33 | * that conforms to the "ERC721 Metadata JSON Schema".
34 | * @return URI of _tokenId.
35 | */
36 | function tokenURI(uint256 _tokenId)
37 | external
38 | view
39 | returns (string memory);
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-erc721-contracts/src/contracts/mocks/nf-token-enumerable-mock.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 |
3 | pragma solidity 0.8.6;
4 |
5 | import "../../contracts/nf-token-enumerable.sol";
6 | import "@0xcert/ethereum-utils-contracts/src/contracts/permission/claimable.sol";
7 |
8 | /**
9 | * @dev This is an example contract implementation of NFToken with enumerable extension.
10 | */
11 | contract NFTokenEnumerableMock is
12 | NFTokenEnumerable,
13 | Claimable
14 | {
15 |
16 | /**
17 | * @dev Creates a new NFT.
18 | * @param _to The address that will own the created NFT.
19 | * @param _tokenId of the NFT to be created by the msg.sender.
20 | */
21 | function create(
22 | address _to,
23 | uint256 _tokenId
24 | )
25 | external
26 | onlyOwner
27 | {
28 | super._create(_to, _tokenId);
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-erc721-contracts/src/contracts/mocks/nf-token-mock.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 |
3 | pragma solidity 0.8.6;
4 |
5 | import "../nf-token.sol";
6 | import "@0xcert/ethereum-utils-contracts/src/contracts/permission/claimable.sol";
7 |
8 | /**
9 | * @dev This is an example contract implementation of NFToken.
10 | */
11 | contract NFTokenMock is
12 | NFToken,
13 | Claimable
14 | {
15 |
16 | /**
17 | * @dev Creates a new NFT.
18 | * @param _to The address that will own the created NFT.
19 | * @param _tokenId of the NFT to be created by the msg.sender.
20 | */
21 | function create(
22 | address _to,
23 | uint256 _tokenId
24 | )
25 | external
26 | onlyOwner
27 | {
28 | super._create(_to, _tokenId);
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-erc721-contracts/src/tests/mocks/nf-token-metadata-test-mock.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 |
3 | pragma solidity 0.8.6;
4 |
5 | import "../../contracts/mocks/nf-token-metadata-mock.sol";
6 |
7 | contract NFTokenMetadataTestMock is
8 | NFTokenMetadataMock
9 | {
10 |
11 | constructor(
12 | string memory _name,
13 | string memory _symbol,
14 | string memory _uriPrefix,
15 | string memory _uriPostfix
16 | )
17 | NFTokenMetadataMock(_name, _symbol, _uriPrefix, _uriPostfix)
18 | {}
19 |
20 | /**
21 | * @dev Removes a NFT from owner.
22 | * @param _tokenId Which NFT we want to remove.
23 | */
24 | function destroy(
25 | uint256 _tokenId
26 | )
27 | external
28 | override
29 | onlyOwner
30 | {
31 | super._destroy(_tokenId);
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-erc721-contracts/src/tests/mocks/nf-token-receiver-test-mock.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 |
3 | pragma solidity 0.8.6;
4 | import "../../contracts/erc721-token-receiver.sol";
5 |
6 | contract NFTokenReceiverTestMock is
7 | ERC721TokenReceiver
8 | {
9 |
10 | function onERC721Received(
11 | address _operator,
12 | address _from,
13 | uint256 _tokenId,
14 | bytes calldata _data
15 | )
16 | external
17 | override
18 | pure
19 | returns(bytes4)
20 | {
21 | _operator;
22 | _from;
23 | _tokenId;
24 | _data;
25 | return 0x150b7a02;
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-erc721-contracts/src/tests/mocks/nf-token-test-mock.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 |
3 | pragma solidity 0.8.6;
4 |
5 | import "../../contracts/mocks/nf-token-mock.sol";
6 |
7 | contract NFTokenTestMock is
8 | NFTokenMock
9 | {
10 |
11 | /**
12 | * @dev Removes an NFT from owner.
13 | * @param _tokenId Which NFT we want to remove.
14 | */
15 | function destroy(
16 | uint256 _tokenId
17 | )
18 | external
19 | onlyOwner
20 | {
21 | super._destroy(_tokenId);
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-erc721-contracts/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "es6",
5 | "noImplicitAny": false,
6 | "removeComments": true,
7 | "sourceMap": true,
8 | "outDir": "dist",
9 | "declaration": true,
10 | "experimentalDecorators": true,
11 | "allowSyntheticDefaultImports": true
12 | }
13 | }
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-gateway-contracts/.solhint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "solhint:default",
3 | "rules": {
4 | "max-line-length": ["warn", 100]
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-gateway-contracts/nodemon.json:
--------------------------------------------------------------------------------
1 | {
2 | "ignore": ["dist/*"],
3 | "ext": "js,ts"
4 | }
5 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-gateway-contracts/src/core/types.ts:
--------------------------------------------------------------------------------
1 | export enum ActionsGatewayAbilities {
2 | MANAGE_ABILITIES = 1,
3 | ALLOW_MANAGE_ABILITIES = 2,
4 | SET_PROXIES = 16,
5 | }
6 |
7 | export enum XcertDeployGateway {
8 | MANAGE_ABILITIES = 1,
9 | ALLOW_MANAGE_ABILITIES = 2,
10 | SET_PROXY = 16,
11 | }
12 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-gateway-contracts/src/index.ts:
--------------------------------------------------------------------------------
1 | export * from './core/types';
2 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-gateway-contracts/src/tests/helpers/common.ts:
--------------------------------------------------------------------------------
1 | export function getCurrentTime() {
2 | return Math.floor((new Date().getTime() / 1000));
3 | }
4 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-gateway-contracts/src/tests/helpers/signature.ts:
--------------------------------------------------------------------------------
1 | export async function getSignature(web3: any, claim: string, address: string) {
2 | const signature = await web3.eth.sign(claim, address);
3 | return {
4 | r: signature.substr(0, 66),
5 | s: `0x${signature.substr(66, 64)}`,
6 | v: parseInt(`0x${signature.substr(130, 2)}`) + 27,
7 | kind: 0,
8 | };
9 | }
10 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-gateway-contracts/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "es6",
5 | "noImplicitAny": false,
6 | "removeComments": true,
7 | "sourceMap": true,
8 | "outDir": "dist",
9 | "declaration": true,
10 | "experimentalDecorators": true,
11 | "allowSyntheticDefaultImports": true
12 | }
13 | }
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-gateway/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | > Order gateway module for executing atomic operations on the Ethereum blockchain.
4 |
5 | The [0xcert Framework](https://docs.0xcert.org) is a free and open-source JavaScript library that provides tools for building powerful decentralized applications. Please refer to the [official documentation](https://docs.0xcert.org) for more details.
6 |
7 | This module is one of the bricks of the [0xcert Framework](https://docs.0xcert.org). It's written with [TypeScript](https://www.typescriptlang.org) and it's actively maintained. The source code is available on [GitHub](https://github.com/0xcert/framework) where you can also find our [issue tracker](https://github.com/0xcert/framework/issues).
8 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-gateway/nodemon.json:
--------------------------------------------------------------------------------
1 | {
2 | "ignore": ["dist/*"],
3 | "ext": "js,ts"
4 | }
5 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-gateway/src/core/types.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Order gateway proxy kinds.
3 | */
4 | export enum ProxyKind {
5 | CREATE_ASSET = 0,
6 | TRANSFER_TOKEN = 1,
7 | TRANSFER_ASSET = 2,
8 | UPDATE_ASSET = 3,
9 | MANAGE_ABILITIES = 4,
10 | DESTROY_ASSET = 5,
11 | }
12 |
13 | /**
14 | * Order gateway proxy ids.
15 | */
16 | export enum ProxyId {
17 | XCERT_CREATE = 0,
18 | TOKEN_TRANSFER = 1,
19 | NFTOKEN_TRANSFER = 2,
20 | NFTOKEN_SAFE_TRANSFER = 3,
21 | XCERT_UPDATE = 4,
22 | MANAGE_ABILITIES = 5,
23 | XCERT_BURN = 6,
24 | }
25 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-gateway/src/index.ts:
--------------------------------------------------------------------------------
1 | export * from '@0xcert/scaffold/dist/core/gateway';
2 | export * from './core/gateway';
3 | export * from './core/types';
4 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-gateway/src/mutations/actions-order/cancel.ts:
--------------------------------------------------------------------------------
1 | import { Mutation } from '@0xcert/ethereum-generic-provider';
2 | import { ActionsOrder } from '@0xcert/scaffold';
3 | import { Gateway } from '../../core/gateway';
4 | import { createRecipeTuple } from '../../lib/actions-order';
5 |
6 | const functionSignature = '0x38a9bfcd';
7 | const inputTypes = ['tuple(address[], tuple[](uint32, address, bytes), uint256, uint256)'];
8 |
9 | /**
10 | * Cancels already submited order on the network.
11 | * @param gateway Order gateway instance.
12 | * @param order Order data.
13 | */
14 | export default async function(gateway: Gateway, order: ActionsOrder) {
15 | const recipeTuple = createRecipeTuple(gateway, order);
16 | const attrs = {
17 | from: gateway.provider.accountId,
18 | to: gateway.config.actionsOrderId,
19 | data: functionSignature + gateway.provider.encoder.encodeParameters(inputTypes, [recipeTuple]).substr(2),
20 | };
21 | const res = await gateway.provider.post({
22 | method: 'eth_sendTransaction',
23 | params: [attrs],
24 | });
25 | return new Mutation(gateway.provider, res.result, gateway);
26 | }
27 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-gateway/src/mutations/actions-order/perform.ts:
--------------------------------------------------------------------------------
1 | import { Mutation } from '@0xcert/ethereum-generic-provider';
2 | import { ActionsOrder } from '@0xcert/scaffold';
3 | import { Gateway } from '../../core/gateway';
4 | import { createRecipeTuple, createSignatureTuple } from '../../lib/actions-order';
5 |
6 | const inputTypes = ['tuple(address[], tuple[](uint32, address, bytes), uint256, uint256)', 'tuple[](bytes32, bytes32, uint8, uint8)'];
7 | const functionSignature = '0xb438bae1';
8 | /**
9 | * Submits the provided order to the network.
10 | * @param gateway Order gateway instance.
11 | * @param order Order data.
12 | * @param claim Claim data.
13 | */
14 | export default async function(gateway: Gateway, order: ActionsOrder, claim: string[]) {
15 | const recipeTuple = createRecipeTuple(gateway, order);
16 | const signatureTuple = createSignatureTuple(claim);
17 | const attrs = {
18 | from: gateway.provider.accountId,
19 | to: gateway.config.actionsOrderId,
20 | data: functionSignature + gateway.provider.encoder.encodeParameters(inputTypes, [recipeTuple, signatureTuple]).substr(2),
21 | };
22 | const res = await gateway.provider.post({
23 | method: 'eth_sendTransaction',
24 | params: [attrs],
25 | });
26 | return new Mutation(gateway.provider, res.result, gateway);
27 | }
28 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-gateway/src/mutations/asset-ledger-deploy-order/cancel.ts:
--------------------------------------------------------------------------------
1 | import { Mutation } from '@0xcert/ethereum-generic-provider';
2 | import { AssetLedgerDeployOrder } from '@0xcert/scaffold';
3 | import { Gateway } from '../../core/gateway';
4 | import { createRecipeTuple } from '../../lib/asset-ledger-deploy-order';
5 |
6 | const functionSignature = '0x9ebbc600';
7 | const inputTypes = ['tuple(address, address, tuple(string, string, string, string, bytes32, bytes4[], address), tuple(address, address, uint256), uint256, uint256)'];
8 |
9 | /**
10 | * Cancels already submited deploy on the network.
11 | * @param gateway Deploy gateway instance.
12 | * @param deploy Deploy data.
13 | */
14 | export default async function(gateway: Gateway, order: AssetLedgerDeployOrder) {
15 | const recipeTuple = createRecipeTuple(order);
16 | const attrs = {
17 | from: gateway.provider.accountId,
18 | to: gateway.config.assetLedgerDeployOrderId,
19 | data: functionSignature + gateway.provider.encoder.encodeParameters(inputTypes, [recipeTuple]).substr(2),
20 | };
21 | const res = await gateway.provider.post({
22 | method: 'eth_sendTransaction',
23 | params: [attrs],
24 | });
25 | return new Mutation(gateway.provider, res.result, gateway);
26 | }
27 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-gateway/src/mutations/asset-set-operator-order/cancel.ts:
--------------------------------------------------------------------------------
1 | import { Mutation } from '@0xcert/ethereum-generic-provider';
2 | import { AssetSetOperatorOrder } from '@0xcert/scaffold';
3 | import { Gateway } from '../../core/gateway';
4 | import { getOrderInputParams } from '../../lib/asset-set-operator-order';
5 |
6 | const functionSignature = '0xce4e3273';
7 | const inputTypes = ['address', 'address', 'bool', 'address', 'uint256', 'address', 'uint256', 'uint256'];
8 |
9 | /**
10 | * Submits the provided deploy to the network.
11 | * @param gateway Deploy gateway instance.
12 | * @param order Asset set operator data.
13 | * @param claim Claim data.
14 | */
15 | export default async function(gateway: Gateway, order: AssetSetOperatorOrder) {
16 | const params = getOrderInputParams(order);
17 | const attrs = {
18 | from: gateway.provider.accountId,
19 | to: order.ledgerId,
20 | data: functionSignature + gateway.provider.encoder.encodeParameters(inputTypes, params).substr(2),
21 | };
22 | const res = await gateway.provider.post({
23 | method: 'eth_sendTransaction',
24 | params: [attrs],
25 | });
26 | return new Mutation(gateway.provider, res.result, gateway);
27 | }
28 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-gateway/src/mutations/dapp-value-approve-order/cancel.ts:
--------------------------------------------------------------------------------
1 | import { Mutation } from '@0xcert/ethereum-generic-provider';
2 | import { DappValueApproveOrder } from '@0xcert/scaffold';
3 | import { Gateway } from '../../core/gateway';
4 | import { getOrderInputParams } from '../../lib/dapp-value-approve-order';
5 |
6 | const functionSignature = '0xeb92ad66';
7 | const inputTypes = ['address', 'uint256', 'address', 'uint256', 'uint256', 'uint256'];
8 |
9 | /**
10 | * Submits the provided deploy to the network.
11 | * @param gateway Deploy gateway instance.
12 | * @param order Order data.
13 | * @param claim Claim data.
14 | */
15 | export default async function(gateway: Gateway, order: DappValueApproveOrder) {
16 | const params = getOrderInputParams(order);
17 | params.shift();
18 | const attrs = {
19 | from: gateway.provider.accountId,
20 | to: order.ledgerId,
21 | data: functionSignature + gateway.provider.encoder.encodeParameters(inputTypes, params).substr(2),
22 | };
23 | const res = await gateway.provider.post({
24 | method: 'eth_sendTransaction',
25 | params: [attrs],
26 | });
27 | return new Mutation(gateway.provider, res.result, gateway);
28 | }
29 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-gateway/src/mutations/value-ledger-deploy-order/cancel.ts:
--------------------------------------------------------------------------------
1 | import { Mutation } from '@0xcert/ethereum-generic-provider';
2 | import { ValueLedgerDeployOrder } from '@0xcert/scaffold';
3 | import { Gateway } from '../../core/gateway';
4 | import { createRecipeTuple } from '../../lib/value-ledger-deploy-order';
5 |
6 | const functionSignature = '0x4e4631e7';
7 | const inputTypes = ['tuple(address, address, tuple(string, string, uint256, uint8, address), tuple(address, address, uint256), uint256, uint256)'];
8 |
9 | /**
10 | * Cancels already submited deploy on the network.
11 | * @param gateway Deploy gateway instance.
12 | * @param deploy Deploy data.
13 | */
14 | export default async function(gateway: Gateway, order: ValueLedgerDeployOrder) {
15 | const recipeTuple = createRecipeTuple(order);
16 | const attrs = {
17 | from: gateway.provider.accountId,
18 | to: gateway.config.valueLedgerDeployOrderId,
19 | data: functionSignature + gateway.provider.encoder.encodeParameters(inputTypes, [recipeTuple]).substr(2),
20 | };
21 | const res = await gateway.provider.post({
22 | method: 'eth_sendTransaction',
23 | params: [attrs],
24 | });
25 | return new Mutation(gateway.provider, res.result, gateway);
26 | }
27 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-gateway/src/queries/actions-order/claim-eth-sign.ts:
--------------------------------------------------------------------------------
1 | import { ActionsOrder } from '@0xcert/scaffold';
2 | import { Gateway } from '../../core/gateway';
3 | import { createOrderHash } from '../../lib/actions-order';
4 |
5 | /**
6 | * Creates order hash, signs it and returns eth signed order claim.
7 | * @param gateway Order gateway instance.
8 | * @param order Order data.
9 | */
10 | export default async function(gateway: Gateway, order: ActionsOrder) {
11 | const message = createOrderHash(gateway, order);
12 | const res = await gateway.provider.post({
13 | method: 'eth_sign',
14 | params: [gateway.provider.accountId, message],
15 | });
16 | return `${gateway.provider.signMethod}:${res.result}`;
17 | }
18 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-gateway/src/queries/actions-order/claim-personal-sign.ts:
--------------------------------------------------------------------------------
1 | import { ActionsOrder } from '@0xcert/scaffold';
2 | import { Gateway } from '../../core/gateway';
3 | import { createOrderHash } from '../../lib/actions-order';
4 |
5 | /**
6 | * Creates order hash, signs it and returns personal signed order claim.
7 | * @param gateway Order gateway instance.
8 | * @param order Order data.
9 | */
10 | export default async function(gateway: Gateway, order: ActionsOrder) {
11 | const message = createOrderHash(gateway, order);
12 | const res = await gateway.provider.post({
13 | method: 'personal_sign',
14 | params: [message, gateway.provider.accountId, null],
15 | });
16 | return `${gateway.provider.signMethod}:${res.result}`;
17 | }
18 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-gateway/src/queries/actions-order/get-order-data-claim.ts:
--------------------------------------------------------------------------------
1 | import { ActionsOrder } from '@0xcert/scaffold';
2 | import { Gateway } from '../../core/gateway';
3 | import { createRecipeTuple } from '../../lib/actions-order';
4 |
5 | const functionSignature = '0x5f2aa503';
6 | const inputTypes = ['tuple(address[], tuple[](uint32, address, bytes), uint256, uint256)'];
7 | const outputTypes = ['bytes32'];
8 |
9 | /**
10 | * Creates hash from order data.
11 | * @param gateway Order gateway instance.
12 | * @param order Order data.
13 | */
14 | export default async function(gateway: Gateway, order: ActionsOrder) {
15 | const recipeTuple = createRecipeTuple(gateway, order);
16 | try {
17 | const attrs = {
18 | to: gateway.config.actionsOrderId,
19 | data: functionSignature + gateway.provider.encoder.encodeParameters(inputTypes, [recipeTuple]).substr(2),
20 | };
21 | const res = await gateway.provider.post({
22 | method: 'eth_call',
23 | params: [attrs, 'latest'],
24 | });
25 | return gateway.provider.encoder.decodeParameters(outputTypes, res.result)[0];
26 | } catch (error) {
27 | gateway.provider.log(error);
28 | return null;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-gateway/src/queries/actions-order/get-proxy-account-id.ts:
--------------------------------------------------------------------------------
1 | import { Gateway } from '../../core/gateway';
2 | import { ProxyId } from '../../core/types';
3 |
4 | const functionSignature = '0xabd90f85';
5 | const inputTypes = ['uint8'];
6 | const outputTypes = ['address'];
7 |
8 | /**
9 | * Returns proxy address based on id used by this gateway.
10 | * @param gateway Order gateway instance.
11 | * @param proxyId Proxy id.
12 | */
13 | export default async function(gateway: Gateway, proxyId: ProxyId) {
14 | try {
15 | const attrs = {
16 | to: gateway.config.actionsOrderId,
17 | data: functionSignature + gateway.provider.encoder.encodeParameters(inputTypes, [proxyId]).substr(2),
18 | };
19 | const res = await gateway.provider.post({
20 | method: 'eth_call',
21 | params: [attrs, 'latest'],
22 | });
23 | return gateway.provider.encoder.decodeParameters(outputTypes, res.result)[0];
24 | } catch (error) {
25 | gateway.provider.log(error);
26 | return null;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-gateway/src/queries/asset-ledger-deploy-order/claim-eth-sign.ts:
--------------------------------------------------------------------------------
1 | import { AssetLedgerDeployOrder } from '@0xcert/scaffold';
2 | import { Gateway } from '../../core/gateway';
3 | import { createOrderHash } from '../../lib/asset-ledger-deploy-order';
4 |
5 | /**
6 | * Creates deploy hash, signs it and returns eth signed deploy claim.
7 | * @param gateway Gateway instance.
8 | * @param deploy Deploy data.
9 | */
10 | export default async function(gateway: Gateway, order: AssetLedgerDeployOrder) {
11 | const message = createOrderHash(gateway, order);
12 | const res = await gateway.provider.post({
13 | method: 'eth_sign',
14 | params: [gateway.provider.accountId, message],
15 | });
16 | return `${gateway.provider.signMethod}:${res.result}`;
17 | }
18 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-gateway/src/queries/asset-ledger-deploy-order/claim-personal-sign.ts:
--------------------------------------------------------------------------------
1 | import { AssetLedgerDeployOrder } from '@0xcert/scaffold';
2 | import { Gateway } from '../../core/gateway';
3 | import { createOrderHash } from '../../lib/asset-ledger-deploy-order';
4 |
5 | /**
6 | * Creates deploy hash, signs it and returns personal signed deploy claim.
7 | * @param gateway Gateway instance.
8 | * @param deploy Deploy data.
9 | */
10 | export default async function(gateway: Gateway, order: AssetLedgerDeployOrder) {
11 | const message = createOrderHash(gateway, order);
12 | const res = await gateway.provider.post({
13 | method: 'personal_sign',
14 | params: [message, gateway.provider.accountId, null],
15 | });
16 | return `${gateway.provider.signMethod}:${res.result}`;
17 | }
18 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-gateway/src/queries/asset-set-operator-order/claim-eth-sign.ts:
--------------------------------------------------------------------------------
1 | import { AssetSetOperatorOrder } from '@0xcert/scaffold';
2 | import { Gateway } from '../../core/gateway';
3 | import { createOrderHash } from '../../lib/asset-set-operator-order';
4 |
5 | /**
6 | * Creates set operator hash, signs it and returns eth signed set operator claim.
7 | * @param gateway Gateway instance.
8 | * @param order Set operator data.
9 | */
10 | export default async function(gateway: Gateway, order: AssetSetOperatorOrder) {
11 | const message = createOrderHash(order);
12 | const res = await gateway.provider.post({
13 | method: 'eth_sign',
14 | params: [gateway.provider.accountId, message],
15 | });
16 | return `${gateway.provider.signMethod}:${res.result}`;
17 | }
18 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-gateway/src/queries/asset-set-operator-order/claim-personal-sign.ts:
--------------------------------------------------------------------------------
1 | import { AssetSetOperatorOrder } from '@0xcert/scaffold';
2 | import { Gateway } from '../../core/gateway';
3 | import { createOrderHash } from '../../lib/asset-set-operator-order';
4 |
5 | /**
6 | * Creates set operator hash, signs it and returns personal signed set operator claim.
7 | * @param gateway Gateway instance.
8 | * @param order Set operator data.
9 | */
10 | export default async function(gateway: Gateway, order: AssetSetOperatorOrder) {
11 | const message = createOrderHash(order);
12 | const res = await gateway.provider.post({
13 | method: 'personal_sign',
14 | params: [message, gateway.provider.accountId, null],
15 | });
16 | return `${gateway.provider.signMethod}:${res.result}`;
17 | }
18 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-gateway/src/queries/asset-set-operator-order/get-order-data-claim.ts:
--------------------------------------------------------------------------------
1 | import { AssetSetOperatorOrder } from '@0xcert/scaffold';
2 | import { Gateway } from '../../core/gateway';
3 | import { getOrderInputParams } from '../../lib/asset-set-operator-order';
4 |
5 | const functionSignature = '0xa0fd4195';
6 | const inputTypes = ['address', 'address', 'bool', 'address', 'uint256', 'address', 'uint256', 'uint256'];
7 | const outputTypes = ['bytes32'];
8 |
9 | /**
10 | * Creates hash from deploy data.
11 | * @param gateway Gateway instance.
12 | * @param order AssetSetOperatorOrder data.
13 | */
14 |
15 | export default async function(gateway: Gateway, order: AssetSetOperatorOrder) {
16 | const params = getOrderInputParams(order);
17 | try {
18 | const attrs = {
19 | to: order.ledgerId,
20 | data: functionSignature + gateway.provider.encoder.encodeParameters(inputTypes, params).substr(2),
21 | };
22 | const res = await gateway.provider.post({
23 | method: 'eth_call',
24 | params: [attrs, 'latest'],
25 | });
26 | return gateway.provider.encoder.decodeParameters(outputTypes, res.result)[0];
27 | } catch (error) {
28 | gateway.provider.log(error);
29 | return null;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-gateway/src/queries/dapp-value-approve-order/claim-eth-sign.ts:
--------------------------------------------------------------------------------
1 | import { DappValueApproveOrder } from '@0xcert/scaffold';
2 | import { Gateway } from '../../core/gateway';
3 | import { createOrderHash } from '../../lib/dapp-value-approve-order';
4 |
5 | /**
6 | * Creates set operator hash, signs it and returns eth signed set operator claim.
7 | * @param gateway Gateway instance.
8 | * @param order Set operator data.
9 | */
10 | export default async function(gateway: Gateway, order: DappValueApproveOrder) {
11 | const message = createOrderHash(order);
12 | const res = await gateway.provider.post({
13 | method: 'eth_sign',
14 | params: [gateway.provider.accountId, message],
15 | });
16 | return `${gateway.provider.signMethod}:${res.result}`;
17 | }
18 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-gateway/src/queries/dapp-value-approve-order/claim-personal-sign.ts:
--------------------------------------------------------------------------------
1 | import { DappValueApproveOrder } from '@0xcert/scaffold';
2 | import { Gateway } from '../../core/gateway';
3 | import { createOrderHash } from '../../lib/dapp-value-approve-order';
4 |
5 | /**
6 | * Creates set operator hash, signs it and returns personal signed set operator claim.
7 | * @param gateway Gateway instance.
8 | * @param order Set operator data.
9 | */
10 | export default async function(gateway: Gateway, order: DappValueApproveOrder) {
11 | const message = createOrderHash(order);
12 | const res = await gateway.provider.post({
13 | method: 'personal_sign',
14 | params: [message, gateway.provider.accountId, null],
15 | });
16 | return `${gateway.provider.signMethod}:${res.result}`;
17 | }
18 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-gateway/src/queries/dapp-value-approve-order/get-order-data-claim.ts:
--------------------------------------------------------------------------------
1 | import { DappValueApproveOrder } from '@0xcert/scaffold';
2 | import { Gateway } from '../../core/gateway';
3 | import { getOrderInputParams } from '../../lib/dapp-value-approve-order';
4 |
5 | const functionSignature = '0x680f36e2';
6 | const inputTypes = ['address', 'address', 'uint256', 'address', 'uint256', 'uint256', 'uint256'];
7 | const outputTypes = ['bytes32'];
8 |
9 | /**
10 | * Creates hash from deploy data.
11 | * @param gateway Gateway instance.
12 | * @param order AssetSetOperatorOrder data.
13 | */
14 |
15 | export default async function(gateway: Gateway, order: DappValueApproveOrder) {
16 | const params = getOrderInputParams(order);
17 | try {
18 | const attrs = {
19 | to: order.ledgerId,
20 | data: functionSignature + gateway.provider.encoder.encodeParameters(inputTypes, params).substr(2),
21 | };
22 | const res = await gateway.provider.post({
23 | method: 'eth_call',
24 | params: [attrs, 'latest'],
25 | });
26 | return gateway.provider.encoder.decodeParameters(outputTypes, res.result)[0];
27 | } catch (error) {
28 | gateway.provider.log(error);
29 | return null;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-gateway/src/queries/value-ledger-deploy-order/claim-eth-sign.ts:
--------------------------------------------------------------------------------
1 | import { ValueLedgerDeployOrder } from '@0xcert/scaffold';
2 | import { Gateway } from '../../core/gateway';
3 | import { createOrderHash } from '../../lib/value-ledger-deploy-order';
4 |
5 | /**
6 | * Creates deploy hash, signs it and returns eth signed deploy claim.
7 | * @param gateway Gateway instance.
8 | * @param deploy Deploy data.
9 | */
10 | export default async function(gateway: Gateway, order: ValueLedgerDeployOrder) {
11 | const message = createOrderHash(gateway, order);
12 | const res = await gateway.provider.post({
13 | method: 'eth_sign',
14 | params: [gateway.provider.accountId, message],
15 | });
16 | return `${gateway.provider.signMethod}:${res.result}`;
17 | }
18 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-gateway/src/queries/value-ledger-deploy-order/claim-personal-sign.ts:
--------------------------------------------------------------------------------
1 | import { ValueLedgerDeployOrder } from '@0xcert/scaffold';
2 | import { Gateway } from '../../core/gateway';
3 | import { createOrderHash } from '../../lib/value-ledger-deploy-order';
4 |
5 | /**
6 | * Creates deploy hash, signs it and returns personal signed deploy claim.
7 | * @param gateway Gateway instance.
8 | * @param deploy Deploy data.
9 | */
10 | export default async function(gateway: Gateway, order: ValueLedgerDeployOrder) {
11 | const message = createOrderHash(gateway, order);
12 | const res = await gateway.provider.post({
13 | method: 'personal_sign',
14 | params: [message, gateway.provider.accountId, null],
15 | });
16 | return `${gateway.provider.signMethod}:${res.result}`;
17 | }
18 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-gateway/src/tests/index.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@specron/spec';
2 | import * as exchange from '..';
3 |
4 | const spec = new Spec();
5 |
6 | spec.test('exposes objects', (ctx) => {
7 | ctx.true(!!exchange.Gateway);
8 | ctx.true(!!exchange.DynamicActionsOrder);
9 | ctx.true(!!exchange.FixedActionsOrder);
10 | ctx.true(!!exchange.SignedDynamicActionsOrder);
11 | ctx.true(!!exchange.SignedFixedActionsOrder);
12 | ctx.true(!!exchange.AssetLedgerDeployOrder);
13 | ctx.true(!!exchange.ProxyKind);
14 | });
15 |
16 | export default spec;
17 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-gateway/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "es6",
5 | "noImplicitAny": false,
6 | "removeComments": true,
7 | "sourceMap": true,
8 | "outDir": "dist",
9 | "declaration": true,
10 | "experimentalDecorators": true,
11 | "allowSyntheticDefaultImports": true
12 | }
13 | }
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-generic-provider/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | > Basic implementation of communication provider for the Ethereum blockchain.
4 |
5 | The [0xcert Framework](https://docs.0xcert.org) is a free and open-source JavaScript library that provides tools for building powerful decentralized applications. Please refer to the [official documentation](https://docs.0xcert.org) for more details.
6 |
7 | This module is one of the bricks of the [0xcert Framework](https://docs.0xcert.org). It's written with [TypeScript](https://www.typescriptlang.org) and it's actively maintained. The source code is available on [GitHub](https://github.com/0xcert/framework) where you can also find our [issue tracker](https://github.com/0xcert/framework/issues).
8 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-generic-provider/nodemon.json:
--------------------------------------------------------------------------------
1 | {
2 | "ignore": ["dist/*"],
3 | "ext": "js,ts"
4 | }
5 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-generic-provider/src/core/errors.ts:
--------------------------------------------------------------------------------
1 | import { ProviderError, ProviderIssue } from '@0xcert/scaffold';
2 |
3 | /**
4 | * Converts provider error into unified ProviderError.
5 | * @param error Error object.
6 | */
7 | export function parseError(error: any) {
8 | if (error instanceof ProviderError) {
9 | return error;
10 | } else if (Object.values(ProviderIssue).includes(error)) {
11 | return new ProviderError(error);
12 | } else {
13 | return new ProviderError(ProviderIssue.CONTRACT_ERROR, error);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-generic-provider/src/index.ts:
--------------------------------------------------------------------------------
1 | export * from '@0xcert/scaffold/dist/core/mutation';
2 | export * from '@0xcert/scaffold/dist/core/provider';
3 | export * from './core/errors';
4 | export * from './core/mutation';
5 | export * from './core/provider';
6 | export * from './core/types';
7 | export * from './core/helpers';
8 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-generic-provider/src/tests/core/helpers/build-gateway-config-instance-method.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@specron/spec';
2 | import { GenericProvider } from '../../..';
3 | import { buildGatewayConfig } from '../../../core/helpers';
4 | import { NetworkKind } from '../../../core/types';
5 |
6 | const spec = new Spec();
7 |
8 | spec.test('sets correct config', async (ctx) => {
9 | const provider = new GenericProvider({
10 | client: ctx.web3,
11 | requiredConfirmations: 1,
12 | gatewayConfig: buildGatewayConfig(NetworkKind.ROPSTEN),
13 | });
14 | ctx.is(provider.gatewayConfig.actionsOrderId, '0xbb719e35c67198e4453923eeccF0c678C6129982');
15 | });
16 |
17 | export default spec;
18 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-generic-provider/src/tests/core/provider/account-change-event.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@specron/spec';
2 | import { GenericProvider, ProviderEvent } from '../../..';
3 |
4 | const spec = new Spec<{
5 | provider: GenericProvider;
6 | bob: string;
7 | }>();
8 |
9 | spec.before(async (stage) => {
10 | const provider = new GenericProvider({
11 | client: stage.web3,
12 | });
13 | stage.set('provider', provider);
14 | });
15 |
16 | spec.before(async (stage) => {
17 | const accounts = await stage.web3.eth.getAccounts();
18 | stage.set('bob', accounts[1]);
19 | });
20 |
21 | spec.test('returns block data', async (ctx) => {
22 | const provider = ctx.get('provider');
23 | const bob = ctx.get('bob');
24 |
25 | let triggered = null;
26 | provider.on(ProviderEvent.ACCOUNT_CHANGE, (accountId) => {
27 | triggered = accountId;
28 | });
29 | provider.accountId = bob;
30 |
31 | ctx.is(triggered, bob);
32 | ctx.is(provider.accountId, bob);
33 | });
34 |
35 | export default spec;
36 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-generic-provider/src/tests/core/provider/account-id-instance-variable.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@specron/spec';
2 | import { GenericProvider } from '../../..';
3 |
4 | const spec = new Spec<{
5 | provider: GenericProvider;
6 | }>();
7 |
8 | spec.before(async (stage) => {
9 | const provider = new GenericProvider({
10 | client: stage.web3,
11 | });
12 | stage.set('provider', provider);
13 | });
14 |
15 | spec.test('normalizes ID when set', async (ctx) => {
16 | const provider = ctx.get('provider');
17 | provider.accountId = '0xf9196f9f176fd2ef9243e8960817d5fbe63d79aa';
18 | ctx.is(provider.accountId, '0xF9196F9f176fd2eF9243E8960817d5FbE63D79aa');
19 | });
20 |
21 | export default spec;
22 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-generic-provider/src/tests/core/provider/gateway-config-instance-variable.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@specron/spec';
2 | import { GatewayConfig, GenericProvider } from '../../..';
3 |
4 | const spec = new Spec<{
5 | provider: GenericProvider;
6 | }>();
7 |
8 | spec.before(async (stage) => {
9 | const provider = new GenericProvider({
10 | client: stage.web3,
11 | });
12 | stage.set('provider', provider);
13 | });
14 |
15 | spec.test('normalizes ID when set', async (ctx) => {
16 | const provider = ctx.get('provider');
17 | provider.gatewayConfig = {
18 | actionsOrderId: '0xf9196f9f176fd2ef9243e8960817d5fbe63d79aa',
19 | assetLedgerDeployOrderId: '0xf9196f9f176fd2ef9243e8960817d5fbe63d79aa',
20 | valueLedgerDeployOrderId: '0xf9196f9f176fd2ef9243e8960817d5fbe63d79aa',
21 | };
22 | ctx.is(provider.gatewayConfig.actionsOrderId, '0xF9196F9f176fd2eF9243E8960817d5FbE63D79aa');
23 | ctx.is(provider.gatewayConfig.assetLedgerDeployOrderId, '0xF9196F9f176fd2eF9243E8960817d5FbE63D79aa');
24 | ctx.is(provider.gatewayConfig.valueLedgerDeployOrderId, '0xF9196F9f176fd2eF9243E8960817d5FbE63D79aa');
25 | });
26 |
27 | export default spec;
28 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-generic-provider/src/tests/core/provider/get-available-accounts-instance-variable.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@specron/spec';
2 | import { GenericProvider } from '../../..';
3 |
4 | const spec = new Spec<{
5 | provider: GenericProvider;
6 | }>();
7 |
8 | spec.before(async (stage) => {
9 | const provider = new GenericProvider({
10 | client: stage.web3,
11 | });
12 | stage.set('provider', provider);
13 | });
14 |
15 | spec.test('returns checksum account ids', async (ctx) => {
16 | const provider = ctx.get('provider');
17 | const accounts = await provider.getAvailableAccounts();
18 | ctx.true(accounts.length > 2);
19 | ctx.not(accounts[0].toLowerCase(), accounts[0]);
20 | });
21 |
22 | export default spec;
23 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-generic-provider/src/tests/core/provider/get-network-version-instance-method.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@specron/spec';
2 | import { GenericProvider } from '../../..';
3 |
4 | const spec = new Spec<{
5 | provider: GenericProvider;
6 | }>();
7 |
8 | spec.before(async (stage) => {
9 | const provider = new GenericProvider({
10 | client: stage.web3,
11 | });
12 | stage.set('provider', provider);
13 | });
14 |
15 | spec.test('returns block data', async (ctx) => {
16 | const provider = ctx.get('provider');
17 | const version = await provider.getNetworkVersion();
18 | ctx.true(parseInt(version) > 2);
19 | });
20 |
21 | export default spec;
22 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-generic-provider/src/tests/core/provider/is-current-account-instance-variable.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@specron/spec';
2 | import { GenericProvider } from '../../..';
3 |
4 | const spec = new Spec<{
5 | provider: GenericProvider;
6 | }>();
7 |
8 | spec.before(async (stage) => {
9 | const provider = new GenericProvider({
10 | client: stage.web3,
11 | accountId: '0x44e44897FC076Bc46AaE6b06b917D0dfD8B2dae9',
12 | });
13 | stage.set('provider', provider);
14 | });
15 |
16 | spec.test('returns true when account ID matches', async (ctx) => {
17 | const provider = ctx.get('provider');
18 | ctx.true(provider.isCurrentAccount('0x44e44897fc076bc46aae6b06b917d0dfd8b2dae9'));
19 | });
20 |
21 | spec.test('returns true when account ID does not match', async (ctx) => {
22 | const provider = ctx.get('provider');
23 | ctx.false(provider.isCurrentAccount('0xF9196F9f176fd2eF9243E8960817d5FbE63D79aa'));
24 | });
25 |
26 | export default spec;
27 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-generic-provider/src/tests/core/provider/is-unsafe-recipient-id-instance-variable.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@specron/spec';
2 | import { GenericProvider } from '../../..';
3 |
4 | const spec = new Spec<{
5 | provider: GenericProvider;
6 | }>();
7 |
8 | spec.before(async (stage) => {
9 | const provider = new GenericProvider({
10 | client: stage.web3,
11 | unsafeRecipientIds: ['0x44e44897FC076Bc46AaE6b06b917D0dfD8B2dae9'],
12 | });
13 | stage.set('provider', provider);
14 | });
15 |
16 | spec.test('returns true for unsafe recipient id', async (ctx) => {
17 | const provider = ctx.get('provider');
18 | ctx.true(provider.isUnsafeRecipientId('0x44e44897FC076Bc46AaE6b06b917D0dfD8B2dae9'));
19 | ctx.true(provider.isUnsafeRecipientId('0x44e44897fc076bc46aae6b06b917d0dfd8b2dae9'));
20 | });
21 |
22 | spec.test('returns false for safe recipient id', async (ctx) => {
23 | const provider = ctx.get('provider');
24 | ctx.false(provider.isUnsafeRecipientId('0xF9196F9f176fd2eF9243E8960817d5FbE63D79aa'));
25 | });
26 |
27 | export default spec;
28 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-generic-provider/src/tests/core/provider/post-instance-method.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@specron/spec';
2 | import { GenericProvider } from '../../..';
3 |
4 | const spec = new Spec<{
5 | provider: GenericProvider;
6 | }>();
7 |
8 | spec.before(async (stage) => {
9 | const provider = new GenericProvider({
10 | client: stage.web3,
11 | });
12 | stage.set('provider', provider);
13 | });
14 |
15 | spec.test('returns block data', async (ctx) => {
16 | const provider = ctx.get('provider');
17 |
18 | const res = await provider.post({
19 | method: 'web3_clientVersion',
20 | params: [],
21 | });
22 |
23 | ctx.is(res.result.indexOf('EthereumJS'), 0);
24 | });
25 |
26 | export default spec;
27 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-generic-provider/src/tests/core/provider/sign-instance-method.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@specron/spec';
2 | import { GenericProvider } from '../../..';
3 | import { SignMethod } from '../../../core/types';
4 |
5 | const spec = new Spec<{
6 | provider: GenericProvider;
7 | }>();
8 |
9 | spec.before(async (stage) => {
10 | const accounts = await stage.web3.eth.getAccounts();
11 | const provider = new GenericProvider({
12 | client: stage.web3,
13 | signMethod: SignMethod.ETH_SIGN,
14 | accountId: accounts[0],
15 | });
16 | stage.set('provider', provider);
17 | });
18 |
19 | spec.test('signs a message', async (ctx) => {
20 | const provider = ctx.get('provider');
21 | const signature = await provider.sign('test');
22 | ctx.true(!!signature);
23 | });
24 |
25 | export default spec;
26 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-generic-provider/src/tests/core/provider/unsafe-recipient-ids-instance-variable.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@specron/spec';
2 | import { GenericProvider } from '../../..';
3 |
4 | const spec = new Spec<{
5 | provider: GenericProvider;
6 | }>();
7 |
8 | spec.before(async (stage) => {
9 | const provider = new GenericProvider({
10 | client: stage.web3,
11 | });
12 | stage.set('provider', provider);
13 | });
14 |
15 | spec.test('normalizes IDs when set', async (ctx) => {
16 | const provider = ctx.get('provider');
17 | provider.unsafeRecipientIds = ['0xf9196f9f176fd2ef9243e8960817d5fbe63d79aa'];
18 | ctx.deepEqual(provider.unsafeRecipientIds, ['0xF9196F9f176fd2eF9243E8960817d5FbE63D79aa']);
19 | });
20 |
21 | export default spec;
22 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-generic-provider/src/tests/index.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@specron/spec';
2 | import * as view from '..';
3 |
4 | const spec = new Spec();
5 |
6 | spec.test('exposes objects', (ctx) => {
7 | ctx.true(!!view.GenericProvider);
8 | ctx.true(!!view.SignMethod);
9 | ctx.true(!!view.buildGatewayConfig);
10 | ctx.true(!!view.NetworkKind);
11 | });
12 |
13 | export default spec;
14 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-generic-provider/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "es6",
5 | "noImplicitAny": false,
6 | "removeComments": true,
7 | "sourceMap": true,
8 | "outDir": "dist",
9 | "declaration": true,
10 | "experimentalDecorators": true,
11 | "allowSyntheticDefaultImports": true
12 | }
13 | }
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-http-provider/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | > Implementation of HTTP communication provider for the Ethereum blockchain.
4 |
5 | The [0xcert Framework](https://docs.0xcert.org) is a free and open-source JavaScript library that provides tools for building powerful decentralized applications. Please refer to the [official documentation](https://docs.0xcert.org) for more details.
6 |
7 | This module is one of the bricks of the [0xcert Framework](https://docs.0xcert.org). It's written with [TypeScript](https://www.typescriptlang.org) and it's actively maintained. The source code is available on [GitHub](https://github.com/0xcert/framework) where you can also find our [issue tracker](https://github.com/0xcert/framework/issues).
8 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-http-provider/nodemon.json:
--------------------------------------------------------------------------------
1 | {
2 | "ignore": ["dist/*"],
3 | "ext": "js,ts"
4 | }
5 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-http-provider/src/index.ts:
--------------------------------------------------------------------------------
1 | export * from '@0xcert/ethereum-generic-provider';
2 | export * from './core/provider';
3 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-http-provider/src/tests/index.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@specron/spec';
2 | import * as view from '..';
3 |
4 | const spec = new Spec();
5 |
6 | spec.test('exposes objects', (ctx) => {
7 | ctx.true(!!view.HttpProvider);
8 | ctx.true(!!view.SignMethod);
9 | ctx.true(!!view.Mutation);
10 | ctx.true(!!view.buildGatewayConfig);
11 | ctx.true(!!view.NetworkKind);
12 | });
13 |
14 | export default spec;
15 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-http-provider/src/tests/provider/get-network-version-instance-method.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@specron/spec';
2 | import { HttpProvider } from '../..';
3 |
4 | const spec = new Spec<{
5 | provider: HttpProvider;
6 | }>();
7 |
8 | spec.before(async (stage) => {
9 | const provider = new HttpProvider({
10 | url: 'https://ropsten.infura.io/v3/06312ac7a50b4bd49762abc5cf79dab8',
11 | });
12 | stage.set('provider', provider);
13 | });
14 |
15 | spec.test('returns block data', async (ctx) => {
16 | const provider = ctx.get('provider');
17 | const version = await provider.getNetworkVersion();
18 | ctx.is(version, '3');
19 | });
20 |
21 | export default spec;
22 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-http-provider/src/tests/provider/send-instance-method.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@specron/spec';
2 | import { HttpProvider } from '../..';
3 |
4 | const spec = new Spec<{
5 | provider: HttpProvider;
6 | }>();
7 |
8 | spec.before(async (stage) => {
9 | const provider = new HttpProvider({
10 | url: 'https://ropsten.infura.io/v3/06312ac7a50b4bd49762abc5cf79dab8',
11 | });
12 | stage.set('provider', provider);
13 | });
14 |
15 | spec.test('returns block data', async (ctx) => {
16 | const provider = ctx.get('provider');
17 | const tx = '0x853f015e3964a00be518dd0f06262165ce464cb261c36e86645077b1eaeb75a9';
18 | const res = await provider.post({
19 | method: 'eth_getTransactionByHash',
20 | params: [tx],
21 | });
22 | ctx.is(res.result.hash, tx);
23 | });
24 |
25 | export default spec;
26 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-http-provider/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "es6",
5 | "noImplicitAny": false,
6 | "removeComments": true,
7 | "sourceMap": true,
8 | "outDir": "dist",
9 | "declaration": true,
10 | "experimentalDecorators": true,
11 | "allowSyntheticDefaultImports": true
12 | }
13 | }
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-metamask-provider/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | > Implementation of MetaMask communication provider for the Ethereum blockchain.
4 |
5 | The [0xcert Framework](https://docs.0xcert.org) is a free and open-source JavaScript library that provides tools for building powerful decentralized applications. Please refer to the [official documentation](https://docs.0xcert.org) for more details.
6 |
7 | This module is one of the bricks of the [0xcert Framework](https://docs.0xcert.org). It's written with [TypeScript](https://www.typescriptlang.org) and it's actively maintained. The source code is available on [GitHub](https://github.com/0xcert/framework) where you can also find our [issue tracker](https://github.com/0xcert/framework/issues).
8 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-metamask-provider/nodemon.json:
--------------------------------------------------------------------------------
1 | {
2 | "ignore": ["dist/*"],
3 | "ext": "js,ts"
4 | }
5 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-metamask-provider/src/index.ts:
--------------------------------------------------------------------------------
1 | export * from '@0xcert/ethereum-generic-provider';
2 | export * from './core/provider';
3 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-metamask-provider/src/tests/index.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@hayspec/spec';
2 | import * as view from '..';
3 |
4 | const spec = new Spec();
5 |
6 | spec.test('exposes objects', (ctx) => {
7 | ctx.true(!!view.MetamaskProvider);
8 | ctx.true(!!view.SignMethod);
9 | ctx.true(!!view.Mutation);
10 | ctx.true(!!view.buildGatewayConfig);
11 | ctx.true(!!view.NetworkKind);
12 | });
13 |
14 | export default spec;
15 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-metamask-provider/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "es6",
5 | "noImplicitAny": false,
6 | "removeComments": true,
7 | "sourceMap": true,
8 | "outDir": "dist",
9 | "declaration": true,
10 | "experimentalDecorators": true,
11 | "allowSyntheticDefaultImports": true
12 | }
13 | }
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-proxy-contracts/.solhint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "solhint:default",
3 | "rules": {
4 | "max-line-length": ["warn", 100]
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-proxy-contracts/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | > Proxy smart contracts used by the gateway when communicating with the Ethereum blockchain.
4 |
5 | The [0xcert Framework](https://docs.0xcert.org) is a free and open-source JavaScript library that provides tools for building powerful decentralized applications. Please refer to the [official documentation](https://docs.0xcert.org) for more details.
6 |
7 | This module is one of the bricks of the [0xcert Framework](https://docs.0xcert.org). It's written with [TypeScript](https://www.typescriptlang.org) and it's actively maintained. The source code is available on [GitHub](https://github.com/0xcert/framework) where you can also find our [issue tracker](https://github.com/0xcert/framework/issues).
8 |
9 | # Build
10 |
11 | By default, the contracts in this package are built for Constantinople EVM. If you would like to use these smart contracts for `Wanchain` or other blockchains using EVM for a different version, you will need to rebuild them for the desired version.
12 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-proxy-contracts/nodemon.json:
--------------------------------------------------------------------------------
1 | {
2 | "ignore": ["dist/*"],
3 | "ext": "js,ts"
4 | }
5 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-proxy-contracts/src/contracts/abilitable-manage-proxy.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 |
3 | pragma solidity 0.8.6;
4 |
5 | import "./iproxy.sol";
6 | import "@0xcert/ethereum-utils-contracts/src/contracts/permission/abilitable.sol";
7 |
8 | /**
9 | * @title AbilitableManageProxy - Manages abilities on behalf of contracts that have been approved
10 | * via decentralized governance.
11 | */
12 | contract AbilitableManageProxy is
13 | Abilitable
14 | {
15 |
16 | /**
17 | * @dev List of abilities:
18 | * 16 - Ability to execute transfer.
19 | */
20 | uint8 constant ABILITY_TO_EXECUTE = 16;
21 |
22 | /**
23 | * @dev Calls into Abilitable contract, invoking grantAbilities.
24 | * @param _target Address of abilitable smart contract.
25 | * @param _to Account to which we are granting abilities.
26 | * @param _abilities Number representing bitfield of abilities we are granting.
27 | */
28 | function set(
29 | address _target,
30 | address _to,
31 | uint256 _abilities
32 | )
33 | public
34 | hasAbilities(ABILITY_TO_EXECUTE)
35 | {
36 | Abilitable(_target).setAbilities(_to, _abilities);
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-proxy-contracts/src/contracts/iproxy.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 |
3 | pragma solidity 0.8.6;
4 |
5 | /**
6 | * @dev Standard interface for a distributed exchange proxy contract.
7 | */
8 | interface Proxy {
9 |
10 | /**
11 | * @dev Executes an action.
12 | * @param _target Target of execution.
13 | * @param _a Address usually representing from.
14 | * @param _b Address usually representing to.
15 | * @param _c Integer usually repersenting amount/value/id.
16 | */
17 | function execute(
18 | address _target,
19 | address _a,
20 | address _b,
21 | uint256 _c
22 | )
23 | external;
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-proxy-contracts/src/contracts/token-custom.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 |
3 | pragma solidity 0.8.6;
4 |
5 | import "@0xcert/ethereum-erc20-contracts/src/contracts/token.sol";
6 |
7 | /**
8 | * @dev This is an implementation of the erc20 token smart contract.
9 | */
10 | contract TokenCustom is
11 | Token
12 | {
13 | constructor(
14 | string memory _name,
15 | string memory _symbol,
16 | uint256 _supply,
17 | uint8 _decimals,
18 | address _owner
19 | )
20 | {
21 | tokenName = _name;
22 | tokenSymbol = _symbol;
23 | tokenDecimals = _decimals;
24 | tokenTotalSupply = _supply;
25 | balances[_owner] = tokenTotalSupply;
26 | emit Transfer(address(0), _owner, tokenTotalSupply);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-proxy-contracts/src/contracts/token-deploy-proxy.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 |
3 | pragma solidity 0.8.6;
4 | import "./token-custom.sol";
5 |
6 | /**
7 | * @title TokenDeployProxy - Deploys a new token on behalf of contracts that have been approved via
8 | * decentralized governance.
9 | */
10 | contract TokenDeployProxy
11 | {
12 | /**
13 | * @dev Deploys a new Token.
14 | * @param _name Token name.
15 | * @param _symbol Token symbol.
16 | * @param _supply Total supply of tokens.
17 | * @param _decimals Number of decimals.
18 | * @param _owner Token owner.
19 | */
20 | function deploy(
21 | string memory _name,
22 | string memory _symbol,
23 | uint256 _supply,
24 | uint8 _decimals,
25 | address _owner
26 | )
27 | public
28 | returns (address token)
29 | {
30 | token = address(
31 | new TokenCustom(
32 | _name, _symbol, _supply, _decimals, _owner
33 | )
34 | );
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-proxy-contracts/src/contracts/xcert-burn-proxy.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 |
3 | pragma solidity 0.8.6;
4 |
5 | import "@0xcert/ethereum-xcert-contracts/src/contracts/ixcert-burnable.sol";
6 | import "@0xcert/ethereum-utils-contracts/src/contracts/permission/abilitable.sol";
7 |
8 | /**
9 | * @title XcertBurnProxy - burns a token on behalf of contracts that have been approved via
10 | * decentralized governance.
11 | */
12 | contract XcertBurnProxy is
13 | Abilitable
14 | {
15 |
16 | /**
17 | * @dev List of abilities:
18 | * 16 - Ability to execute create.
19 | */
20 | uint8 constant ABILITY_TO_EXECUTE = 16;
21 |
22 | /**
23 | * @dev Destroys an existing Xcert.
24 | * @param _xcert Address of the Xcert contract on which the token destroy will be performed.
25 | * @param _id The Xcert we will destroy.
26 | */
27 | function destroy(
28 | address _xcert,
29 | uint256 _id
30 | )
31 | external
32 | hasAbilities(ABILITY_TO_EXECUTE)
33 | {
34 | XcertBurnable(_xcert).destroy(_id);
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-proxy-contracts/src/contracts/xcert-create-proxy.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 |
3 | pragma solidity 0.8.6;
4 |
5 | import "@0xcert/ethereum-xcert-contracts/src/contracts/ixcert.sol";
6 | import "@0xcert/ethereum-utils-contracts/src/contracts/permission/abilitable.sol";
7 |
8 | /**
9 | * @title XcertCreateProxy - creates a token on behalf of contracts that have been approved via
10 | * decentralized governance.
11 | */
12 | contract XcertCreateProxy is
13 | Abilitable
14 | {
15 |
16 | /**
17 | * @dev List of abilities:
18 | * 16 - Ability to execute create.
19 | */
20 | uint8 constant ABILITY_TO_EXECUTE = 16;
21 |
22 | /**
23 | * @dev Creates a new Xcert.
24 | * @param _xcert Address of the Xcert contract on which the creation will be performed.
25 | * @param _to The address that will own the created Xcert.
26 | * @param _id The Xcert to be created by the msg.sender.
27 | * @param _tokenURIIntegrityDigest Cryptographic asset URI integrity digest.
28 | */
29 | function create(
30 | address _xcert,
31 | address _to,
32 | uint256 _id,
33 | bytes32 _tokenURIIntegrityDigest
34 | )
35 | external
36 | hasAbilities(ABILITY_TO_EXECUTE)
37 | {
38 | Xcert(_xcert).create(_to, _id, _tokenURIIntegrityDigest);
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-proxy-contracts/src/core/types.ts:
--------------------------------------------------------------------------------
1 | export enum XcertCreateProxyAbilities {
2 | MANAGE_ABILITIES = 1,
3 | ALLOW_MANAGE_ABILITIES = 2,
4 | EXECUTE = 16,
5 | }
6 |
7 | export enum TokenTransferProxyAbilities {
8 | MANAGE_ABILITIES = 1,
9 | ALLOW_MANAGE_ABILITIES = 2,
10 | EXECUTE = 16,
11 | }
12 |
13 | export enum NFTokenTransferProxyAbilities {
14 | MANAGE_ABILITIES = 1,
15 | ALLOW_MANAGE_ABILITIES = 2,
16 | EXECUTE = 16,
17 | }
18 |
19 | export enum NFTokenSafeTransferProxyAbilities {
20 | MANAGE_ABILITIES = 1,
21 | ALLOW_MANAGE_ABILITIES = 2,
22 | EXECUTE = 16,
23 | }
24 |
25 | export enum XcertUpdateProxyAbilities {
26 | MANAGE_ABILITIES = 1,
27 | ALLOW_MANAGE_ABILITIES = 2,
28 | EXECUTE = 16,
29 | }
30 |
31 | export enum AbilitableManageProxyAbilities {
32 | MANAGE_ABILITIES = 1,
33 | ALLOW_MANAGE_ABILITIES = 2,
34 | EXECUTE = 16,
35 | }
36 |
37 | export enum XcertBurnProxyAbilities {
38 | MANAGE_ABILITIES = 1,
39 | ALLOW_MANAGE_ABILITIES = 2,
40 | EXECUTE = 16,
41 | }
42 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-proxy-contracts/src/index.ts:
--------------------------------------------------------------------------------
1 | export * from './core/types';
2 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-proxy-contracts/src/tests/token-custom.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@specron/spec';
2 |
3 | const spec = new Spec();
4 |
5 | spec.test('checks correct token custom', async (ctx) => {
6 | const accounts = await ctx.web3.eth.getAccounts();
7 | const tokenCustom = await ctx.deploy({
8 | src: './build/token-custom.json',
9 | contract: 'TokenCustom',
10 | args: [
11 | 'Foo',
12 | 'F',
13 | '50000000000000000000000',
14 | '18',
15 | accounts[3],
16 | ],
17 | });
18 | const ownerBalance = await tokenCustom.instance.methods.balanceOf(accounts[3]).call();
19 | const contractName = await tokenCustom.instance.methods.name().call();
20 | ctx.is(ownerBalance, '50000000000000000000000');
21 | ctx.is(contractName, 'Foo');
22 | });
23 |
24 | export default spec;
25 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-proxy-contracts/src/tests/token-deploy-proxy.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@specron/spec';
2 |
3 | /**
4 | * Spec context interfaces.
5 | */
6 |
7 | interface Data {
8 | tokenDeployProxy?: any;
9 | owner?: string;
10 | bob?: string;
11 | jane?: string;
12 | }
13 |
14 | const spec = new Spec();
15 |
16 | spec.before(async (ctx) => {
17 | const accounts = await ctx.web3.eth.getAccounts();
18 | ctx.set('owner', accounts[0]);
19 | ctx.set('bob', accounts[1]);
20 | ctx.set('jane', accounts[2]);
21 | });
22 |
23 | spec.beforeEach(async (ctx) => {
24 | const tokenDeployProxy = await ctx.deploy({
25 | src: './build/token-deploy-proxy.json',
26 | contract: 'TokenDeployProxy',
27 | });
28 | ctx.set('tokenDeployProxy', tokenDeployProxy);
29 | });
30 |
31 | spec.test('deploys a Token', async (ctx) => {
32 | const tokenDeployProxy = ctx.get('tokenDeployProxy');
33 | const bob = ctx.get('bob');
34 | const accounts = await ctx.web3.eth.getAccounts();
35 |
36 | await ctx.notThrows(() => tokenDeployProxy.instance.methods.deploy(
37 | 'Foo',
38 | 'F',
39 | '50000000000000000000000',
40 | '18',
41 | accounts[3],
42 | ).send({ from: bob }));
43 | });
44 |
45 | export default spec;
46 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-proxy-contracts/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "es6",
5 | "noImplicitAny": false,
6 | "removeComments": true,
7 | "sourceMap": true,
8 | "outDir": "dist",
9 | "declaration": true,
10 | "experimentalDecorators": true,
11 | "allowSyntheticDefaultImports": true
12 | }
13 | }
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-sandbox/nodemon.json:
--------------------------------------------------------------------------------
1 | {
2 | "ignore": ["dist/*"],
3 | "ext": "js,ts"
4 | }
5 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-sandbox/src/README.md:
--------------------------------------------------------------------------------
1 | Standalone usage:
2 |
3 | ```ts
4 | import { Sandbox } from '@0xcert/ethereum-sandbox';
5 |
6 | const sandbox = new Sandbox();
7 | await sandbox.listen();
8 | ...
9 | await sandbox.close();
10 | ```
11 |
12 | Specron example:
13 |
14 | ```ts
15 | import { Spec } from '@specron/spec';
16 | import { Protocol } from '@0xcert/ethereum-sandbox';
17 |
18 | const spec = new Spec();
19 |
20 | spec.before(async (stage) => {
21 | await Protocol.deploy(stage.web3);
22 | });
23 |
24 | export default spec;
25 | ```
26 |
27 | Hayspec example:
28 |
29 | ```ts
30 | import { Spec } from '@hayspec/spec';
31 | import { Sandbox } from '@0xcert/ethereum-sandbox';
32 |
33 | interface Data {
34 | sandbox: Sandbox;
35 | }
36 |
37 | const spec = new Spec();
38 |
39 | spec.before(async (stage) => {
40 | stage.set('sandbox', await Sandbox.listen());
41 | });
42 |
43 | spec.after(async (stage) => {
44 | await stage.get('sandbox').close();
45 | });
46 |
47 | export default spec;
48 | ```
49 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-sandbox/src/index.ts:
--------------------------------------------------------------------------------
1 | export * from './core/sandbox';
2 | export * from './core/protocol';
3 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-sandbox/src/lib/deploy.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Deploys smart contract to the network.
3 | * @param config Deploy contract configuration.
4 | */
5 | export function deploy(config: {
6 | web3: any;
7 | abi: any;
8 | bytecode: string;
9 | from: string;
10 | args?: any[];
11 | gas?: number;
12 | gasPrice?: number;
13 | }) {
14 | return new config.web3.eth.Contract(config.abi).deploy({
15 | data: config.bytecode,
16 | arguments: config.args,
17 | }).send({
18 | from: config.from,
19 | gas: config.gas || 6000000,
20 | gasPrice: config.gas || 1,
21 | }).then((receipt) => {
22 | const instance = new config.web3.eth.Contract(
23 | config.abi,
24 | receipt.options.address,
25 | {
26 | gas: config.gas || 6000000,
27 | from: config.from,
28 | },
29 | );
30 | return { instance, receipt };
31 | });
32 | }
33 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-sandbox/src/tests/index.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@hayspec/spec';
2 | import * as sandbox from '..';
3 |
4 | const spec = new Spec();
5 |
6 | spec.test('exposes objects', (t) => {
7 | t.true(!!sandbox.Sandbox);
8 | t.true(!!sandbox.Protocol);
9 | });
10 |
11 | export default spec;
12 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-sandbox/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "es6",
5 | "noImplicitAny": false,
6 | "removeComments": true,
7 | "sourceMap": true,
8 | "outDir": "dist",
9 | "declaration": true,
10 | "experimentalDecorators": true,
11 | "allowSyntheticDefaultImports": true
12 | }
13 | }
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-utils-contracts/.solhint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "solhint:default",
3 | "rules": {
4 | "max-line-length": ["warn", 100]
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-utils-contracts/nodemon.json:
--------------------------------------------------------------------------------
1 | {
2 | "ignore": ["dist/*"],
3 | "ext": "js,ts"
4 | }
5 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-utils-contracts/src/contracts/utils/address-utils.sol:
--------------------------------------------------------------------------------
1 |
2 | // SPDX-License-Identifier: MIT
3 | pragma solidity 0.8.6;
4 |
5 | /**
6 | * @dev Utility library of inline functions on addresses.
7 | */
8 | library AddressUtils
9 | {
10 |
11 | /**
12 | * @dev Returns whether the target address is a deployed contract.
13 | * If a contract constructor calls this method with its own address the returned value
14 | * will be false. If you want to check if an address is a contract (in whatever state) you can do
15 | * so using extcodehash after constantinople fork.
16 | * @param _addr Address to check.
17 | * @return addressCheck True if _addr is a deployed contract, false if not.
18 | */
19 | function isDeployedContract(
20 | address _addr
21 | )
22 | internal
23 | view
24 | returns (bool addressCheck)
25 | {
26 | uint256 size;
27 | assembly { size := extcodesize(_addr) } // solhint-disable-line
28 | addressCheck = size > 0;
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-utils-contracts/src/contracts/utils/erc165.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 |
3 | pragma solidity 0.8.6;
4 |
5 | /**
6 | * @dev A standard for detecting smart contract interfaces.
7 | * See: https://eips.ethereum.org/EIPS/eip-165.
8 | */
9 | interface ERC165
10 | {
11 |
12 | /**
13 | * @dev Checks if the smart contract implements a specific interface.
14 | * This function uses less than 30,000 gas.
15 | * @param _interfaceID The interface identifier, as specified in ERC-165.
16 | */
17 | function supportsInterface(
18 | bytes4 _interfaceID
19 | )
20 | external
21 | view
22 | returns (bool);
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-utils-contracts/src/contracts/utils/supports-interface.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 |
3 | pragma solidity 0.8.6;
4 |
5 | import "./erc165.sol";
6 |
7 | /**
8 | * @dev Implementation of standard to publish supported interfaces.
9 | */
10 | contract SupportsInterface is
11 | ERC165
12 | {
13 |
14 | /**
15 | * @dev Mapping of supported intefraces.
16 | * You must not set element 0xffffffff to true.
17 | */
18 | mapping(bytes4 => bool) internal supportedInterfaces;
19 |
20 | /**
21 | * @dev Contract constructor.
22 | */
23 | constructor()
24 | {
25 | supportedInterfaces[0x01ffc9a7] = true; // ERC165
26 | }
27 |
28 | /**
29 | * @dev Function to check which interfaces are supported by this contract.
30 | * @param _interfaceID Id of the interface.
31 | */
32 | function supportsInterface(
33 | bytes4 _interfaceID
34 | )
35 | external
36 | override
37 | view
38 | returns (bool)
39 | {
40 | return supportedInterfaces[_interfaceID];
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-utils-contracts/src/tests/mocks/abilitable-test-mock.sol:
--------------------------------------------------------------------------------
1 | pragma solidity 0.8.6;
2 |
3 | import "../../contracts/permission/abilitable.sol";
4 |
5 | contract AbilitableTestMock is
6 | Abilitable
7 | {
8 | uint8 constant ABILITY_A = 1;
9 | uint8 constant ABILITY_B = 16;
10 |
11 | function abilityA()
12 | external
13 | view
14 | hasAbilities(ABILITY_A)
15 | returns (string memory)
16 | {
17 | return "A";
18 | }
19 |
20 | function abilityB()
21 | external
22 | view
23 | hasAbilities(ABILITY_B)
24 | returns (string memory)
25 | {
26 | return "B";
27 | }
28 |
29 | function abilityX(uint8 _ability)
30 | external
31 | view
32 | hasAbilities(_ability)
33 | returns (string memory)
34 | {
35 | return "X";
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-utils-contracts/src/tests/mocks/address-utils-mock.sol:
--------------------------------------------------------------------------------
1 | pragma solidity 0.8.6;
2 |
3 | import "../../contracts/utils/address-utils.sol";
4 |
5 | contract AddressUtilsMock {
6 | using AddressUtils for address;
7 |
8 | function isDeployedContract(
9 | address _addr
10 | )
11 | external
12 | view
13 | returns (bool addressCheck)
14 | {
15 | addressCheck = _addr.isDeployedContract();
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-utils-contracts/src/tests/mocks/unpack-test-mock.sol:
--------------------------------------------------------------------------------
1 | pragma solidity 0.8.6;
2 |
3 | import "../../contracts/utils/bytes-type.sol";
4 |
5 | contract UnpackTestMock
6 | {
7 |
8 | // Expecting 109-byte input
9 | function unpack(
10 | bytes calldata _input
11 | )
12 | external
13 | pure
14 | returns (address p1, bool p2, bytes32 p3, uint8 p4, uint16 p5, uint256 p6)
15 | {
16 | uint8 offset = 88;
17 | p1 = BytesType.toAddress(offset, _input);
18 | offset -= 20;
19 | p2 = BytesType.toBool(offset, _input);
20 | offset -= 1;
21 | p3 = BytesType.toBytes32(offset, _input);
22 | offset -= 32;
23 | p4 = BytesType.toUint8(offset, _input);
24 | offset -= 1;
25 | p5 = BytesType.toUint16(offset, _input);
26 | offset -= 2;
27 | p6 = BytesType.toUint256(offset, _input);
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-utils-contracts/src/tests/supports-interface.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@specron/spec';
2 |
3 | interface Data {
4 | supportsInterface?: any;
5 | }
6 |
7 | const spec = new Spec();
8 |
9 | spec.beforeEach(async (ctx) => {
10 | const supportsInterface = await ctx.deploy({
11 | src: './build/supports-interface.json',
12 | contract: 'SupportsInterface',
13 | });
14 | ctx.set('supportsInterface', supportsInterface);
15 | });
16 |
17 | spec.test('correctly checks all the supported interfaces', async (ctx) => {
18 | const supportsInterface = ctx.get('supportsInterface');
19 | const erc165 = await supportsInterface.instance.methods.supportsInterface('0x01ffc9a7').call();
20 | ctx.is(erc165, true);
21 | });
22 |
23 | spec.test('checks if 0xffffffff is false', async (ctx) => {
24 | const supportsInterface = ctx.get('supportsInterface');
25 | const erc165 = await supportsInterface.instance.methods.supportsInterface('0xffffffff').call();
26 | ctx.is(erc165, false);
27 | });
28 |
29 | export default spec;
30 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-utils-contracts/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "es6",
5 | "noImplicitAny": false,
6 | "removeComments": true,
7 | "sourceMap": true,
8 | "outDir": "dist",
9 | "declaration": true,
10 | "experimentalDecorators": true,
11 | "allowSyntheticDefaultImports": true
12 | }
13 | }
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-utils/nodemon.json:
--------------------------------------------------------------------------------
1 | {
2 | "ignore": ["dist/*"],
3 | "ext": "js,ts"
4 | }
5 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-utils/src/index.ts:
--------------------------------------------------------------------------------
1 | export * from './lib/abi';
2 | export * from './lib/normalize-address';
3 | export * from './lib/big-number';
4 | export * from './lib/encoder';
5 | export * from './lib/hex-to-bytes';
6 | export * from './lib/left-pad';
7 | export * from './lib/right-pad';
8 | export * from './lib/string-to-hex';
9 | export * from './lib/zero-address';
10 | export * from './types/utils';
11 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-utils/src/lib/abi.ts:
--------------------------------------------------------------------------------
1 | import { AbiCoder } from 'ethers/utils/abi-coder';
2 |
3 | const coder = new AbiCoder();
4 |
5 | /**
6 | * Encodes parameters for smart contract call.
7 | * @param types Input types.
8 | * @param values Input values.
9 | */
10 | export function encodeParameters(types: any, values: Array): string {
11 | return coder.encode(types, values);
12 | }
13 |
14 | /**
15 | * Decodes parameters from smart contract return.
16 | * @param types Output types.
17 | * @param data Output data.
18 | */
19 | export function decodeParameters(types: any, data: any): any {
20 | return coder.decode(types, data);
21 | }
22 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-utils/src/lib/big-number.ts:
--------------------------------------------------------------------------------
1 | import { bigNumberify as toBN } from 'ethers/utils/bignumber';
2 | export { BigNumber } from 'ethers/utils/bignumber';
3 |
4 | /**
5 | * Converts arbitrary number to a BigNumber format.
6 | * @param value Arbitrary number.
7 | */
8 | export function bigNumberify(value: any) {
9 | return toBN(value);
10 | }
11 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-utils/src/lib/encoder.ts:
--------------------------------------------------------------------------------
1 | import { AbiCoder } from 'ethers/utils/abi-coder';
2 | import { getAddress } from 'ethers/utils/address';
3 | import { Encode } from '../types/utils';
4 |
5 | export class Encoder implements Encode {
6 |
7 | private coder: AbiCoder = new AbiCoder();
8 |
9 | /**
10 | * Encodes parameters for smart contract call.
11 | * @param types Input types.
12 | * @param values Input values.
13 | */
14 | public encodeParameters(types: any, values: Array): string {
15 | return this.coder.encode(types, values);
16 | }
17 |
18 | /**
19 | * Decodes parameters from smart contract return.
20 | * @param types Output types.
21 | * @param data Output data.
22 | */
23 | public decodeParameters(types: any, data: any): any {
24 | return this.coder.decode(types, data);
25 | }
26 |
27 | /**
28 | * Converts ethereum address to checksum format.
29 | * @see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-55.md
30 | */
31 | public normalizeAddress(address: string): string {
32 | return address ? getAddress(address) : null;
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-utils/src/lib/hex-to-bytes.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * @note Based on: https://github.com/ethereum/web3.js/blob/1.0/packages/web3-utils/src/utils.js
3 | */
4 | export function hexToBytes(hex: any) {
5 | hex = hex.toString(16).replace(/^0x/i, '');
6 | const bytes = [];
7 |
8 | for (let c = 0; c < hex.length; c += 2) {
9 | bytes.push(parseInt(hex.substr(c, 2), 16));
10 | }
11 |
12 | return bytes;
13 | }
14 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-utils/src/lib/left-pad.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Should be called to pad string to expected length
3 | * @note Based on: https://github.com/ethereum/web3.js/blob/1.0/packages/web3-utils/src/utils.js
4 | * @param string String to be padded.
5 | * @param chars Chars that result string should have.
6 | * @param sign Sign by default 0.
7 | * @param prefix Prefix by default calculated depending on input.
8 | */
9 | export function leftPad(input: any, chars: number, sign?: string, prefix?: boolean) {
10 | const hasPrefix = prefix === undefined ? /^0x/i.test(input) || typeof input === 'number' : prefix;
11 | input = input.toString(16).replace(/^0x/i, '');
12 | const padding = (chars - input.length + 1 >= 0) ? chars - input.length + 1 : 0;
13 |
14 | return (hasPrefix ? '0x' : '') + new Array(padding).join(sign ? sign : '0') + input;
15 | }
16 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-utils/src/lib/normalize-address.ts:
--------------------------------------------------------------------------------
1 | import { getAddress } from 'ethers/utils/address';
2 |
3 | /**
4 | * Converts ethereum address to checksum format.
5 | * @see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-55.md
6 | */
7 | export function normalizeAddress(address: string): string {
8 | return address ? getAddress(address.toLowerCase()) : null;
9 | }
10 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-utils/src/lib/right-pad.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Should be called to pad string to expected length
3 | * @note Based on: https://github.com/ethereum/web3.js/blob/1.0/packages/web3-utils/src/utils.js
4 | * @param string String to be padded.
5 | * @param chars Chars that result string should have.
6 | * @param sign Sign by default 0.
7 | */
8 | export function rightPad(input: any, chars: number, sign?: string, prefix?: boolean) {
9 | const hasPrefix = prefix === undefined ? /^0x/i.test(input) || typeof input === 'number' : prefix;
10 | input = input.toString(16).replace(/^0x/i, '');
11 |
12 | const padding = (chars - input.length + 1 >= 0) ? chars - input.length + 1 : 0;
13 |
14 | return (hasPrefix ? '0x' : '') + input + (new Array(padding).join(sign ? sign : '0'));
15 | }
16 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-utils/src/lib/string-to-hex.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Changes string to hex representation.
3 | * @param str String to change into hex.
4 | */
5 | export function stringToHex(str: String) {
6 | let result = '';
7 | for (let i = 0; i < str.length; i++) {
8 | result += str.charCodeAt(i).toString(16);
9 | }
10 | return result;
11 | }
12 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-utils/src/lib/zero-address.ts:
--------------------------------------------------------------------------------
1 | export const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000';
2 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-utils/src/tests/normalize-address.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@hayspec/spec';
2 | import { normalizeAddress } from '../lib/normalize-address';
3 |
4 | const spec = new Spec();
5 |
6 | spec.test('normalize address', (ctx) => {
7 | ctx.is(normalizeAddress('0x85A9916425960aA35B2a527D77C71855DC0215B3'), '0x85A9916425960aA35B2a527D77C71855DC0215B3');
8 | ctx.is(normalizeAddress('0x85a9916425960aa35b2a527d77c71855dc0215b3'), '0x85A9916425960aA35B2a527D77C71855DC0215B3');
9 | ctx.is(normalizeAddress('0x85A9916425960AA35B2A527D77C71855DC0215B3'), '0x85A9916425960aA35B2a527D77C71855DC0215B3');
10 | ctx.is(normalizeAddress('85A9916425960aA35B2a527D77C71855DC0215B3'), '0x85A9916425960aA35B2a527D77C71855DC0215B3');
11 | ctx.is(normalizeAddress('0x85A9916425960aA35B2a527D77C71855DC0215b3'), '0x85A9916425960aA35B2a527D77C71855DC0215B3');
12 | ctx.is(normalizeAddress(null), null);
13 | ctx.throws(() => normalizeAddress('dfg'));
14 | });
15 |
16 | export default spec;
17 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-utils/src/types/utils.ts:
--------------------------------------------------------------------------------
1 | export interface Encode {
2 |
3 | /**
4 | * Converts address to checksum format.
5 | * @param address Address to covert.
6 | */
7 | normalizeAddress(address: string): string;
8 |
9 | /**
10 | * Encodes parameters for smart contract call.
11 | * @param types Input types.
12 | * @param values Input values.
13 | */
14 | encodeParameters(types: any, values: Array): string;
15 |
16 | /**
17 | * Decodes parameters from smart contract return.
18 | * @param types Output types.
19 | * @param data Output data.
20 | */
21 | decodeParameters(types: any, data: any): any;
22 | }
23 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-utils/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "es6",
5 | "noImplicitAny": false,
6 | "removeComments": true,
7 | "sourceMap": true,
8 | "outDir": "dist",
9 | "declaration": true,
10 | "experimentalDecorators": true,
11 | "allowSyntheticDefaultImports": true
12 | }
13 | }
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-value-ledger/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | > Value ledger module for currency management on the Ethereum blockchain.
4 |
5 | The [0xcert Framework](https://docs.0xcert.org) is a free and open-source JavaScript library that provides tools for building powerful decentralized applications. Please refer to the [official documentation](https://docs.0xcert.org) for more details.
6 |
7 | This module is one of the bricks of the [0xcert Framework](https://docs.0xcert.org). It's written with [TypeScript](https://www.typescriptlang.org) and it's actively maintained. The source code is available on [GitHub](https://github.com/0xcert/framework) where you can also find our [issue tracker](https://github.com/0xcert/framework/issues).
8 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-value-ledger/nodemon.json:
--------------------------------------------------------------------------------
1 | {
2 | "ignore": ["dist/*"],
3 | "ext": "js,ts"
4 | }
5 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-value-ledger/src/index.ts:
--------------------------------------------------------------------------------
1 | export { ValueLedgerDeployRecipe, ValueLedgerInfo, ValueLedgerTransferRecipe } from '@0xcert/scaffold';
2 | export * from './core/ledger';
3 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-value-ledger/src/mutations/approve-account.ts:
--------------------------------------------------------------------------------
1 | import { Mutation } from '@0xcert/ethereum-generic-provider';
2 | import { ValueLedger } from '../core/ledger';
3 |
4 | const functionSignature = '0x095ea7b3';
5 | const inputTypes = ['address', 'uint256'];
6 |
7 | /**
8 | * Approves an account for transferring an amount of tokens.
9 | * @param ledger Value ledger instance.
10 | * @param accountId Account address.
11 | * @param value Amount of tokens.
12 | */
13 | export default async function(ledger: ValueLedger, accountId: string, value: string) {
14 | const attrs = {
15 | from: ledger.provider.accountId,
16 | to: ledger.id,
17 | data: functionSignature + ledger.provider.encoder.encodeParameters(inputTypes, [accountId, value]).substr(2),
18 | };
19 | const res = await ledger.provider.post({
20 | method: 'eth_sendTransaction',
21 | params: [attrs],
22 | });
23 | return new Mutation(ledger.provider, res.result, ledger);
24 | }
25 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-value-ledger/src/mutations/deploy.ts:
--------------------------------------------------------------------------------
1 | import { GenericProvider, Mutation } from '@0xcert/ethereum-generic-provider';
2 | import { ValueLedgerDeployRecipe } from '@0xcert/scaffold';
3 | import { fetchJson } from '@0xcert/utils';
4 |
5 | const inputTypes = ['string', 'string', 'uint8', 'uint256'];
6 |
7 | /**
8 | * Deploys a new value ledger.
9 | * @param provider Instance of the provider.
10 | * @param param1 Data needed to deploy a new value ledger.
11 | */
12 | export default async function(provider: GenericProvider, { name, symbol, decimals, supply }: ValueLedgerDeployRecipe) {
13 | const contract = await fetchJson(provider.valueLedgerSource);
14 | const source = contract.TokenMock.evm.bytecode.object;
15 | const attrs = {
16 | from: provider.accountId,
17 | data: `0x${source}${provider.encoder.encodeParameters(inputTypes, [ name, symbol, decimals, supply]).substr(2)}`,
18 | };
19 | const res = await provider.post({
20 | method: 'eth_sendTransaction',
21 | params: [attrs],
22 | });
23 | return new Mutation(provider, res.result);
24 | }
25 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-value-ledger/src/mutations/transfer-from.ts:
--------------------------------------------------------------------------------
1 | import { Mutation } from '@0xcert/ethereum-generic-provider';
2 | import { ValueLedger } from '../core/ledger';
3 |
4 | const functionSignature = '0x23b872dd';
5 | const inputTypes = ['address', 'address', 'uint256'];
6 |
7 | /**
8 | * Transfers tokens that you have been approved from.
9 | * @param ledger Value ledger instance.
10 | * @param senderId Address of the token owner.
11 | * @param receiverId Address of the receiver.
12 | * @param value Amount of tokens.
13 | */
14 | export default async function(ledger: ValueLedger, senderId: string, receiverId: string, value: string) {
15 | const attrs = {
16 | from: ledger.provider.accountId,
17 | to: ledger.id,
18 | data: functionSignature + ledger.provider.encoder.encodeParameters(inputTypes, [senderId, receiverId, value]).substr(2),
19 | };
20 | const res = await ledger.provider.post({
21 | method: 'eth_sendTransaction',
22 | params: [attrs],
23 | });
24 | return new Mutation(ledger.provider, res.result, ledger);
25 | }
26 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-value-ledger/src/mutations/transfer.ts:
--------------------------------------------------------------------------------
1 | import { Mutation } from '@0xcert/ethereum-generic-provider';
2 | import { ValueLedger } from '../core/ledger';
3 |
4 | const functionSignature = '0xa9059cbb';
5 | const inputTypes = ['address', 'uint256'];
6 |
7 | /**
8 | * Transfers your tokens to another account.
9 | * @param ledger Value ledger instance.
10 | * @param receiverId Address of the receiver.
11 | * @param value Amount of tokens.
12 | */
13 | export default async function(ledger: ValueLedger, receiverId: string, value: string) {
14 | const attrs = {
15 | from: ledger.provider.accountId,
16 | to: ledger.id,
17 | data: functionSignature + ledger.provider.encoder.encodeParameters(inputTypes, [receiverId, value]).substr(2),
18 | };
19 | const res = await ledger.provider.post({
20 | method: 'eth_sendTransaction',
21 | params: [attrs],
22 | });
23 | return new Mutation(ledger.provider, res.result, ledger);
24 | }
25 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-value-ledger/src/queries/get-allowance.ts:
--------------------------------------------------------------------------------
1 | import { ValueLedger } from '../core/ledger';
2 |
3 | const functionSignature = '0xdd62ed3e';
4 | const inputTypes = ['address', 'address'];
5 | const outputTypes = ['uint256'];
6 |
7 | /**
8 | * Gets the amount of tokens an account approved for usage to another account.
9 | * @param ledger Value ledger instance.
10 | * @param accountId Token owner account id.
11 | * @param spenderId Approved spender account id.
12 | */
13 | export default async function(ledger: ValueLedger, accountId: string, spenderId: string) {
14 | try {
15 | const attrs = {
16 | to: ledger.id,
17 | data: functionSignature + ledger.provider.encoder.encodeParameters(inputTypes, [accountId, spenderId]).substr(2),
18 | };
19 | const res = await ledger.provider.post({
20 | method: 'eth_call',
21 | params: [attrs, 'latest'],
22 | });
23 | return ledger.provider.encoder.decodeParameters(outputTypes, res.result)[0].toString();
24 | } catch (error) {
25 | ledger.provider.log(error);
26 | return null;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-value-ledger/src/queries/get-balance.ts:
--------------------------------------------------------------------------------
1 | import { ValueLedger } from '../core/ledger';
2 |
3 | const functionSignature = '0x70a08231';
4 | const inputTypes = ['address'];
5 | const outputTypes = ['uint256'];
6 |
7 | /**
8 | * Gets the amount of token an account owns.
9 | * @param ledger Value ledger instance.
10 | * @param accountId Account address.
11 | */
12 | export default async function(ledger: ValueLedger, accountId: string) {
13 | try {
14 | const attrs = {
15 | to: ledger.id,
16 | data: functionSignature + ledger.provider.encoder.encodeParameters(inputTypes, [accountId]).substr(2),
17 | };
18 | const res = await ledger.provider.post({
19 | method: 'eth_call',
20 | params: [attrs, 'latest'],
21 | });
22 | return ledger.provider.encoder.decodeParameters(outputTypes, res.result)[0].toString();
23 | } catch (error) {
24 | ledger.provider.log(error);
25 | return null;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-value-ledger/src/tests/index.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@specron/spec';
2 | import * as ledger from '..';
3 |
4 | const spec = new Spec();
5 |
6 | spec.test('exposes objects', (ctx) => {
7 | ctx.true(!!ledger.ValueLedger);
8 | });
9 |
10 | export default spec;
11 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-value-ledger/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "es6",
5 | "noImplicitAny": false,
6 | "removeComments": true,
7 | "sourceMap": true,
8 | "outDir": "dist",
9 | "declaration": true,
10 | "experimentalDecorators": true,
11 | "allowSyntheticDefaultImports": true
12 | }
13 | }
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-xcert-contracts/.solhint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "solhint:default",
3 | "rules": {
4 | "max-line-length": ["warn", 100]
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-xcert-contracts/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | > Smart contracts used by the Asset ledger on the Ethereum blockchain.
4 |
5 | The [0xcert Framework](https://docs.0xcert.org) is a free and open-source JavaScript library that provides tools for building powerful decentralized applications. Please refer to the [official documentation](https://docs.0xcert.org) for more details.
6 |
7 | This module is one of the bricks of the [0xcert Framework](https://docs.0xcert.org). It's written with [TypeScript](https://www.typescriptlang.org) and it's actively maintained. The source code is available on [GitHub](https://github.com/0xcert/framework) where you can also find our [issue tracker](https://github.com/0xcert/framework/issues).
8 |
9 | # Build
10 |
11 | By default, the contracts in this package are built for Constantinople EVM. If you would like to use these smart contracts for `Wanchain` or other blockchains using EVM for a different version, you will need to rebuild them for the desired version.
12 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-xcert-contracts/nodemon.json:
--------------------------------------------------------------------------------
1 | {
2 | "ignore": ["dist/*"],
3 | "ext": "js,ts"
4 | }
5 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-xcert-contracts/src/contracts/ierc-2477.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 |
3 | pragma solidity 0.8.6;
4 | /**
5 | * @title ERC-2477 Non-Fungible Token Metadata Integrity Standard
6 | * @dev See https://eips.ethereum.org/EIPS/eip-2477
7 | * @dev The ERC-165 identifier for this interface is 0x#######. //TODO: FIX THIS
8 | */
9 | interface ERC2477 /* is ERC165 */ {
10 | /**
11 | * @notice Get the cryptographic hash of the specified tokenID's metadata
12 | * @param tokenId Identifier for a specific token
13 | * @return digest Bytes returned from the hash algorithm
14 | * @return hashAlgorithm The name of the cryptographic hash algorithm
15 | */
16 | function tokenURIIntegrity(uint256 tokenId) external view returns(bytes memory digest, string memory hashAlgorithm);
17 |
18 | /**
19 | * @notice Get the cryptographic hash for the specified tokenID's metadata schema
20 | * @param tokenId Id of the Xcert.
21 | * @return digest Bytes returned from the hash algorithm or "" if there is no schema
22 | * @return hashAlgorithm The name of the cryptographic hash algorithm or "" if there is no schema
23 | */
24 | function tokenURISchemaIntegrity(uint256 tokenId) external view returns(bytes memory digest, string memory hashAlgorithm);
25 | }
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-xcert-contracts/src/contracts/ixcert-burnable.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 |
3 | pragma solidity 0.8.6;
4 |
5 | /**
6 | * @dev Xcert burnable interface.
7 | */
8 | interface XcertBurnable // is Xcert
9 | {
10 |
11 | /**
12 | * @dev Destroys a specified Xcert. Reverts if not called from Xcert owner or operator.
13 | * @param _tokenId Id of the Xcert we want to destroy.
14 | */
15 | function destroy(
16 | uint256 _tokenId
17 | )
18 | external;
19 |
20 | }
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-xcert-contracts/src/contracts/ixcert-mutable.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 |
3 | pragma solidity 0.8.6;
4 |
5 | /**
6 | * @dev Xcert mutable interface.
7 | */
8 | interface XcertMutable // is Xcert
9 | {
10 |
11 | /**
12 | * @dev Updates Xcert tokenURIIntegrityDigest.
13 | * @param _tokenId Id of the Xcert.
14 | * @param _tokenURIIntegrityDigest New tokenURIIntegrityDigest.
15 | */
16 | function updateTokenURIIntegrityDigest(
17 | uint256 _tokenId,
18 | bytes32 _tokenURIIntegrityDigest
19 | )
20 | external;
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-xcert-contracts/src/contracts/ixcert-pausable.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 |
3 | pragma solidity 0.8.6;
4 |
5 | /**
6 | * @dev Xcert pausable interface.
7 | */
8 | interface XcertPausable // is Xcert
9 | {
10 |
11 | /**
12 | * @dev Sets if Xcerts transfers are paused (can be performed) or not.
13 | * @param _isPaused Pause status.
14 | */
15 | function setPause(
16 | bool _isPaused
17 | )
18 | external;
19 |
20 | }
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-xcert-contracts/src/contracts/ixcert-revokable.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 |
3 | pragma solidity 0.8.6;
4 |
5 | /**
6 | * @dev Xcert revokable interface.
7 | */
8 | interface XcertRevokable // is Xcert
9 | {
10 |
11 | /**
12 | * @dev Revokes a specified Xcert. Reverts if not called from contract owner or authorized
13 | * address.
14 | * @param _tokenId Id of the Xcert we want to destroy.
15 | */
16 | function revoke(
17 | uint256 _tokenId
18 | )
19 | external;
20 |
21 | }
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-xcert-contracts/src/contracts/ixcert.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 |
3 | pragma solidity 0.8.6;
4 |
5 | /**
6 | * @dev Xcert interface.
7 | */
8 | interface Xcert // is ERC-721 metadata enumerable, is ERC-2447
9 | {
10 |
11 | /**
12 | * @dev Creates a new Xcert.
13 | * @param _to The address that will own the created Xcert.
14 | * @param _id The Xcert to be created by the msg.sender.
15 | * @param _imprint Cryptographic asset imprint.
16 | */
17 | function create(
18 | address _to,
19 | uint256 _id,
20 | bytes32 _imprint
21 | )
22 | external;
23 |
24 | /**
25 | * @dev Change URI.
26 | * @param _uriPrefix New URI prefix.
27 | * @param _uriPostfix New URI postfix.
28 | */
29 | function setUri(
30 | string calldata _uriPrefix,
31 | string calldata _uriPostfix
32 | )
33 | external;
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-xcert-contracts/src/core/types.ts:
--------------------------------------------------------------------------------
1 | export enum XcertAbilities {
2 | MANAGE_ABILITIES = 1,
3 | ALLOW_MANAGE_ABILITIES = 2,
4 | CREATE_ASSET = 16,
5 | REVOKE_ASSET = 32,
6 | TOGGLE_TRANSFERS = 64,
7 | UPDATE_ASSET_IMPRINT = 128,
8 | UPDATE_URI_BASE = 256,
9 | ALLOW_CREATE_ASSET = 512,
10 | ALLOW_UPDATE_ASSET_IMPRINT = 1024,
11 | }
12 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-xcert-contracts/src/index.ts:
--------------------------------------------------------------------------------
1 | export * from './core/types';
2 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-xcert-contracts/src/tests/full-xcert.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@specron/spec';
2 |
3 | interface Data {
4 | xcert?: any;
5 | }
6 |
7 | const spec = new Spec();
8 |
9 | spec.beforeEach(async (ctx) => {
10 | const xcert = await ctx.deploy({
11 | src: './build/xcert-mock.json',
12 | contract: 'XcertMock',
13 | args: ['Foo', 'F', 'https://0xcert.org/', '.json', '0x9c22ff5f21f0b81b113e63f7db6da94fedef11b2119b4088b89664fb9a3cb658', ['0x9d118770', '0x0d04c3b8', '0xbedb86fb', '0x20c5429b']],
14 | });
15 | ctx.set('xcert', xcert);
16 | });
17 |
18 | spec.test('supports interfaces', async (ctx) => {
19 | const xcert = ctx.get('xcert');
20 | ctx.true(await xcert.instance.methods.supportsInterface('0x9d118770')); // destroyable
21 | ctx.true(await xcert.instance.methods.supportsInterface('0x0d04c3b8')); // mutable
22 | ctx.true(await xcert.instance.methods.supportsInterface('0xbedb86fb')); // pausable
23 | ctx.true(await xcert.instance.methods.supportsInterface('0x20c5429b')); // revokable
24 | ctx.true(await xcert.instance.methods.supportsInterface('0xe08725ee')); // xcert
25 | });
26 |
27 | export default spec;
28 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-xcert-contracts/src/tests/helpers/common.ts:
--------------------------------------------------------------------------------
1 | export function getCurrentTime() {
2 | return Math.floor((new Date().getTime() / 1000));
3 | }
4 |
--------------------------------------------------------------------------------
/packages/0xcert-ethereum-xcert-contracts/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "es6",
5 | "noImplicitAny": false,
6 | "removeComments": true,
7 | "sourceMap": true,
8 | "outDir": "dist",
9 | "declaration": true,
10 | "experimentalDecorators": true,
11 | "allowSyntheticDefaultImports": true
12 | }
13 | }
--------------------------------------------------------------------------------
/packages/0xcert-merkle/nodemon.json:
--------------------------------------------------------------------------------
1 | {
2 | "ignore": ["dist/*"],
3 | "ext": "js,ts"
4 | }
5 |
--------------------------------------------------------------------------------
/packages/0xcert-merkle/src/index.ts:
--------------------------------------------------------------------------------
1 | export * from './core/merkle';
2 |
--------------------------------------------------------------------------------
/packages/0xcert-merkle/src/tests/index.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@hayspec/spec';
2 | import * as merkle from '..';
3 |
4 | const spec = new Spec();
5 |
6 | spec.test('exposes objects', (ctx) => {
7 | ctx.true(!!merkle.Merkle);
8 | });
9 |
10 | export default spec;
11 |
--------------------------------------------------------------------------------
/packages/0xcert-merkle/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "es6",
5 | "noImplicitAny": false,
6 | "removeComments": true,
7 | "sourceMap": true,
8 | "outDir": "dist",
9 | "declaration": true,
10 | "experimentalDecorators": true,
11 | "allowSyntheticDefaultImports": true
12 | }
13 | }
--------------------------------------------------------------------------------
/packages/0xcert-scaffold/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | > Overarching module with types, enums, and interfaces for easier development of interoperable modules.
4 |
5 | The [0xcert Framework](https://docs.0xcert.org) is a free and open-source JavaScript library that provides tools for building powerful decentralized applications. Please refer to the [official documentation](https://docs.0xcert.org) for more details.
6 |
7 | This module is one of the bricks of the [0xcert Framework](https://docs.0xcert.org). It's written with [TypeScript](https://www.typescriptlang.org) and it's actively maintained. The source code is available on [GitHub](https://github.com/0xcert/framework) where you can also find our [issue tracker](https://github.com/0xcert/framework/issues).
8 |
9 | # Scaffold Interfaces
10 |
11 | These TypeScript interfaces are platform-agnostic base types which are implemented separately in for each provider.
12 |
13 | Or in plain English, these are the base data structures in the 0xcert protocol regardless of whether you are using it on a blockchain or MongoDB.
--------------------------------------------------------------------------------
/packages/0xcert-scaffold/nodemon.json:
--------------------------------------------------------------------------------
1 | {
2 | "ignore": ["dist/*"],
3 | "ext": "js,ts"
4 | }
5 |
--------------------------------------------------------------------------------
/packages/0xcert-scaffold/src/assets/metadata.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Definition of asset metadata.
3 | */
4 | export interface AssetMetadata {
5 |
6 | /**
7 | * A detailed description of an asset.
8 | */
9 | description?: string;
10 |
11 | /**
12 | * A valid URI pointing to a resource with mime type image/* representing the asset to which this NFT represents. Consider making any images at a width between 320 and 1080 pixels and aspect ratio between 1.91:1 and 4:5 inclusive.
13 | */
14 | image?: string;
15 |
16 | /**
17 | * A name of an asset.
18 | */
19 | name?: string;
20 | }
21 |
--------------------------------------------------------------------------------
/packages/0xcert-scaffold/src/core/provider.ts:
--------------------------------------------------------------------------------
1 | import { ProviderIssue } from './issues';
2 | import messages from './messages';
3 |
4 | /**
5 | * A provider is a connection to a blockchain or other database store.
6 | */
7 | export interface ProviderBase {
8 | accountId: string;
9 | }
10 |
11 | /**
12 | * Provider events.
13 | */
14 | export enum ProviderEvent {
15 | ACCOUNT_CHANGE = 'accountChanged',
16 | NETWORK_CHANGE = 'networkChanged',
17 | }
18 |
19 | /**
20 | * Handled system error.
21 | */
22 | export class ProviderError extends Error {
23 |
24 | /**
25 | * Specific kind of error.
26 | */
27 | public issue: ProviderIssue;
28 |
29 | /**
30 | * Original error report.
31 | */
32 | public original: any;
33 |
34 | /**
35 | * Class constructor.
36 | * @param issue Issue identification.
37 | * @param details Original error object.
38 | */
39 | public constructor(issue: ProviderIssue, original?: any) {
40 | super();
41 |
42 | this.name = 'ProviderError';
43 | this.issue = issue;
44 | this.original = original;
45 | this.message = messages[issue] || `GenericProvider error [issue: ${issue}]`;
46 |
47 | if (Error.captureStackTrace) {
48 | Error.captureStackTrace(this, this.constructor);
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/packages/0xcert-scaffold/src/index.ts:
--------------------------------------------------------------------------------
1 | export * from './assets/metadata';
2 | export * from './core/provider';
3 | export * from './core/asset-ledger';
4 | export * from './core/mutation';
5 | export * from './core/gateway';
6 | export * from './core/value-ledger';
7 | export * from './core/issues';
8 |
--------------------------------------------------------------------------------
/packages/0xcert-scaffold/src/tests/index.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@hayspec/spec';
2 | import * as scaffold from '..';
3 |
4 | const spec = new Spec();
5 |
6 | spec.test('compile all files', (ctx) => {
7 | ctx.is(
8 | typeof scaffold,
9 | typeof scaffold,
10 | );
11 | });
12 |
13 | export default spec;
14 |
--------------------------------------------------------------------------------
/packages/0xcert-scaffold/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "es6",
5 | "noImplicitAny": false,
6 | "removeComments": true,
7 | "sourceMap": true,
8 | "outDir": "dist",
9 | "declaration": true,
10 | "experimentalDecorators": true,
11 | "allowSyntheticDefaultImports": true
12 | }
13 | }
--------------------------------------------------------------------------------
/packages/0xcert-utils/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | > General utility module with common helper functions.
4 |
5 | The [0xcert Framework](https://docs.0xcert.org) is a free and open-source JavaScript library that provides tools for building powerful decentralized applications. Please refer to the [official documentation](https://docs.0xcert.org) for more details.
6 |
7 | This module is one of the bricks of the [0xcert Framework](https://docs.0xcert.org). It's written with [TypeScript](https://www.typescriptlang.org) and it's actively maintained. The source code is available on [GitHub](https://github.com/0xcert/framework) where you can also find our [issue tracker](https://github.com/0xcert/framework/issues).
8 |
9 | # Utilities
10 |
11 | This small collection of functions is a convenience for common situations programming in TypeScript.
12 |
--------------------------------------------------------------------------------
/packages/0xcert-utils/nodemon.json:
--------------------------------------------------------------------------------
1 | {
2 | "ignore": ["dist/*"],
3 | "ext": "js,ts"
4 | }
5 |
--------------------------------------------------------------------------------
/packages/0xcert-utils/src/index.ts:
--------------------------------------------------------------------------------
1 | export * from './methods/fetch';
2 | export * from './methods/sha';
3 | export * from './methods/keccak';
4 | export * from './methods/to-float';
5 | export * from './methods/to-integer';
6 | export * from './methods/to-seconds';
7 | export * from './methods/to-string';
8 | export * from './methods/to-tuple';
9 |
--------------------------------------------------------------------------------
/packages/0xcert-utils/src/methods/fetch.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Universal fetch method reads remote or local JSON file.
3 | * @param path URL or local path.
4 | */
5 | export async function fetchJson(path, options?): Promise {
6 | if (typeof window !== 'undefined') {
7 | return (window as any).fetch(path, options).then((r) => r.json());
8 | } else if (path.lastIndexOf('http', 0) !== 0) {
9 | try { // UI with SSR sometimes can't find `fs` module, but it's not needed
10 | return require('fs').promises.readFile(path, 'utf8').then((d) => JSON.parse(d));
11 | } catch (e) {
12 | return null;
13 | }
14 | } else {
15 | return require('node-fetch')(path, options).then((r) => r.json());
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/packages/0xcert-utils/src/methods/keccak.ts:
--------------------------------------------------------------------------------
1 | import * as Hash from 'eth-lib/src/hash';
2 |
3 | /**
4 | * Generates keccak256 hash.
5 | */
6 | export function keccak256(input: any) {
7 | return Hash.keccak256(input);
8 | }
9 |
--------------------------------------------------------------------------------
/packages/0xcert-utils/src/methods/sha.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Converts a message into SHA256 hash string.
3 | * @param bits Number of bits (e.g. 256).
4 | * @param message Text message.
5 | */
6 | export async function sha(bits: number, message: string) {
7 | if (typeof window !== 'undefined') {
8 | const msgBuffer = new (window as any)['TextEncoder']('utf-8').encode(message);
9 | const hashBuffer = await window['crypto'].subtle.digest(`SHA-${bits}`, msgBuffer);
10 | const hashArray = Array.from(new Uint8Array(hashBuffer));
11 | return hashArray.map((b) => (`00${b.toString(16)}`).slice(-2)).join('');
12 | } else {
13 | return require('crypto').createHash(`sha${bits}`).update(message).digest('hex');
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/packages/0xcert-utils/src/methods/to-float.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Converts number to float.
3 | */
4 | export function toFloat(val: number) {
5 | return parseFloat(`${val}`) || 0;
6 | }
7 |
--------------------------------------------------------------------------------
/packages/0xcert-utils/src/methods/to-integer.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Converts numeric values to integer.
3 | */
4 | export function toInteger(val: number | string | boolean) {
5 | if (typeof val === 'number' && val > Number.MAX_SAFE_INTEGER) {
6 | return 0;
7 | } else if (typeof val === 'boolean' && val === true) {
8 | return 1;
9 | } else {
10 | return parseInt(`${val}`) || 0;
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/packages/0xcert-utils/src/methods/to-seconds.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Converts time in milliseconds to the appropriate ethereum timestamp.
3 | */
4 | export function toSeconds(milliseconds: number) {
5 | return parseInt(`${parseFloat(`${milliseconds}`) / 1000}`) || 0;
6 | }
7 |
--------------------------------------------------------------------------------
/packages/0xcert-utils/src/methods/to-string.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Converts a value to string.
3 | */
4 | export function toString(val: any) {
5 | return val !== null && val !== undefined ? val.toString() : null;
6 | }
7 |
--------------------------------------------------------------------------------
/packages/0xcert-utils/src/methods/to-tuple.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Transforms an object into web3 tuple type.
3 | * @param obj Web3 structure as object.
4 | */
5 | export function toTuple(obj) {
6 | if (!(obj instanceof Object)) {
7 | return [];
8 | }
9 |
10 | const output = [];
11 | let i = 0;
12 | Object.keys(obj).forEach((k) => {
13 | if (obj[k] instanceof Object) {
14 | output[i] = toTuple(obj[k]);
15 | } else if (obj[k] instanceof Array) {
16 | let j1 = 0;
17 | const temp1 = [];
18 | obj[k].forEach((ak) => {
19 | temp1[j1] = toTuple(obj[k]);
20 | j1++;
21 | });
22 | output[i] = temp1;
23 | } else {
24 | output[i] = obj[k];
25 | }
26 | i++;
27 | });
28 |
29 | return output;
30 | }
31 |
--------------------------------------------------------------------------------
/packages/0xcert-utils/src/tests/index.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@hayspec/spec';
2 | import * as utils from '..';
3 |
4 | const spec = new Spec();
5 |
6 | spec.test('exposes objects', (ctx) => {
7 | ctx.true(!!utils.sha);
8 | ctx.true(!!utils.keccak256);
9 | ctx.true(!!utils.toFloat);
10 | ctx.true(!!utils.toInteger);
11 | ctx.true(!!utils.toSeconds);
12 | ctx.true(!!utils.toString);
13 | ctx.true(!!utils.toTuple);
14 | ctx.true(!!utils.fetchJson);
15 | });
16 |
17 | export default spec;
18 |
--------------------------------------------------------------------------------
/packages/0xcert-utils/src/tests/methods/fetch.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@hayspec/spec';
2 | import * as path from 'path';
3 | import { fetchJson } from '../../methods/fetch';
4 |
5 | const spec = new Spec();
6 |
7 | spec.test('downloads a remote file', async (ctx) => {
8 | const res = await fetchJson('https://docs.0xcert.org/xcert-mock.json');
9 | ctx.true(!!res.XcertMock);
10 | });
11 |
12 | spec.test('reads a local file', async (ctx) => {
13 | const res = await fetchJson(path.join(__dirname, '..', 'mocks', 'xcert-mock.json'));
14 | ctx.true(!!res.XcertMock);
15 | });
16 |
17 | export default spec;
18 |
--------------------------------------------------------------------------------
/packages/0xcert-utils/src/tests/methods/keccak.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@hayspec/spec';
2 | import { keccak256 } from '../../methods/keccak';
3 |
4 | const spec = new Spec();
5 |
6 | spec.test('converts string into keccak256 hash', async (ctx) => {
7 | ctx.is(keccak256('foo#'), '0xe7bb87eda991af44cdb673a7d5f2bfeb854dd089e421b3934d022fc5c29259a0');
8 | ctx.is(keccak256('bar!'), '0x179eb773d34690d312adc3f96661402e2de2009e39dbf4b8dee22b3adc842752');
9 | });
10 |
11 | export default spec;
12 |
--------------------------------------------------------------------------------
/packages/0xcert-utils/src/tests/methods/sha.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@hayspec/spec';
2 | import { sha } from '../../methods/sha';
3 |
4 | const spec = new Spec();
5 |
6 | spec.test('converts string into SHA256 hash', async (ctx) => {
7 | ctx.is(await sha(256, 'foo#'), '18845243706c9f9a00b514348b58edd82fe708a68393ccbb3f70e1599577a148');
8 | ctx.is(await sha(256, 'bar!'), 'e687b749f2cd93615923a2f705faace4033f35d57ccfca652cdc39616a94a3c2');
9 | });
10 |
11 | export default spec;
12 |
--------------------------------------------------------------------------------
/packages/0xcert-utils/src/tests/methods/to-float.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@hayspec/spec';
2 | import { toFloat } from '../..';
3 |
4 | const spec = new Spec();
5 |
6 | spec.test('converts numbers to floats', (ctx) => {
7 | ctx.is(toFloat(9000), 9000);
8 | ctx.is(toFloat(9000.1982), 9000.1982);
9 | ctx.is(toFloat(0.1982), 0.1982);
10 | ctx.is(toFloat('10000.124' as any), 10000.124);
11 | });
12 |
13 | spec.test('handles non-numeric and other invalid values', (ctx) => {
14 | ctx.is(toFloat('foo' as any), 0);
15 | ctx.is(toFloat(null), 0);
16 | ctx.is(toFloat(undefined), 0);
17 | });
18 |
19 | export default spec;
20 |
--------------------------------------------------------------------------------
/packages/0xcert-utils/src/tests/methods/to-integer.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@hayspec/spec';
2 | import { toInteger } from '../..';
3 |
4 | const spec = new Spec();
5 |
6 | spec.test('converts floats to integers', (ctx) => {
7 | ctx.is(toInteger(9000), 9000);
8 | ctx.is(toInteger(9000.1982), 9000);
9 | ctx.is(toInteger(0.1982), 0);
10 | ctx.is(toInteger('10000.124'), 10000);
11 | });
12 |
13 | spec.test('handles non-numeric and other invalid values', (ctx) => {
14 | ctx.is(toInteger('foo' as any), 0);
15 | ctx.is(toInteger(null), 0);
16 | ctx.is(toInteger(true), 1);
17 | ctx.is(toInteger(false), 0);
18 | ctx.is(toInteger(undefined), 0);
19 | ctx.is(toInteger(2 ** 100), 0); // too big
20 | });
21 |
22 | export default spec;
23 |
--------------------------------------------------------------------------------
/packages/0xcert-utils/src/tests/methods/to-seconds.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@hayspec/spec';
2 | import { toSeconds } from '../..';
3 |
4 | const spec = new Spec();
5 |
6 | spec.test('converts milliseconds to seconds', (ctx) => {
7 | ctx.is(toSeconds(9000), 9);
8 | ctx.is(toSeconds(9000.1982), 9);
9 | ctx.is(toSeconds(0.1982), 0);
10 | ctx.is(toSeconds('10000.124' as any), 10);
11 | });
12 |
13 | spec.test('handles non-numeric and other invalid values', (ctx) => {
14 | ctx.is(toSeconds('foo' as any), 0);
15 | ctx.is(toSeconds(null), 0);
16 | ctx.is(toSeconds(undefined), 0);
17 | });
18 |
19 | export default spec;
20 |
--------------------------------------------------------------------------------
/packages/0xcert-utils/src/tests/methods/to-string.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@hayspec/spec';
2 | import { toString } from '../..';
3 |
4 | const spec = new Spec();
5 |
6 | spec.test('converts value to string', (ctx) => {
7 | ctx.is(toString(undefined), null);
8 | ctx.is(toString(null), null);
9 | ctx.is(toString(''), '');
10 | ctx.is(toString(NaN), 'NaN');
11 | ctx.is(toString(Infinity), 'Infinity');
12 | ctx.is(toString(true), 'true');
13 | ctx.is(toString(100.1), '100.1');
14 | ctx.is(toString([1, 2]), '1,2');
15 | });
16 |
17 | export default spec;
18 |
--------------------------------------------------------------------------------
/packages/0xcert-utils/src/tests/methods/to-tuple.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@hayspec/spec';
2 | import { toTuple } from '../..';
3 |
4 | const spec = new Spec();
5 |
6 | spec.test('transforms an object to tuple', (ctx) => {
7 | const res = toTuple({
8 | foo: 'FOO',
9 | bar: ['BAR1', 'BAR2'],
10 | baz: {
11 | bazfoo: [1, 2],
12 | bazbar: 'BAZBAR',
13 | },
14 | zed: [
15 | {
16 | zedfoo: [1, 2],
17 | zedbar: 'BAZBAR',
18 | },
19 | ],
20 | });
21 | ctx.deepEqual(res, [
22 | 'FOO',
23 | ['BAR1', 'BAR2'],
24 | [[1, 2], 'BAZBAR'],
25 | [[[1, 2], 'BAZBAR']],
26 | ]);
27 | });
28 |
29 | export default spec;
30 |
--------------------------------------------------------------------------------
/packages/0xcert-utils/src/tests/mocks/xcert-mock.json:
--------------------------------------------------------------------------------
1 | {
2 | "XcertMock": {}
3 | }
--------------------------------------------------------------------------------
/packages/0xcert-utils/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "es6",
5 | "noImplicitAny": false,
6 | "removeComments": true,
7 | "sourceMap": true,
8 | "outDir": "dist",
9 | "declaration": true,
10 | "experimentalDecorators": true,
11 | "allowSyntheticDefaultImports": true
12 | }
13 | }
--------------------------------------------------------------------------------
/packages/0xcert-vue-example/.gitignore:
--------------------------------------------------------------------------------
1 | # dependencies
2 | node_modules
3 |
4 | # logs
5 | npm-debug.log
6 |
7 | # Nuxt build
8 | .nuxt
9 |
10 | # Nuxt generate
11 | dist
12 |
13 | # infrastructure secrets & temp files
14 | infra-params-secrets.json
15 | infra/temp
16 |
--------------------------------------------------------------------------------
/packages/0xcert-vue-example/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | > VueJS plug-in example for NuxtJS.
4 |
5 | Run `rushx dev` to start the application.
6 |
7 | The [0xcert Framework](https://docs.0xcert.org) is a free and open-source JavaScript library that provides tools for building powerful decentralized applications. Please refer to the [official documentation](https://docs.0xcert.org) for more details.
8 |
9 | This module is one of the bricks of the [0xcert Framework](https://docs.0xcert.org). It's written with [TypeScript](https://www.typescriptlang.org) and it's actively maintained. The source code is available on [GitHub](https://github.com/0xcert/framework) where you can also find our [issue tracker](https://github.com/0xcert/framework/issues).
10 |
--------------------------------------------------------------------------------
/packages/0xcert-vue-example/nuxt.config.js:
--------------------------------------------------------------------------------
1 | export default {
2 | build: {
3 | extend(config, { isDev }) {
4 | if (isDev) config.resolve.symlinks = false
5 | },
6 | },
7 | plugins: [
8 | { src: '~/plugins/0xcert', ssr: false },
9 | ],
10 | }
11 |
--------------------------------------------------------------------------------
/packages/0xcert-vue-example/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@0xcert/vue-example",
3 | "version": "0.0.0",
4 | "description": "VueJS plug-in example for NuxtJS.",
5 | "scripts": {
6 | "build": "",
7 | "dev": "npx nuxt",
8 | "test": ""
9 | },
10 | "dependencies": {
11 | "@0xcert/cert": "2.1.1",
12 | "@0xcert/conventions": "2.1.1",
13 | "@0xcert/ethereum-asset-ledger": "2.1.1",
14 | "@0xcert/ethereum-gateway": "2.1.1",
15 | "@0xcert/ethereum-value-ledger": "2.1.1",
16 | "@0xcert/ethereum-metamask-provider": "2.1.1",
17 | "@0xcert/vue-plugin": "2.1.1",
18 | "nuxt": "2.14.7"
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/packages/0xcert-vue-example/plugins/0xcert.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue'
2 | import { Vue0xcert } from '@0xcert/vue-plugin'
3 | import { MetamaskProvider, ProviderEvent } from '@0xcert/ethereum-metamask-provider'
4 | import { Cert } from '@0xcert/cert'
5 | import { AssetLedger } from '@0xcert/ethereum-asset-ledger'
6 | import { ValueLedger } from '@0xcert/ethereum-value-ledger'
7 | import { Gateway } from '@0xcert/ethereum-gateway'
8 |
9 | const provider = new MetamaskProvider()
10 | provider.on(ProviderEvent.ACCOUNT_CHANGE, (newAccountId, oldAccountId) => {
11 | if (oldAccountId) location.reload()
12 | })
13 | provider.on(ProviderEvent.NETWORK_CHANGE, (newNetworkVersion, oldNetworkId) => {
14 | if (oldNetworkId) location.reload()
15 | })
16 |
17 | Vue.use(Vue0xcert, {
18 | provider,
19 | modules: [
20 | { name: 'Cert', object: Cert },
21 | { name: 'AssetLedger', object: AssetLedger },
22 | { name: 'ValueLedger', object: ValueLedger },
23 | { name: 'Gateway', object: Gateway },
24 | ],
25 | })
26 |
--------------------------------------------------------------------------------
/packages/0xcert-vue-plugin/nodemon.json:
--------------------------------------------------------------------------------
1 | {
2 | "ignore": ["dist/*"],
3 | "ext": "js,ts"
4 | }
5 |
--------------------------------------------------------------------------------
/packages/0xcert-vue-plugin/src/core/plugin.ts:
--------------------------------------------------------------------------------
1 | import { Client } from './client';
2 |
3 | /**
4 | *
5 | */
6 | export const Vue0xcert = {
7 | install(Vue, options) {
8 | Vue.prototype.$0xcert = new Client(options);
9 | },
10 | };
11 |
12 | /**
13 | * The plugin is automatically installed when loaded in browser (not as module).
14 | */
15 | if (typeof window !== 'undefined' && !!window['Vue']) {
16 | (window as any)['Vue'].use(Vue0xcert);
17 | }
18 |
--------------------------------------------------------------------------------
/packages/0xcert-vue-plugin/src/index.ts:
--------------------------------------------------------------------------------
1 | export * from './core/client';
2 | export * from './core/plugin';
3 |
--------------------------------------------------------------------------------
/packages/0xcert-vue-plugin/src/tests/index.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@hayspec/spec';
2 | import * as view from '..';
3 |
4 | const spec = new Spec();
5 |
6 | spec.test('exposes objects', (ctx) => {
7 | ctx.true(!!view.Client);
8 | ctx.true(!!view.Vue0xcert);
9 | });
10 |
11 | export default spec;
12 |
--------------------------------------------------------------------------------
/packages/0xcert-vue-plugin/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "es6",
5 | "noImplicitAny": false,
6 | "removeComments": true,
7 | "sourceMap": true,
8 | "outDir": "dist",
9 | "declaration": true,
10 | "experimentalDecorators": true,
11 | "allowSyntheticDefaultImports": true
12 | }
13 | }
--------------------------------------------------------------------------------
/packages/0xcert-wanchain-asset-ledger/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | > Asset ledger module for asset management on the Wanchain blockchain.
4 |
5 | The [0xcert Framework](https://docs.0xcert.org) is a free and open-source JavaScript library that provides tools for building powerful decentralized applications. Please refer to the [official documentation](https://docs.0xcert.org) for more details.
6 |
7 | This module is one of the bricks of the [0xcert Framework](https://docs.0xcert.org). It's written with [TypeScript](https://www.typescriptlang.org) and it's actively maintained. The source code is available on [GitHub](https://github.com/0xcert/framework) where you can also find our [issue tracker](https://github.com/0xcert/framework/issues).
8 |
--------------------------------------------------------------------------------
/packages/0xcert-wanchain-asset-ledger/nodemon.json:
--------------------------------------------------------------------------------
1 | {
2 | "ignore": ["dist/*"],
3 | "ext": "js,ts"
4 | }
5 |
--------------------------------------------------------------------------------
/packages/0xcert-wanchain-asset-ledger/src/core/ledger.ts:
--------------------------------------------------------------------------------
1 | import * as ethereum from '@0xcert/ethereum-asset-ledger';
2 |
3 | /**
4 | * Wanchain asset ledger implementation.
5 | */
6 | export class AssetLedger extends ethereum.AssetLedger { }
7 |
--------------------------------------------------------------------------------
/packages/0xcert-wanchain-asset-ledger/src/index.ts:
--------------------------------------------------------------------------------
1 | export { AssetLedgerBase, AssetLedgerDeployRecipe, AssetLedgerAbility, GeneralAssetLedgerAbility,
2 | SuperAssetLedgerAbility, AssetLedgerItem, AssetLedgerCapability, AssetLedgerInfo,
3 | AssetLedgerItemRecipe, AssetLedgerTransferRecipe, AssetLedgerObjectUpdateRecipe,
4 | AssetLedgerUpdateRecipe } from '@0xcert/ethereum-asset-ledger';
5 | export * from './core/ledger';
6 |
--------------------------------------------------------------------------------
/packages/0xcert-wanchain-asset-ledger/src/tests/index.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@hayspec/spec';
2 | import * as ledger from '..';
3 |
4 | const spec = new Spec();
5 |
6 | spec.test('exposes objects', (ctx) => {
7 | ctx.true(!!ledger.AssetLedger);
8 | ctx.true(!!ledger.GeneralAssetLedgerAbility);
9 | ctx.true(!!ledger.SuperAssetLedgerAbility);
10 | ctx.true(!!ledger.AssetLedgerCapability);
11 | });
12 |
13 | export default spec;
14 |
--------------------------------------------------------------------------------
/packages/0xcert-wanchain-asset-ledger/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "es6",
5 | "noImplicitAny": false,
6 | "removeComments": true,
7 | "sourceMap": true,
8 | "outDir": "dist",
9 | "declaration": true,
10 | "experimentalDecorators": true,
11 | "allowSyntheticDefaultImports": true
12 | }
13 | }
--------------------------------------------------------------------------------
/packages/0xcert-wanchain-gateway/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | > Order gateway module for executing atomic operations on the Wanchain blockchain.
4 |
5 | The [0xcert Framework](https://docs.0xcert.org) is a free and open-source JavaScript library that provides tools for building powerful decentralized applications. Please refer to the [official documentation](https://docs.0xcert.org) for more details.
6 |
7 | This module is one of the bricks of the [0xcert Framework](https://docs.0xcert.org). It's written with [TypeScript](https://www.typescriptlang.org) and it's actively maintained. The source code is available on [GitHub](https://github.com/0xcert/framework) where you can also find our [issue tracker](https://github.com/0xcert/framework/issues).
8 |
--------------------------------------------------------------------------------
/packages/0xcert-wanchain-gateway/nodemon.json:
--------------------------------------------------------------------------------
1 | {
2 | "ignore": ["dist/*"],
3 | "ext": "js,ts"
4 | }
5 |
--------------------------------------------------------------------------------
/packages/0xcert-wanchain-gateway/src/core/gateway.ts:
--------------------------------------------------------------------------------
1 | import * as ethereum from '@0xcert/ethereum-gateway';
2 |
3 | /**
4 | * Wanchain gateway implementation.
5 | */
6 | export class Gateway extends ethereum.Gateway {}
7 |
--------------------------------------------------------------------------------
/packages/0xcert-wanchain-gateway/src/index.ts:
--------------------------------------------------------------------------------
1 | export { ActionsOrderActionKind, DynamicActionsOrder, SignedDynamicActionsOrder, SignedFixedActionsOrder,
2 | FixedActionsOrder, AssetLedgerDeployOrder, ProxyKind } from '@0xcert/ethereum-gateway';
3 | export * from './core/gateway';
4 |
--------------------------------------------------------------------------------
/packages/0xcert-wanchain-gateway/src/tests/index.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@hayspec/spec';
2 | import * as exchange from '..';
3 |
4 | const spec = new Spec();
5 |
6 | spec.test('exposes objects', (ctx) => {
7 | ctx.true(!!exchange.Gateway);
8 | ctx.true(!!exchange.DynamicActionsOrder);
9 | ctx.true(!!exchange.FixedActionsOrder);
10 | ctx.true(!!exchange.SignedDynamicActionsOrder);
11 | ctx.true(!!exchange.SignedFixedActionsOrder);
12 | ctx.true(!!exchange.AssetLedgerDeployOrder);
13 | ctx.true(!!exchange.ProxyKind);
14 | });
15 |
16 | export default spec;
17 |
--------------------------------------------------------------------------------
/packages/0xcert-wanchain-gateway/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "es6",
5 | "noImplicitAny": false,
6 | "removeComments": true,
7 | "sourceMap": true,
8 | "outDir": "dist",
9 | "declaration": true,
10 | "experimentalDecorators": true,
11 | "allowSyntheticDefaultImports": true
12 | }
13 | }
--------------------------------------------------------------------------------
/packages/0xcert-wanchain-generic-provider/CHANGELOG.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@0xcert/wanchain-generic-provider",
3 | "entries": [
4 | {
5 | "version": "2.1.1",
6 | "tag": "@0xcert/wanchain-generic-provider_v2.1.1",
7 | "date": "Mon, 15 Mar 2021 13:36:24 GMT",
8 | "comments": {}
9 | },
10 | {
11 | "version": "2.1.0",
12 | "tag": "@0xcert/wanchain-generic-provider_v2.1.0",
13 | "date": "Thu, 14 Jan 2021 09:48:04 GMT",
14 | "comments": {}
15 | },
16 | {
17 | "version": "2.0.4",
18 | "tag": "@0xcert/wanchain-generic-provider_v2.0.4",
19 | "date": "Thu, 14 Jan 2021 09:44:14 GMT",
20 | "comments": {}
21 | },
22 | {
23 | "version": "2.0.3",
24 | "tag": "@0xcert/wanchain-generic-provider_v2.0.3",
25 | "date": "Wed, 12 Aug 2020 11:26:03 GMT",
26 | "comments": {}
27 | },
28 | {
29 | "version": "2.0.2",
30 | "tag": "@0xcert/wanchain-generic-provider_v2.0.2",
31 | "date": "Mon, 04 May 2020 17:35:38 GMT",
32 | "comments": {}
33 | },
34 | {
35 | "version": "2.0.1",
36 | "tag": "@0xcert/wanchain-generic-provider_v2.0.1",
37 | "date": "Fri, 06 Mar 2020 12:54:59 GMT",
38 | "comments": {}
39 | }
40 | ]
41 | }
42 |
--------------------------------------------------------------------------------
/packages/0xcert-wanchain-generic-provider/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Change Log - @0xcert/wanchain-generic-provider
2 |
3 | This log was last generated on Mon, 15 Mar 2021 13:36:24 GMT and should not be manually modified.
4 |
5 | ## 2.1.1
6 | Mon, 15 Mar 2021 13:36:24 GMT
7 |
8 | *Version update only*
9 |
10 | ## 2.1.0
11 | Thu, 14 Jan 2021 09:48:04 GMT
12 |
13 | *Version update only*
14 |
15 | ## 2.0.4
16 | Thu, 14 Jan 2021 09:44:14 GMT
17 |
18 | *Version update only*
19 |
20 | ## 2.0.3
21 | Wed, 12 Aug 2020 11:26:03 GMT
22 |
23 | *Version update only*
24 |
25 | ## 2.0.2
26 | Mon, 04 May 2020 17:35:38 GMT
27 |
28 | *Version update only*
29 |
30 | ## 2.0.1
31 | Fri, 06 Mar 2020 12:54:59 GMT
32 |
33 | *Initial release*
34 |
35 |
--------------------------------------------------------------------------------
/packages/0xcert-wanchain-generic-provider/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | > Basic implementation of a communication provider for the Wanchain blockchain.
4 |
5 | The [0xcert Framework](https://docs.0xcert.org) is a free and open-source JavaScript library that provides tools for building powerful decentralized applications. Please refer to the [official documentation](https://docs.0xcert.org) for more details.
6 |
7 | This module is one of the bricks of the [0xcert Framework](https://docs.0xcert.org). It's written with [TypeScript](https://www.typescriptlang.org) and it's actively maintained. The source code is available on [GitHub](https://github.com/0xcert/framework) where you can also find our [issue tracker](https://github.com/0xcert/framework/issues).
8 |
--------------------------------------------------------------------------------
/packages/0xcert-wanchain-generic-provider/nodemon.json:
--------------------------------------------------------------------------------
1 | {
2 | "ignore": ["dist/*"],
3 | "ext": "js,ts"
4 | }
5 |
--------------------------------------------------------------------------------
/packages/0xcert-wanchain-generic-provider/src/core/helpers.ts:
--------------------------------------------------------------------------------
1 | import { NetworkKind } from './types';
2 |
3 | /**
4 | * Generates gateway config from deployed contract addresses.
5 | * @notice Configs will changes based on released version.
6 | * @param networkKind Ethereum network kind.
7 | */
8 | export function buildGatewayConfig(networkKind: NetworkKind) {
9 | switch (networkKind) {
10 | case NetworkKind.LIVE:
11 | return {
12 | actionsOrderId: '0x8a85cA5ED516DA0f235647222e89CEfeF85F53e4',
13 | assetLedgerDeployOrderId: '0x20337208647bB73b706D435c86F31cd5897bB24c',
14 | valueLedgerDeployOrderId: '0x9a0bB454D50c7281562cD75311412E1a7D1375AF',
15 | };
16 | case NetworkKind.TESTNET:
17 | return {
18 | actionsOrderId: '0x7b65B89Dd2b43229E8BD087fA1601805d571b57D',
19 | assetLedgerDeployOrderId: '0x121ab5e82cdA136e4632268956d4227696D2F5e7',
20 | valueLedgerDeployOrderId: '0xE18a943ab808B69A5da445de844932f5f267baA0',
21 | };
22 | default:
23 | throw new Error('Unsupported network kind.');
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/packages/0xcert-wanchain-generic-provider/src/core/types.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * Network kind.
3 | */
4 | export enum NetworkKind {
5 | LIVE,
6 | TESTNET,
7 | }
8 |
--------------------------------------------------------------------------------
/packages/0xcert-wanchain-generic-provider/src/index.ts:
--------------------------------------------------------------------------------
1 | export { GatewayConfig, SignMethod, RpcResponse, SendOptions, Mutation, MutationStatus,
2 | MutationEvent, MutationContext, MutationEventSignature, MutationEventType, MutationEventTypeKind,
3 | parseError } from '@0xcert/ethereum-generic-provider';
4 | export * from './core/provider';
5 | export * from './core/types';
6 | export * from './core/helpers';
7 |
--------------------------------------------------------------------------------
/packages/0xcert-wanchain-generic-provider/src/tests/core/helpers/build-gateway-config-instance-method.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@hayspec/spec';
2 | import { buildGatewayConfig, GenericProvider, NetworkKind } from '../../../';
3 |
4 | const spec = new Spec();
5 |
6 | spec.test('sets correct config', async (ctx) => {
7 | const provider = new GenericProvider({
8 | requiredConfirmations: 1,
9 | gatewayConfig: buildGatewayConfig(NetworkKind.TESTNET),
10 | });
11 | ctx.is(provider.gatewayConfig.actionsOrderId, '0x7b65b89dd2b43229e8bd087fa1601805d571b57d');
12 | });
13 |
14 | export default spec;
15 |
--------------------------------------------------------------------------------
/packages/0xcert-wanchain-generic-provider/src/tests/core/provider/config.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@hayspec/spec';
2 | import { GenericProvider } from '../../..';
3 |
4 | const spec = new Spec();
5 |
6 | spec.test('normalizes ID when set', async (ctx) => {
7 | const provider = new GenericProvider({});
8 | ctx.is(provider.valueLedgerSource, 'https://conventions.0xcert.org/wanchain/token-mock.json');
9 | ctx.is(provider.assetLedgerSource, 'https://conventions.0xcert.org/wanchain/xcert-mock.json');
10 | });
11 |
12 | export default spec;
13 |
--------------------------------------------------------------------------------
/packages/0xcert-wanchain-generic-provider/src/tests/index.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@hayspec/spec';
2 | import * as view from '..';
3 |
4 | const spec = new Spec();
5 |
6 | spec.test('exposes objects', (ctx) => {
7 | ctx.true(!!view.GenericProvider);
8 | ctx.true(!!view.SignMethod);
9 | ctx.true(!!view.Mutation);
10 | ctx.true(!!view.NetworkKind);
11 | });
12 |
13 | export default spec;
14 |
--------------------------------------------------------------------------------
/packages/0xcert-wanchain-generic-provider/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "es6",
5 | "noImplicitAny": false,
6 | "removeComments": true,
7 | "sourceMap": true,
8 | "outDir": "dist",
9 | "declaration": true,
10 | "experimentalDecorators": true,
11 | "allowSyntheticDefaultImports": true
12 | }
13 | }
--------------------------------------------------------------------------------
/packages/0xcert-wanchain-http-provider/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | > Implementation of an HTTP communication provider for the Wanchain blockchain.
4 |
5 | The [0xcert Framework](https://docs.0xcert.org) is a free and open-source JavaScript library that provides tools for building powerful decentralized applications. Please refer to the [official documentation](https://docs.0xcert.org) for more details.
6 |
7 | This module is one of the bricks of the [0xcert Framework](https://docs.0xcert.org). It's written with [TypeScript](https://www.typescriptlang.org) and it's actively maintained. The source code is available on [GitHub](https://github.com/0xcert/framework) where you can also find our [issue tracker](https://github.com/0xcert/framework/issues).
8 |
--------------------------------------------------------------------------------
/packages/0xcert-wanchain-http-provider/nodemon.json:
--------------------------------------------------------------------------------
1 | {
2 | "ignore": ["dist/*"],
3 | "ext": "js,ts"
4 | }
5 |
--------------------------------------------------------------------------------
/packages/0xcert-wanchain-http-provider/src/index.ts:
--------------------------------------------------------------------------------
1 | export * from '@0xcert/wanchain-generic-provider';
2 | export * from './core/provider';
3 |
--------------------------------------------------------------------------------
/packages/0xcert-wanchain-http-provider/src/tests/index.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@hayspec/spec';
2 | import * as view from '..';
3 |
4 | const spec = new Spec();
5 |
6 | spec.test('exposes objects', (ctx) => {
7 | ctx.true(!!view.HttpProvider);
8 | ctx.true(!!view.SignMethod);
9 | ctx.true(!!view.Mutation);
10 | ctx.true(!!view.buildGatewayConfig);
11 | ctx.true(!!view.NetworkKind);
12 | });
13 |
14 | export default spec;
15 |
--------------------------------------------------------------------------------
/packages/0xcert-wanchain-http-provider/src/tests/provider/get-network-version-instance-method.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@hayspec/spec';
2 | import { HttpProvider } from '../..';
3 |
4 | const spec = new Spec<{
5 | provider: HttpProvider;
6 | }>();
7 |
8 | spec.before(async (stage) => {
9 | const provider = new HttpProvider({
10 | url: 'https://gwan-ssl.wandevs.org:46891',
11 | });
12 | stage.set('provider', provider);
13 | });
14 |
15 | spec.test('returns network version', async (ctx) => {
16 | const provider = ctx.get('provider');
17 | const version = await provider.getNetworkVersion();
18 | ctx.is(version, '999');
19 | });
20 |
21 | export default spec;
22 |
--------------------------------------------------------------------------------
/packages/0xcert-wanchain-http-provider/src/tests/provider/normalize-address.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@hayspec/spec';
2 | import { HttpProvider } from '../..';
3 |
4 | const spec = new Spec();
5 |
6 | spec.test('Check normalize address override', (ctx) => {
7 | const provider1 = new HttpProvider({
8 | url: '',
9 | accountId: '0xE96D860C8BBB30F6831E6E65D327295B7A0C524F',
10 | });
11 | ctx.is(provider1.accountId, '0xe96d860c8bbb30f6831e6e65d327295b7a0c524f');
12 | // ctx.is(provider1.accountId, '0xE96d860c8bbb30f6831e6e65D327295b7a0c524F');
13 |
14 | const provider2 = new HttpProvider({
15 | url: '',
16 | accountId: '0xE96D860C8BBB30F6831E6E65D327295B7A0C524F',
17 | });
18 | ctx.is(provider2.accountId, '0xe96d860c8bbb30f6831e6e65d327295b7a0c524f');
19 | // ctx.is(provider2.accountId, '0xE96d860c8bbb30f6831e6e65D327295b7a0c524F');
20 | });
21 |
22 | export default spec;
23 |
--------------------------------------------------------------------------------
/packages/0xcert-wanchain-http-provider/src/tests/provider/send-instance-method.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@hayspec/spec';
2 | import { HttpProvider } from '../..';
3 |
4 | const spec = new Spec<{
5 | provider: HttpProvider;
6 | }>();
7 |
8 | spec.before(async (stage) => {
9 | const provider = new HttpProvider({
10 | url: 'https://gwan-ssl.wandevs.org:46891',
11 | });
12 | stage.set('provider', provider);
13 | });
14 |
15 | spec.test('returns block data', async (ctx) => {
16 | const provider = ctx.get('provider');
17 | const tx = '0x1f5b1b974c399a1c50a6035d05fe13235cc18f09fe8162349cf5d459b7e49a43';
18 | const res = await provider.post({
19 | method: 'eth_getTransactionByHash',
20 | params: [tx],
21 | });
22 | ctx.is(res.result.hash, tx);
23 | });
24 |
25 | export default spec;
26 |
--------------------------------------------------------------------------------
/packages/0xcert-wanchain-http-provider/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "es6",
5 | "noImplicitAny": false,
6 | "removeComments": true,
7 | "sourceMap": true,
8 | "outDir": "dist",
9 | "declaration": true,
10 | "experimentalDecorators": true,
11 | "allowSyntheticDefaultImports": true
12 | }
13 | }
--------------------------------------------------------------------------------
/packages/0xcert-wanchain-utils/nodemon.json:
--------------------------------------------------------------------------------
1 | {
2 | "ignore": ["dist/*"],
3 | "ext": "js,ts"
4 | }
5 |
--------------------------------------------------------------------------------
/packages/0xcert-wanchain-utils/src/index.ts:
--------------------------------------------------------------------------------
1 | export { Encode } from '@0xcert/ethereum-utils';
2 | export * from './lib/encoder';
3 |
--------------------------------------------------------------------------------
/packages/0xcert-wanchain-utils/src/tests/normalize-address.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@hayspec/spec';
2 | import { Encoder } from '../lib/encoder';
3 |
4 | const spec = new Spec();
5 |
6 | spec.test('normalize address', (ctx) => {
7 | const encoder = new Encoder();
8 | // ctx.is(normalizeAddress('0xE96D860C8BBB30F6831E6E65D327295B7A0C524F'), '0xE96d860c8bbb30f6831e6e65D327295b7a0c524F');
9 | // ctx.is(normalizeAddress('0xe96d860c8bbb30f6831e6e65d327295b7a0c524f'), '0xE96d860c8bbb30f6831e6e65D327295b7a0c524F');
10 | // ctx.is(normalizeAddress('0xE96d860c8bbb30f6831e6e65D327295b7a0c524F'), '0xE96d860c8bbb30f6831e6e65D327295b7a0c524F');
11 | // ctx.is(normalizeAddress('E96d860c8bbb30f6831e6e65D327295b7a0c524F'), '0xE96d860c8bbb30f6831e6e65D327295b7a0c524F');
12 | ctx.is(encoder.normalizeAddress(null), null);
13 | // ctx.throws(() => normalizeAddress('dfg'));
14 | });
15 |
16 | export default spec;
17 |
--------------------------------------------------------------------------------
/packages/0xcert-wanchain-utils/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "es6",
5 | "noImplicitAny": false,
6 | "removeComments": true,
7 | "sourceMap": true,
8 | "outDir": "dist",
9 | "declaration": true,
10 | "experimentalDecorators": true,
11 | "allowSyntheticDefaultImports": true
12 | }
13 | }
--------------------------------------------------------------------------------
/packages/0xcert-wanchain-value-ledger/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | > Value ledger module for currency management on the Wanchain blockchain.
4 |
5 | The [0xcert Framework](https://docs.0xcert.org) is a free and open-source JavaScript library that provides tools for building powerful decentralized applications. Please refer to the [official documentation](https://docs.0xcert.org) for more details.
6 |
7 | This module is one of the bricks of the [0xcert Framework](https://docs.0xcert.org). It's written with [TypeScript](https://www.typescriptlang.org) and it's actively maintained. The source code is available on [GitHub](https://github.com/0xcert/framework) where you can also find our [issue tracker](https://github.com/0xcert/framework/issues).
8 |
--------------------------------------------------------------------------------
/packages/0xcert-wanchain-value-ledger/nodemon.json:
--------------------------------------------------------------------------------
1 | {
2 | "ignore": ["dist/*"],
3 | "ext": "js,ts"
4 | }
5 |
--------------------------------------------------------------------------------
/packages/0xcert-wanchain-value-ledger/src/core/ledger.ts:
--------------------------------------------------------------------------------
1 | import * as ethereum from '@0xcert/ethereum-value-ledger';
2 |
3 | /**
4 | * Wanchain value ledger implementation.
5 | */
6 | export class ValueLedger extends ethereum.ValueLedger {}
7 |
--------------------------------------------------------------------------------
/packages/0xcert-wanchain-value-ledger/src/index.ts:
--------------------------------------------------------------------------------
1 | export { ValueLedgerDeployRecipe, ValueLedgerInfo, ValueLedgerTransferRecipe } from '@0xcert/ethereum-value-ledger';
2 | export * from './core/ledger';
3 |
--------------------------------------------------------------------------------
/packages/0xcert-wanchain-value-ledger/src/tests/index.test.ts:
--------------------------------------------------------------------------------
1 | import { Spec } from '@hayspec/spec';
2 | import * as ledger from '..';
3 |
4 | const spec = new Spec();
5 |
6 | spec.test('exposes objects', (ctx) => {
7 | ctx.true(!!ledger.ValueLedger);
8 | });
9 |
10 | export default spec;
11 |
--------------------------------------------------------------------------------
/packages/0xcert-wanchain-value-ledger/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "target": "es6",
5 | "noImplicitAny": false,
6 | "removeComments": true,
7 | "sourceMap": true,
8 | "outDir": "dist",
9 | "declaration": true,
10 | "experimentalDecorators": true,
11 | "allowSyntheticDefaultImports": true
12 | }
13 | }
--------------------------------------------------------------------------------
/packages/0xcert-webpack/example/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | XCert
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/packages/0xcert-webpack/nodemon.json:
--------------------------------------------------------------------------------
1 | {
2 | "ignore": ["dist/*"],
3 | "ext": "js,ts"
4 | }
5 |
--------------------------------------------------------------------------------
/packages/0xcert-webpack/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@0xcert/webpack",
3 | "version": "1.0.0",
4 | "description": "Module for package building and minification.",
5 | "scripts": {
6 | "build": "npm run clean && npx webpack",
7 | "clean": "rm -Rf ../../dist",
8 | "test": ""
9 | },
10 | "license": "MIT",
11 | "devDependencies": {
12 | "@0xcert/cert": "2.1.1",
13 | "@0xcert/ethereum-asset-ledger": "2.1.1",
14 | "@0xcert/ethereum-http-provider": "2.1.1",
15 | "@0xcert/ethereum-metamask-provider": "2.1.1",
16 | "@0xcert/ethereum-gateway": "2.1.1",
17 | "@0xcert/ethereum-value-ledger": "2.1.1",
18 | "@0xcert/wanchain-gateway": "2.1.1",
19 | "@0xcert/wanchain-value-ledger": "2.1.1",
20 | "@0xcert/wanchain-asset-ledger": "2.1.1",
21 | "@0xcert/wanchain-http-provider": "2.1.1",
22 | "webpack": "5.13.0",
23 | "webpack-cli": "4.3.1"
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/packages/0xcert-webpack/src/0xcert-cert.js:
--------------------------------------------------------------------------------
1 | window.$0xcert = window.$0xcert || {};
2 |
3 | Object.assign(
4 | window.$0xcert,
5 | require('@0xcert/cert'),
6 | );
7 |
--------------------------------------------------------------------------------
/packages/0xcert-webpack/src/0xcert-ethereum-asset-ledger.js:
--------------------------------------------------------------------------------
1 | window.$0xcert = window.$0xcert || {};
2 |
3 | Object.assign(
4 | window.$0xcert,
5 | require('@0xcert/ethereum-asset-ledger'),
6 | );
7 |
--------------------------------------------------------------------------------
/packages/0xcert-webpack/src/0xcert-ethereum-gateway.js:
--------------------------------------------------------------------------------
1 | window.$0xcert = window.$0xcert || {};
2 |
3 | Object.assign(
4 | window.$0xcert,
5 | require('@0xcert/ethereum-gateway'),
6 | );
7 |
--------------------------------------------------------------------------------
/packages/0xcert-webpack/src/0xcert-ethereum-http-provider.js:
--------------------------------------------------------------------------------
1 | window.$0xcert = window.$0xcert || {};
2 |
3 | Object.assign(
4 | window.$0xcert,
5 | require('@0xcert/ethereum-http-provider'),
6 | );
7 |
--------------------------------------------------------------------------------
/packages/0xcert-webpack/src/0xcert-ethereum-metamask-provider.js:
--------------------------------------------------------------------------------
1 | window.$0xcert = window.$0xcert || {};
2 |
3 | Object.assign(
4 | window.$0xcert,
5 | require('@0xcert/ethereum-metamask-provider'),
6 | );
7 |
--------------------------------------------------------------------------------
/packages/0xcert-webpack/src/0xcert-ethereum-value-ledger.js:
--------------------------------------------------------------------------------
1 | window.$0xcert = window.$0xcert || {};
2 |
3 | Object.assign(
4 | window.$0xcert,
5 | require('@0xcert/ethereum-value-ledger'),
6 | );
7 |
--------------------------------------------------------------------------------
/packages/0xcert-webpack/src/0xcert-ethereum.js:
--------------------------------------------------------------------------------
1 | window.$0xcert = window.$0xcert || {};
2 |
3 | Object.assign(
4 | window.$0xcert,
5 | require('@0xcert/cert'),
6 | require('@0xcert/ethereum-asset-ledger'),
7 | require('@0xcert/ethereum-gateway'),
8 | require('@0xcert/ethereum-value-ledger'),
9 | );
10 |
--------------------------------------------------------------------------------
/packages/0xcert-webpack/src/0xcert-wanchain-asset-ledger.js:
--------------------------------------------------------------------------------
1 | window.$0xcert = window.$0xcert || {};
2 |
3 | Object.assign(
4 | window.$0xcert,
5 | require('@0xcert/wanchain-asset-ledger'),
6 | );
7 |
--------------------------------------------------------------------------------
/packages/0xcert-webpack/src/0xcert-wanchain-gateway.js:
--------------------------------------------------------------------------------
1 | window.$0xcert = window.$0xcert || {};
2 |
3 | Object.assign(
4 | window.$0xcert,
5 | require('@0xcert/wanchain-gateway'),
6 | );
7 |
--------------------------------------------------------------------------------
/packages/0xcert-webpack/src/0xcert-wanchain-http-provider.js:
--------------------------------------------------------------------------------
1 | window.$0xcert = window.$0xcert || {};
2 |
3 | Object.assign(
4 | window.$0xcert,
5 | require('@0xcert/wanchain-http-provider'),
6 | );
7 |
--------------------------------------------------------------------------------
/packages/0xcert-webpack/src/0xcert-wanchain-value-ledger.js:
--------------------------------------------------------------------------------
1 | window.$0xcert = window.$0xcert || {};
2 |
3 | Object.assign(
4 | window.$0xcert,
5 | require('@0xcert/wanchain-value-ledger'),
6 | );
7 |
--------------------------------------------------------------------------------
/packages/0xcert-webpack/src/0xcert-wanchain.js:
--------------------------------------------------------------------------------
1 | window.$0xcert = window.$0xcert || {};
2 |
3 | Object.assign(
4 | window.$0xcert,
5 | require('@0xcert/cert'),
6 | require('@0xcert/wanchain-asset-ledger'),
7 | require('@0xcert/wanchain-gateway'),
8 | require('@0xcert/wanchain-value-ledger'),
9 | );
10 |
--------------------------------------------------------------------------------