Package: Js - PolymathNetwork/polymath-apps GitHub Wiki
Package's Concerns
This package was built with the intention of being a utility to interact with the Smart Contracts. Right now this package is being used partially for this purpose, since our apps use a mix of direct use of web3
and this package.
It has been decided that this package will eventually be replaced with a utility that functions as an abstraction layer for interacting with the Smart Contracts in the Polymath Network, representing higher-level processes rather than just a direct translation of the Contracts' public APIs into javascript. For this reason, it is adviced to use web3
directly instead of using this package.
Architecture
A class for each Smart Contract exists, this classes inherit from a base Contract
class which holds shared behavior.
The Contract
class' constructor sets a Proxy
to intercept method calls and look for the corresponding method from the contract's artifact performing the call. It will then either do a method.call
or execute the method using this._tx
. One thing to notice though is that this is not how Inheriting components are mostly performing transactions. The reason for this to be done seems to have been a way to dynamically generate methods for all contracts when being instantiated.
The class representations of Smart Contracts expose methods that contain logic for executing specific transactions (or groups of transactions) in the blockchain.
The way transactions are called is usually the following:
- Create a transaction object through
web3
- Pass the transaction object to the
this._tx()
method (delegated to the parent)