Commit da53ec8a authored by Ruslan Kryukov's avatar Ruslan Kryukov
Browse files

don't worry, it's just a massive vendor update

I noticed withdrawal function is gone, For this I use direct string function name
parent 9b6901f0
Showing with 272 additions and 61 deletions
+272 -61
......@@ -5,21 +5,22 @@ import (
"fmt"
"github.com/hyperledger/fabric/core/chaincode/shim"
"github.com/hyperledger/fabric/protos/peer"
"gitlab.smartblocklab.com/smartcontracts/sc-security/actions"
"gitlab.smartblocklab.com/smartcontracts/common/security/actions"
"gitlab.smartblocklab.com/smartcontracts/common/chaincode"
"gitlab.smartblocklab.com/smartcontracts/common/invoke"
)
// Defines operations supported by chaincode
var (
AddRootUser = actions.Actions().UserCC().AddRootUser.FunctionName
AddOrganizationRootUser = actions.Actions().UserCC().AddOrganizationRootUser.FunctionName
AddSystemUser = actions.Actions().UserCC().AddSystemUser.FunctionName
AddServiceUser = actions.Actions().UserCC().AddServiceUser.FunctionName
AddUser = actions.Actions().UserCC().AddUser.FunctionName
GetUser = actions.Actions().UserCC().GetUser.FunctionName
AddPublicKey = actions.Actions().UserCC().AddPublicKey.FunctionName
RevokeUserPublicKey = actions.Actions().UserCC().RevokeUserPublicKey.FunctionName
VerifyUserSignature = actions.Actions().UserCC().VerifyUserSignature.FunctionName
AddRootUser = invoke.AddRootUserFunction
AddOrganizationRootUser = invoke.AddOrganizationRootUserFunction
AddSystemUser = invoke.AddSystemUserFunction
AddServiceUser = invoke.AddServiceUserFunction
AddUser = invoke.AddUserFunction
GetUser = invoke.GetUserFunction
AddPublicKey = invoke.AddPublicKeyFunction
RevokeUserPublicKey = invoke.RevokeUserPublicKeyFunction
VerifyUserSignature = invoke.VerifyUserSignatureFunction
RootUserID = "ROOT_USER"
)
......
......@@ -15,7 +15,7 @@ import (
"math/big"
"gitlab.smartblocklab.com/smartcontracts/common/chaincode"
"gitlab.smartblocklab.com/smartcontracts/common/function"
"gitlab.smartblocklab.com/smartcontracts/sc-security/requests"
"gitlab.smartblocklab.com/smartcontracts/common/security/requests"
)
var logger = logrus.WithFields(logrus.Fields{
......
......@@ -376,6 +376,18 @@ func (d Decimal) Mul(d2 Decimal) Decimal {
}
}
// Shift shifts the decimal in base 10.
// It shifts left when shift is positive and right if shift is negative.
// In simpler terms, the given value for shift is added to the exponent
// of the decimal.
func (d Decimal) Shift(shift int32) Decimal {
d.ensureInitialized()
return Decimal{
value: new(big.Int).Set(d.value),
exp: d.exp + shift,
}
}
// Div returns d / d2. If it doesn't divide exactly, the result will have
// DivisionPrecision digits after the decimal point.
func (d Decimal) Div(d2 Decimal) Decimal {
......
......@@ -4,8 +4,8 @@ import (
"github.com/hyperledger/fabric/core/chaincode/shim"
pb "github.com/hyperledger/fabric/protos/peer"
"gitlab.smartblocklab.com/smartcontracts/common/logging"
"gitlab.smartblocklab.com/smartcontracts/sc-security/checker"
"gitlab.smartblocklab.com/smartcontracts/sc-security/requests"
"gitlab.smartblocklab.com/smartcontracts/common/security/checker"
"gitlab.smartblocklab.com/smartcontracts/common/security/requests"
)
// ChaincodeStubInterfaceAdapter stub interface to encapsulate only
......
......@@ -12,6 +12,18 @@ type StubInterfaceAdapterMock struct {
mock.Mock
}
func (iter *StubInterfaceAdapterMock) Close() error {
return nil
}
func (iter *StubInterfaceAdapterMock) Next() (*queryresult.KV, error) {
return nil, nil
}
func (iter *StubInterfaceAdapterMock) HasNext() bool {
return true
}
// GetState
func (mock *StubInterfaceAdapterMock) GetState(key string) ([]byte, error) {
args := mock.Called(key)
......
......@@ -14,18 +14,20 @@ var logger = logrus.WithFields(logrus.Fields{
})
func GetSelector(data interface{}) (string, error) {
logger.Info("AccountChaincode::getSelector")
logger.Info("getSelector")
query, err := json.Marshal(struct {
Selector interface{} `json:"selector"`
}{
Selector: data,
})
return string(query), err
stringQuery := string(query)
logger.Infof("query: %s", stringQuery)
return stringQuery, err
}
func FindOneByQuery(queryObject interface{}, stub chaincode.StubInterfaceAdapter) ([]byte, error) {
logger.Info("AccountChaincode::findOneByQuery")
logger.Info("findOneByQuery")
query, err := GetSelector(queryObject)
if err != nil {
errMsg := fmt.Sprintf("Failed to create query. Error: %s", err)
......
......@@ -2,8 +2,7 @@ package function
import (
"fmt"
"gitlab.smartblocklab.com/smartcontracts/sc-security/tools"
"gitlab.smartblocklab.com/smartcontracts/sc-security/actions"
"gitlab.smartblocklab.com/smartcontracts/common/security/tools"
"github.com/hyperledger/fabric/core/chaincode/shim"
"encoding/json"
"gitlab.smartblocklab.com/smartcontracts/common/invoke"
......@@ -20,7 +19,7 @@ func CheckAndLoadAccount_Function(userAccountInfo *model.UserAccountInfo, adapte
logger.Error(logMsg)
// Invoke account check chaincode
resp := tools.SignedInvokeChaincode(adapter, invoke.CheckAndLoadAccountChannel, actions.Actions().AccountCC().CheckAndLoadAccount, userAccountInfo)
resp := tools.SignedInvokeChaincode(adapter, invoke.AccountChannel, invoke.AccountCC, invoke.CheckAndLoadAccountFunction, userAccountInfo)
// We got error status
if resp.Status != int32(shim.OK) {
logger.Errorf("verification of user id %s failed, with following response %s", userAccountInfo.UserID, resp.Message)
......
package function
import (
"gitlab.smartblocklab.com/smartcontracts/sc-security/tools"
"gitlab.smartblocklab.com/smartcontracts/sc-security/actions"
"gitlab.smartblocklab.com/smartcontracts/sc-security/requests"
"gitlab.smartblocklab.com/smartcontracts/common/security/tools"
"gitlab.smartblocklab.com/smartcontracts/common/security/requests"
"github.com/hyperledger/fabric/core/chaincode/shim"
"encoding/json"
"fmt"
......@@ -19,7 +18,7 @@ func GetAccountInfoByAccountID_Function(accountId string, adapter chaincode.Stub
logger.Infof("find by accountId %s", accountId)
// Invoke account check chaincode
resp := tools.SignedInvokeChaincode(adapter, invoke.AccountChannel, actions.Actions().AccountCC().GetAccountInfoByAccountID, requests.Id{Id: accountId})
resp := tools.SignedInvokeChaincode(adapter, invoke.AccountChannel, invoke.AccountCC, invoke.GetAccountInfoByAccountIDFunction, requests.Id{Id: accountId})
// We got error status
if resp.Status != int32(shim.OK) {
logger.Errorf("verification of external account id %s failed, with following response %s", accountId, resp.Message)
......
package function
import (
"gitlab.smartblocklab.com/smartcontracts/sc-security/tools"
"gitlab.smartblocklab.com/smartcontracts/sc-security/actions"
"gitlab.smartblocklab.com/smartcontracts/common/security/tools"
"github.com/hyperledger/fabric/core/chaincode/shim"
"fmt"
"gitlab.smartblocklab.com/smartcontracts/common/model"
......@@ -11,10 +10,12 @@ import (
"gitlab.smartblocklab.com/smartcontracts/common/chaincode"
)
type VerifyUserAccount_Type func(info model.UserAccountInfo, adapter chaincode.StubInterfaceAdapter) error
// checkAccountStatus call account chaincode to verify account status
func CheckAccountStatus(info model.UserAccountInfo, adapter chaincode.StubInterfaceAdapter) error {
func VerifyUserAccount_Function(info model.UserAccountInfo, adapter chaincode.StubInterfaceAdapter) error {
// Check out account status
resp := tools.SignedInvokeChaincode(adapter, invoke.VerifyAccountChannelName, actions.Actions().AccountCC().VerifyUserAccount, info)
resp := tools.SignedInvokeChaincode(adapter, invoke.AccountChannel, invoke.AccountCC, invoke.VerifyUserAccountFunction, info)
if resp.Status != int32(shim.OK) {
errMsg := fmt.Sprintf("verification of user id %s, failed due to %s", info.UserID, resp.Message)
......@@ -23,4 +24,4 @@ func CheckAccountStatus(info model.UserAccountInfo, adapter chaincode.StubInterf
}
return nil
}
\ No newline at end of file
}
......@@ -2,9 +2,8 @@ package function
import (
"fmt"
"gitlab.smartblocklab.com/smartcontracts/sc-security/tools"
"gitlab.smartblocklab.com/smartcontracts/common/security/tools"
"gitlab.smartblocklab.com/smartcontracts/common/invoke"
"gitlab.smartblocklab.com/smartcontracts/sc-security/actions"
"github.com/hyperledger/fabric/core/chaincode/shim"
"encoding/json"
"gitlab.smartblocklab.com/smartcontracts/common/model"
......@@ -12,6 +11,8 @@ import (
"gitlab.smartblocklab.com/smartcontracts/common/chaincode"
)
type GetCommission_Type func(partnerCode string, customerType model.CustomerType, commissionType model.CommissionType, stub chaincode.StubInterfaceAdapter) (float64, error)
// CommissionForTransfer compute commission based on transaction input parameters
func GetCommission_Function(partnerCode string, customerType model.CustomerType, commissionType model.CommissionType, stub chaincode.StubInterfaceAdapter) (float64, error) {
msg := fmt.Sprintf("CommissionForTransfer (partnerCode %s, customerType %s, commissionType %s)", partnerCode, customerType, commissionType)
......@@ -33,7 +34,7 @@ func GetCommission_Function(partnerCode string, customerType model.CustomerType,
return 0, errors.New(errMsg)
}
resp := tools.SignedInvokeChaincode(stub, invoke.CommissionChannel, actions.Actions().CommissionCC().GetCommission, model.GetCommissionArg{
resp := tools.SignedInvokeChaincode(stub, invoke.CommissionChannel, invoke.CommissionCC, invoke.GetCommissionFunction, model.GetCommissionArg{
PartnerCode: partnerCode,
CustomerType: customerType.String(),
CommissionType: commissionType.String(),
......
......@@ -2,9 +2,8 @@ package function
import (
"fmt"
"gitlab.smartblocklab.com/smartcontracts/sc-security/tools"
"gitlab.smartblocklab.com/smartcontracts/sc-security/actions"
"gitlab.smartblocklab.com/smartcontracts/sc-security/requests"
"gitlab.smartblocklab.com/smartcontracts/common/security/tools"
"gitlab.smartblocklab.com/smartcontracts/common/security/requests"
"github.com/hyperledger/fabric/core/chaincode/shim"
"encoding/json"
"errors"
......@@ -21,7 +20,7 @@ func GetCryptocurrenciesByDaemonName_Function(systemUserId string, adapter chain
logMsg := fmt.Sprintf("cryptocurrencyLoaderFunction (daemonName: %s)", systemUserId)
logger.Error(logMsg)
resp := tools.SignedInvokeChaincodeWithUserId(adapter, systemUserId, invoke.GetCryptocurrenciesByDaemonNameChannel, actions.Actions().CryptocurrencyCC().GetCryptocurrenciesByDaemonName, requests.Id{Id: systemUserId})
resp := tools.SignedInvokeChaincodeWithUserId(adapter, systemUserId, invoke.GetCryptocurrenciesByDaemonNameChannel, invoke.CryptocurrencyCC, invoke.GetCryptocurrenciesByDaemonNameFunction, requests.Id{Id: systemUserId})
// We got error status
if resp.Status != int32(shim.OK) {
......
package function
import (
"gitlab.smartblocklab.com/smartcontracts/sc-security/tools"
"gitlab.smartblocklab.com/smartcontracts/sc-security/actions"
"gitlab.smartblocklab.com/smartcontracts/common/security/tools"
"github.com/hyperledger/fabric/core/chaincode/shim"
"gitlab.smartblocklab.com/smartcontracts/common/chaincode"
"gitlab.smartblocklab.com/smartcontracts/common/model"
"gitlab.smartblocklab.com/smartcontracts/common/invoke"
)
type IsOfferApproved_Type func(operationID string, adapter chaincode.StubInterfaceAdapter) bool
func IsOfferApproved_Function(operationID string, adapter chaincode.StubInterfaceAdapter) bool {
logger.Infof("Invoke: OfferCC.IsOfferApproved {operationID: %s}", operationID)
......@@ -16,6 +17,6 @@ func IsOfferApproved_Function(operationID string, adapter chaincode.StubInterfac
OperationID: operationID,
}
resp := tools.SignedInvokeChaincode(adapter, invoke.OfferIsApprovedChannel, actions.Actions().OfferCC().IsOfferApproved, isOfferApprovedArg)
resp := tools.SignedInvokeChaincode(adapter, invoke.OfferChannel, invoke.OfferCC, invoke.IsOfferApprovedFunction, isOfferApprovedArg)
return resp.Status == int32(shim.OK)
}
\ No newline at end of file
......@@ -5,10 +5,9 @@ import (
"errors"
"fmt"
"github.com/hyperledger/fabric/core/chaincode/shim"
"gitlab.smartblocklab.com/smartcontracts/sc-security/actions"
"gitlab.smartblocklab.com/smartcontracts/sc-security/requests"
"gitlab.smartblocklab.com/smartcontracts/common/security/requests"
"gitlab.smartblocklab.com/smartcontracts/common/chaincode"
"gitlab.smartblocklab.com/smartcontracts/sc-security/tools"
"gitlab.smartblocklab.com/smartcontracts/common/security/tools"
"gitlab.smartblocklab.com/smartcontracts/common/model"
"gitlab.smartblocklab.com/smartcontracts/common/invoke"
"github.com/sirupsen/logrus"
......@@ -24,7 +23,7 @@ type GetOrganization_Type func(partnerCode string, adapter chaincode.StubInterfa
func GetOrganization_Function(partnerCode string, adapter chaincode.StubInterfaceAdapter) (*model.Organization, error) {
logger.Infof("organizationLoaderFunction (partnerCode: %s)", partnerCode)
resp := tools.SignedInvokeChaincode(adapter, invoke.GetOrganizationChannel, actions.Actions().OrganizationCC().GetOrganization, requests.Id{Id: partnerCode})
resp := tools.SignedInvokeChaincode(adapter, invoke.OrganizationChannel, invoke.OrganizationCC, invoke.GetOrganizationFunction, requests.Id{Id: partnerCode})
if resp.Status == 404 {
logger.Debug("Organization is not found")
......
package marketaccount
import (
"encoding/json"
"gitlab.smartblocklab.com/smartcontracts/common/chaincode"
"gitlab.smartblocklab.com/smartcontracts/common/interfaces/imarketaccount"
"gitlab.smartblocklab.com/smartcontracts/common/logging"
"gitlab.smartblocklab.com/smartcontracts/common/model/marketaccount"
"gitlab.smartblocklab.com/smartcontracts/common/security/requests"
"gitlab.smartblocklab.com/smartcontracts/common/security/tools"
"gitlab.smartblocklab.com/smartcontracts/common/invoke"
)
type RemoteManagerImpl struct {
adapter chaincode.StubInterfaceAdapter
timeGetter chaincode.TimeGetter
channel string
}
func GetRemoteManager(adapter chaincode.StubInterfaceAdapter, timeGetter chaincode.TimeGetter, channel string) imarketaccount.IMarketaccountCC {
return &RemoteManagerImpl{
adapter: adapter,
timeGetter: timeGetter,
channel: channel,
}
}
func (this *RemoteManagerImpl) AddWallet(UserID string, newWalletUISigned marketaccount.NewWallet, walletId requests.Id) (*marketaccount.Wallet, error) {
return nil, logging.Get().Error("Failed to make remote call")
}
func (this *RemoteManagerImpl) AddAccount(UserID string, newAccountUISigned marketaccount.NewAccount, accountId requests.Id) (*marketaccount.Account, error) {
return nil, logging.Get().Error("Failed to make remote call")
}
func (this *RemoteManagerImpl) AddExternalAccount(UserID string, newExternalAccount marketaccount.NewExternalAccount, subAccountId requests.Id) (*marketaccount.Account, error) {
return nil, logging.Get().Error("Failed to make remote call")
}
func (this *RemoteManagerImpl) ActivateWallet(UserID string, walletId requests.Id) (*marketaccount.Wallet, error) {
return nil, logging.Get().Error("Failed to make remote call")
}
func (this *RemoteManagerImpl) BlockWallet(UserID string, walletId requests.Id) (*marketaccount.Wallet, error) {
return nil, logging.Get().Error("Failed to make remote call")
}
func (this *RemoteManagerImpl) ActivateAccount(UserID string, accountId requests.Id) (*marketaccount.Account, error) {
return nil, logging.Get().Error("Failed to make remote call")
}
func (this *RemoteManagerImpl) BlockAccount(UserID string, accountId requests.Id) (*marketaccount.Account, error) {
return nil, logging.Get().Error("Failed to make remote call")
}
func (this *RemoteManagerImpl) GetAccountByCurrencyType(arg marketaccount.GetAccountByCurrencyTypeArg) (*marketaccount.Account, error) {
if resp := tools.SignedInvokeChaincode(this.adapter, this.channel, invoke.MarketaccountCC, invoke.GetAccountByCurrencyTypeFunction, arg); resp.Status != 200 {
return nil, logging.Get().Error(resp.Message)
} else {
var result marketaccount.Account
if err := json.Unmarshal(resp.Payload, &result); err != nil {
return nil, logging.Get().Error(err.Error())
} else {
return &result, nil
}
}
}
func (this *RemoteManagerImpl) VerifyUserAccount(arg marketaccount.AccountInfo) (*marketaccount.Account, error) {
if resp := tools.SignedInvokeChaincode(this.adapter, this.channel, invoke.MarketaccountCC, invoke.VerifyUserAccountFunction, arg); resp.Status != 200 {
return nil, logging.Get().Error(resp.Message)
} else {
var result marketaccount.Account
if err := json.Unmarshal(resp.Payload, &result); err != nil {
return nil, logging.Get().Error(err.Error())
} else {
return &result, nil
}
}
}
func (this *RemoteManagerImpl) CheckAndLoadAccount(arg marketaccount.AccountInfo) (*marketaccount.Account, error) {
if resp := tools.SignedInvokeChaincode(this.adapter, this.channel, invoke.MarketaccountCC, invoke.CheckAndLoadAccountFunction, arg); resp.Status != 200 {
return nil, logging.Get().Error(resp.Message)
} else {
var result marketaccount.Account
if err := json.Unmarshal(resp.Payload, &result); err != nil {
return nil, logging.Get().Error(err.Error())
} else {
return &result, nil
}
}
}
func (this *RemoteManagerImpl) GetAllUserWallets(userId requests.Id) (*marketaccount.WalletsEnvelope, error) {
if resp := tools.SignedInvokeChaincode(this.adapter, this.channel, invoke.MarketaccountCC, invoke.GetAllUserWalletsFunction, userId); resp.Status != 200 {
return nil, logging.Get().Error(resp.Message)
} else {
var result marketaccount.WalletsEnvelope
if err := json.Unmarshal(resp.Payload, &result); err != nil {
return nil, logging.Get().Error(err.Error())
} else {
return &result, nil
}
}
}
func (this *RemoteManagerImpl) GetAccountInfoByAccountID(accountId requests.Id) (*marketaccount.AccountInfo, error) {
if resp := tools.SignedInvokeChaincode(this.adapter, this.channel, invoke.MarketaccountCC, invoke.GetAccountInfoByAccountIDFunction, accountId); resp.Status != 200 {
return nil, logging.Get().Error(resp.Message)
} else {
var result marketaccount.AccountInfo
if err := json.Unmarshal(resp.Payload, &result); err != nil {
return nil, logging.Get().Error(err.Error())
} else {
return &result, nil
}
}
}
func (this *RemoteManagerImpl) GetAccounts(userId requests.Id) (*marketaccount.AccountsEnvelope, error) {
if resp := tools.SignedInvokeChaincode(this.adapter, this.channel, invoke.MarketaccountCC, invoke.GetAccountsFunction, userId); resp.Status != 200 {
return nil, logging.Get().Error(resp.Message)
} else {
var result marketaccount.AccountsEnvelope
if err := json.Unmarshal(resp.Payload, &result); err != nil {
return nil, logging.Get().Error(err.Error())
} else {
return &result, nil
}
}
}
func (this *RemoteManagerImpl) GetWallets(userId requests.Id) (*marketaccount.WalletsEnvelope, error) {
if resp := tools.SignedInvokeChaincode(this.adapter, this.channel, invoke.MarketaccountCC, invoke.GetWalletsFunction, userId); resp.Status != 200 {
return nil, logging.Get().Error(resp.Message)
} else {
var result marketaccount.WalletsEnvelope
if err := json.Unmarshal(resp.Payload, &result); err != nil {
return nil, logging.Get().Error(err.Error())
} else {
return &result, nil
}
}
}
\ No newline at end of file
package function
import (
"gitlab.smartblocklab.com/smartcontracts/sc-security/tools"
"gitlab.smartblocklab.com/smartcontracts/sc-security/actions"
"gitlab.smartblocklab.com/smartcontracts/common/security/tools"
"github.com/hyperledger/fabric/core/chaincode/shim"
"encoding/json"
"fmt"
......@@ -16,7 +15,7 @@ type CheckExistsTransactionByList_Type func(syncRequest model.SyncRequest, adapt
func CheckExistsTransactionByList_Function(syncRequest model.SyncRequest, adapter chaincode.StubInterfaceAdapter) (*model.CheckExistsResult, error) {
resp := tools.SignedInvokeChaincode(adapter, invoke.CheckExistsTransactionByListChannel, actions.Actions().TransactionCC().CheckExistsTransactionByList, syncRequest)
resp := tools.SignedInvokeChaincode(adapter, invoke.TransactionChannel, invoke.TransactionCC, invoke.CheckExistsTransactionByListFunction, syncRequest)
if resp.Status != int32(shim.OK) {
logger.Errorf("Error %s", resp.Message)
......
package function
import (
"gitlab.smartblocklab.com/smartcontracts/sc-security/tools"
"gitlab.smartblocklab.com/smartcontracts/sc-security/actions"
"gitlab.smartblocklab.com/smartcontracts/common/security/tools"
"github.com/hyperledger/fabric/core/chaincode/shim"
"fmt"
"encoding/json"
......@@ -14,11 +13,11 @@ import (
// получение заблокированных средств по operationID
func FindLockAmountByOperationIDAndUserId(operationID string, userID string, adapter chaincode.StubInterfaceAdapter) (*model.FindLockAmountResult, error) {
resp := tools.SignedInvokeChaincode(adapter, invoke.FindLockAmountByOperationIDAndUserIdChannelName,
actions.Actions().TransactionCC().FindLockAmountByOperationIDAndUserId, model.FindLockAmountByOperationIDAndUserIdArg{
OperationID: operationID,
UserID: userID,
})
arg := model.FindLockAmountByOperationIDAndUserIdArg{
OperationID: operationID,
UserID: userID,
}
resp := tools.SignedInvokeChaincode(adapter, invoke.TransactionChannel, invoke.TransactionCC, invoke.FindLockAmountByOperationIDAndUserIdFunction, arg)
if resp.Status != int32(shim.OK) {
errMsg := fmt.Sprintf("Problem to find lock transaction by operationID %s and userID %s. Message: %s", operationID, userID, resp.Message)
......
......@@ -2,10 +2,9 @@ package function
import (
"gitlab.smartblocklab.com/smartcontracts/common/model"
"gitlab.smartblocklab.com/smartcontracts/sc-security/tools"
"gitlab.smartblocklab.com/smartcontracts/common/security/tools"
"gitlab.smartblocklab.com/smartcontracts/common/invoke"
"gitlab.smartblocklab.com/smartcontracts/sc-security/actions"
"gitlab.smartblocklab.com/smartcontracts/sc-security/requests"
"gitlab.smartblocklab.com/smartcontracts/common/security/requests"
"github.com/hyperledger/fabric/core/chaincode/shim"
"encoding/json"
"fmt"
......@@ -19,7 +18,7 @@ func GetUser_Function(userID string, adapter chaincode.StubInterfaceAdapter) (*m
logger.Infof("userLoader (userID: %s)", userID)
// Invoke account check chaincode
resp := tools.SignedInvokeChaincode(adapter, invoke.GetUserChannel, actions.Actions().UserCC().GetUser, requests.Id{Id: userID})
resp := tools.SignedInvokeChaincode(adapter, invoke.UserChannel, invoke.UserCC, invoke.GetUserFunction, requests.Id{Id: userID})
// We got error status
if resp.Status != int32(shim.OK) {
logger.Errorf("verification of user id %s failed, with following response %s", userID, resp.Message)
......
......@@ -4,10 +4,9 @@ import (
"fmt"
"github.com/hyperledger/fabric/core/chaincode/shim"
"encoding/json"
"gitlab.smartblocklab.com/smartcontracts/sc-security/tools"
"gitlab.smartblocklab.com/smartcontracts/common/security/tools"
"gitlab.smartblocklab.com/smartcontracts/common/invoke"
"gitlab.smartblocklab.com/smartcontracts/sc-security/actions"
"gitlab.smartblocklab.com/smartcontracts/sc-security/requests"
"gitlab.smartblocklab.com/smartcontracts/common/security/requests"
"gitlab.smartblocklab.com/smartcontracts/common/model"
"gitlab.smartblocklab.com/smartcontracts/common/chaincode"
"errors"
......@@ -19,7 +18,7 @@ func UserPreferenceLoader_Function(externalAccountId string, adapter chaincode.S
logMsg := fmt.Sprintf("userPreferenceLoaderFunction (externalAccountId: %s)", externalAccountId)
logger.Error(logMsg)
resp := tools.SignedInvokeChaincode(adapter, invoke.GetIntAccountByExtAccountChannel, actions.Actions().UserPreferenceCC().GetIntAccountByExtAccount, requests.Id{Id: externalAccountId})
resp := tools.SignedInvokeChaincode(adapter, invoke.UserpreferenceChannel, invoke.UserpreferenceChannel, invoke.GetIntAccountByExtAccountFunction, requests.Id{Id: externalAccountId})
if resp.Status == 404 {
logger.Debug("UserPreference is not found")
......@@ -41,4 +40,3 @@ func UserPreferenceLoader_Function(externalAccountId string, adapter chaincode.S
}
return &userPreference, nil
}
package imarket
import (
"gitlab.smartblocklab.com/smartcontracts/common/model/market"
"gitlab.smartblocklab.com/smartcontracts/common/security/requests"
)
type IMarketManager interface {
DepositFunds(userID string, inputMarketFoundsObject market.UIDepositFunds, operationID requests.Id) (*market.MarketTransaction, error)
GetBalance(balanceArg market.MarketArg) (*market.MarketBalance, error)
WithdrawalFunds(userID string, arg market.UIMarketWithdrawal, operationID requests.Id) (*market.MarketTransactionList, error)
CreateOrder(userID string, marketOrder market.UIMarketOrder, operationID requests.Id) (*market.MarketTransactionList, error)
GetAllOrders() (*market.PlainMarketOrderList, error)
GetUserOrders(arg requests.Id) (*market.PlainMarketOrderList, error)
CancelOrder(userID string, id requests.Id) (*market.MarketTransactionList, error)
MatchOrders() (*market.TransactionList, error)
FindOutgoingTransactions(arg market.FindMarketTransactionArg) (*market.MarketTransactionList, error)
FindIncomingTransactions(arg market.FindMarketTransactionArg) (*market.MarketTransactionList, error)
}
package imarketaccount
import (
"gitlab.smartblocklab.com/smartcontracts/common/model/marketaccount"
"gitlab.smartblocklab.com/smartcontracts/common/security/requests"
)
type IMarketaccountCC interface {
AddWallet(UserID string, newWalletUISigned marketaccount.NewWallet, walletId requests.Id) (*marketaccount.Wallet, error)
AddAccount(UserID string, newAccountUISigned marketaccount.NewAccount, accountId requests.Id) (*marketaccount.Account, error)
AddExternalAccount(UserID string, newExternalAccount marketaccount.NewExternalAccount, subAccountId requests.Id) (*marketaccount.Account, error)
ActivateWallet(UserID string, walletId requests.Id) (*marketaccount.Wallet, error)
BlockWallet(UserID string, walletId requests.Id) (*marketaccount.Wallet, error)
ActivateAccount(UserID string, accountId requests.Id) (*marketaccount.Account, error)
BlockAccount(UserID string, accountId requests.Id) (*marketaccount.Account, error)
GetAccountByCurrencyType(arg marketaccount.GetAccountByCurrencyTypeArg) (*marketaccount.Account, error)
VerifyUserAccount(arg marketaccount.AccountInfo) (*marketaccount.Account, error)
CheckAndLoadAccount(arg marketaccount.AccountInfo) (*marketaccount.Account, error)
GetAllUserWallets(userId requests.Id) (*marketaccount.WalletsEnvelope, error)
GetAccountInfoByAccountID(accountId requests.Id) (*marketaccount.AccountInfo, error)
GetAccounts(userId requests.Id) (*marketaccount.AccountsEnvelope, error)
GetWallets(userId requests.Id) (*marketaccount.WalletsEnvelope, error)
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment