Skip to content
This repository has been archived by the owner on Feb 6, 2019. It is now read-only.

Commit

Permalink
Merge pull request #116 from OpenSTFoundation/release-1.0
Browse files Browse the repository at this point in the history
merging v1.0.5 to master
  • Loading branch information
Kedar authored May 17, 2018
2 parents 16377ee + e2d3310 commit 89c980b
Show file tree
Hide file tree
Showing 211 changed files with 7,617 additions and 188,487 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ mocha_test/scripts/poa-genesis.json
mocha_test/scripts/pw
mocha_test/scripts/st-poa/

package-lock.json
package-lock.json
build/
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ before_install:
- sudo apt-get install software-properties-common
- sudo add-apt-repository -y ppa:ethereum/ethereum
- sudo apt-get update
- sudo bash mocha_test/scripts/install_geth_1_7_3.sh
- sudo bash mocha_test/scripts/install_geth_1_8_3.sh
- sudo apt-get install solc
- geth version
install:
- npm install
before_script:
before_script:
- mkdir -p ~/.ethash
- geth makedag 0 ~/.ethash
- nohup sh tools/runTestRpc.sh </dev/null >/dev/null 2>&1 &
- bash contracts/compile.sh
script:
Expand Down
52 changes: 52 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,55 @@
## OpenST-Payments v1.0.5 (17 May 2018)

Changelog:

- Fix for double credit issue is done. On few cases of payment transactions beneficiary was credited two times.
- Solidity/solc is upgraded to 0.4.23. All contracts compile warnings are handled and contracts are upgraded with latest syntax.
- Truffle package is upgraded to 4.1.8.
- Fixes for travis broken tests is added.
- New response helper integration. Standardized error codes are now being used in OST Price Oracle.
- OpenST base web3 integration. Web socket connection to geth is now being used and preferred over RPC connection.
- OpenST base integration with logger is done.
- New services for payment success and failure were added. This was part of payment transactions optimization fixes.
- Loggers updated from into to debug wherever necessary. Log level support was introduced and non-important logs were moved to debug log level.
- Gas limit optimization on transactions is done. Predefined calculated gas limit with buffer is defined for each type of transactions.
- Support for web socket is added.
- Geth version updated to 1.0.0-beta.33.

## OpenST-Payments v1.0.5.beta.1

Changelog:
- Added new services and services refactoring
- Readme update as per updated services
- Comments updated for services

## OpenST-Payments v1.0.4.beta.2

Changelog:
- Upgrade Geth and Web3 version
- while transferring from reserve to airdrop budget holder validate if reserve has sufficient balance.

## OpenST-Payments v1.0.4

Changelog:
- Changed error message when insufficient balance
- Changed error message when insufficient gas

## OpenST-Payments v1.0.3

Changelog:
- Added error code for insufficient gas fund
- Added error code for transaction receipt with status 0

## OpenST-Payments v1.0.2

Changelog:
- Airdrop table caching and integration

## OpenST-Payments v1.0.1

Changelog:
- Fixed - Exception coming when converting Number to BigNumber with high precision

## OpenST-Payments v1.0.0 (14 March 2018)

OpenST-Payments 1.0.0 is the first release of OpenST-Payments. It provides `Airdrop` and `Pricer` contracts for token transfers, defines a `PriceOracle` interface, and introduces the concept of `Workers`.
191 changes: 162 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ sh start_test_chain.sh

```bash
export OST_UTILITY_GETH_RPC_PROVIDER=''
export OST_UTILITY_GETH_WS_PROVIDER=''
export OST_UTILITY_DEPLOYER_ADDR=''
export OST_UTILITY_DEPLOYER_PASSPHRASE=''
export OST_UTILITY_OPS_ADDR=''
Expand Down Expand Up @@ -73,47 +74,179 @@ export OP_MYSQL_CONNECTION_POOL_SIZE='5'
node migrations/create_tables.js
```

# Example:
# Deploy Service Examples:
```js
const OpenSTPayment = require('@openstfoundation/openst-payments')
, deployer = new OpenSTPayment.deployer()
, opsManaged = new OpenSTPayment.opsManaged(contractAddress, gasPrice, chainId)
, workers = new OpenSTPayment.worker(workerContractAddress, chainId)
, airdrop = new OpenSTPayment.airdrop(airdropContractAddress, chainId)
, airdropManager = OpenSTPayment.airdropManager
, Deploy = OpenSTPayment.services.deploy
;
// Deploy Workers
const deployWorkerObject = new Deploy.workers({
gas_price: gasPrice,
options: {returnType: 'txHash'}
});
deployWorkerObject.perform();

// Deploy Airdrop
const deployAirdropObject = new Deploy.airdrop({
branded_token_contract_address: brandedTokenAddress,
base_currency: baseCurrency,
worker_contract_address: workerContractAddress,
airdrop_budget_holder: airdropBudgetHolder,
gas_price: gasPrice,
options: {returnType: 'txHash'}
});
deployAirdropObject.perform();

```

# OpsManaged Service Examples
```js
const OpenSTPayment = require('@openstfoundation/openst-payments')
, OpsManaged = OpenSTPayment.services.opsManaged
;
// Deploy Contract
deployer.deploy( contractName, constructorArgs, gasPrice, options);
// Register Airdrop
airdropManager.registerAirdrop(airdropContractAddress, chainId);
// Set Ops Address
opsManaged.setOpsAddress(deployerAddress, deployerPassphrase, opsAddress, options);
const setOpsObject = new OpsManaged.setOps({
contract_address: contractAddress,
gas_price: gasPrice,
chain_id: chainId,
deployer_address: deployerAddress,
deployer_passphrase: deployerPassphrase,
ops_address: opsAddress,
options: {returnType: 'txHash'}
});
setOpsObject.perform();

// Get Ops Address
const getOpsObject = new OpsManaged.getOps({
contract_address: contractAddress,
gas_price: gasPrice,
chain_id: chainId
});
getOpsObject.perform();
```

# Workers Service Examples
```js
const OpenSTPayment = require('@openstfoundation/openst-payments')
, Workers = OpenSTPayment.services.workers
;
// Set Worker
workers.setWorker(senderAddress, senderPassphrase, workerAddress, deactivationHeight, gasPrice, options);
const setWorkerObject = new Workers.setWorker({
workers_contract_address: constants.workersContractAddress,
sender_address: constants.ops,
sender_passphrase: constants.opsPassphrase,
worker_address: workerAddress,
deactivation_height: deactivationHeight.toString(10),
gas_price: gasPrice,
chain_id: chainId,
options: {returnType: 'txHash'}
});
setWorkerObject.perform();

// Is Worker
const isWorkerObject = new Workers.isWorker({
workers_contract_address: workersContractAddress,
worker_address: workerAddress,
chain_id: chainId
});
isWorkerObject.perform();
```

# Airdrop Management Service Examples:
```js
const OpenSTPayment = require('@openstfoundation/openst-payments')
, AirdropManager = OpenSTPayment.services.airdropManager
;
// Register Airdrop
const registerObject = new AirdropManager.register({
airdrop_contract_address: airdropContractAddress,
chain_id: chainId
});
registerObject.perform();

// Set Price Oracle
airdrop.setPriceOracle(senderAddress, senderPassphrase, currency, address, gasPrice, options);
const setPriceOracleObject = new AirdropManager.setPriceOracle({
airdrop_contract_address: airdropContractAddress,
chain_id: chainId,
sender_address: senderAddress,
sender_passphrase: senderPassphrase,
currency: currency,
price_oracle_contract_address: priceOracleContractAddress,
gas_price: gasPrice,
options: {tag: 'airdrop.setPriceOracle', returnType: 'txHash'}
});
setPriceOracleObject.perform();

// Set Accepted Margin
airdrop.setAcceptedMargin(senderAddress, senderPassphrase, currency, acceptedMargin, gasPrice, options);
const setAcceptedMarginObject = new AirdropManager.setAcceptedMargin({
airdrop_contract_address: airdropContractAddress,
chain_id: chainId,
sender_address: senderAddress,
sender_passphrase: senderPassphrase,
currency: currency,
accepted_margin: acceptedMargin,
gas_price: gasPrice,
options: {tag: 'airdrop.setAcceptedMargin', returnType: 'txHash'}
});
setAcceptedMarginObject.perform();

// Transfer Amount to airdrop budget holder
airdropManager.transfer(senderAddress, senderPassphrase, airdropContractAddress, amount, gasPrice, chainId, options);
const transferObject = new AirdropManager.transfer({
sender_address: senderAddress,
sender_passphrase: senderPassphrase,
airdrop_contract_address: airdropContractAddress,
amount: airdropBudgetAmountInWei,
gas_price: gasPrice,
chain_id: chainId,
options: {tag: 'airdrop.transfer', returnType: 'txHash'}
});
transferObject.perform();

// Approve airdrop budget holder
airdropManager.approve(airdropContractAddress, airdropBudgetHolderPassphrase, gasPrice, chainId, options);
const approveObject = new AirdropManager.approve({
airdrop_contract_address: airdropContractAddress,
airdrop_budget_holder_passphrase: airdropBudgetHolderPassphrase,
gas_price: gasPrice,
chain_id: chainId,
options: {tag: 'airdrop.approve', returnType: 'txHash'}
});
approveObject.perform();

// Allocate airdrop amount to users in batch
airdropManager.batchAllocate(airdropContractAddress, transactionHash, airdropUsers, chainId);
const batchAllocatorObject = new AirdropManager.batchAllocator({
airdrop_contract_address: airdropContractAddress,
transaction_hash: transactionHash,
airdrop_users: {userAddress1: {airdropAmount: amountInWei, expiryTimestamp: 0}, userAddress2: {airdropAmount: amountInWei, expiryTimestamp: 0}},
chain_id: chainId
});
batchAllocatorObject.perform();

// Get Users Airdrop Balance
airdropManager.getAirdropBalance(chainId, airdropContractAddress, userAddresses);
const userBalanceObject = new AirdropManager.userBalance({
airdrop_contract_address: airdropContractAddress,
chain_id: chainId,
user_addresses: [user1, user2]
});
userBalanceObject.perform();

// Call Pay method
airdrop.pay(workerAddress,
WorkerPassphrase,
beneficiaryAddress,
transferAmount,
commissionBeneficiaryAddress,
commissionAmount,
currency,
intendedPricePoint,
spender,
gasPrice,
{tag:'airdrop.pay', returnType: 'txHash'});
const payObject = new AirdropManager.pay({
airdrop_contract_address: airdropContractAddress,
chain_id: chainId,
sender_worker_address: workerAddress,
sender_worker_passphrase: workerPassphrase,
beneficiary_address: beneficiary,
transfer_amount: transferAmount.toString(10),
commission_beneficiary_address: commissionBeneficiary,
commission_amount: commissionAmount.toString(10),
currency: currency,
intended_price_point: intendedPricePoint,
spender: spenderAddress,
gas_price: gasPrice,
options: {tag:'airdrop.pay', returnType: 'txHash'}
});
payObject.perform()

```

For further implementation details, please refer to the [API documentation](https://openstfoundation.github.io/openst-payments/).
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.0
1.0.5
14 changes: 14 additions & 0 deletions app/models/airdrop.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,19 @@ const AirdropKlassPrototype = {
*/
tableName: 'airdrops',

/**
* Select all airdrop contracts
*
* @return {Promise}
*
*/
getAll: function() {
const oThis = this
;

return oThis.select().fire();
},

/**
* get airdrop AR by contract Address
*
Expand All @@ -62,6 +75,7 @@ const AirdropKlassPrototype = {
return oThis.select().where(["contract_address=?", airdropContractAddress]).
limit(1).fire();
}

};

Object.assign(AirdropKlass.prototype, AirdropKlassPrototype);
Expand Down
24 changes: 22 additions & 2 deletions app/models/airdrop_allocation_proof_detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,16 @@ const rootPrefix = '../..'
, QueryDBKlass = require(rootPrefix + '/app/models/queryDb')
, ModelBaseKlass = require(rootPrefix + '/app/models/base')
, responseHelper = require(rootPrefix + '/lib/formatter/response')
, logger = require(rootPrefix + '/helpers/custom_console_logger')
, paramErrorConfig = require(rootPrefix + '/config/param_error_config')
, apiErrorConfig = require(rootPrefix + '/config/api_error_config')
;

const errorConfig = {
param_error_config: paramErrorConfig,
api_error_config: apiErrorConfig
};

const dbName = coreConstants.MYSQL_DATABASE
, QueryDBObj = new QueryDBKlass(dbName)
;
Expand Down Expand Up @@ -62,7 +70,13 @@ const AirdropAllocationProofDetailKlassPrototype = {
});
return responseHelper.successWithData({response: insertedRecord});
} catch(err){
return responseHelper.error('l_aapd_cr_1', 'Error creating airdrop_allocation_proof_details record:'+err);
let errorParams = {
internal_error_identifier: 'l_aapd_cr_1',
api_error_identifier: 'entry_creation_failed',
error_config: errorConfig,
debug_options: { err: err }
};
return responseHelper.error(errorParams);
}

},
Expand All @@ -84,7 +98,13 @@ const AirdropAllocationProofDetailKlassPrototype = {
await oThis.update({airdrop_allocated_amount: allocatedAmount}).where(["id=?", id]).fire();
return responseHelper.successWithData({});
} catch(err){
return responseHelper.error('l_a_m_aapd_1', 'Something went wrong while updating record id:'+id+" err: "+err);
let errorParams = {
internal_error_identifier: 'l_a_m_aapd_1',
api_error_identifier: 'entry_updation_failed',
error_config: errorConfig,
debug_options: { err: err }
};
return responseHelper.error(errorParams);
}
},

Expand Down
Loading

0 comments on commit 89c980b

Please sign in to comment.