UNPKG

@verified-network/verified-sdk

Version:

An SDK to develop applications on the Verified Network

144 lines (143 loc) 8.01 kB
"use strict"; // SPDX-License-Identifier: BUSL-1.1 // @ts-nocheck Object.defineProperty(exports, "__esModule", { value: true }); const index_1 = require("../index"); const Client_json_1 = require("../../abi/securities/Client.json"); var FUNCTIONS; (function (FUNCTIONS) { FUNCTIONS["SETSIGNER"] = "setSigner"; FUNCTIONS["GETROLE"] = "getRole"; FUNCTIONS["REMOVEROLE"] = "removeRole"; FUNCTIONS["ADDROLE"] = "addRole"; FUNCTIONS["UPDATEKYC"] = "KycUpdate"; FUNCTIONS["FULLKYCUPDATE"] = "fullKycUpdate"; FUNCTIONS["GETCLIENTKYC"] = "getClientKYC"; FUNCTIONS["GETFULLKYC"] = "getFullClientKYC"; FUNCTIONS["SETAMLSCORE"] = "setAmlScore"; FUNCTIONS["SETCREDITSCORE"] = "setCreditScore"; FUNCTIONS["SETAMLPASSSCORE"] = "setAmlPassScore"; FUNCTIONS["GETAMLSTATUS"] = "getAMLStatus"; FUNCTIONS["SETCUSTODYACCOUNT"] = "setCustodyAccount"; FUNCTIONS["GETCUSTODYACCOUNT"] = "getCustodyAccount"; FUNCTIONS["GETMANAGERS"] = "getManagers"; FUNCTIONS["SETCUSTODY"] = "setCustody"; FUNCTIONS["GETCUSTODY"] = "getCustody"; })(FUNCTIONS || (FUNCTIONS = {})); class Client extends index_1.VerifiedContract { constructor(signer, contractNetworkAddress) { const address = contractNetworkAddress; //const chainId: string = Object.keys(networks) //const address = networks[chainId].address super(address, JSON.stringify(Client_json_1.abi), signer); this.contractAddress = address; } async _getMeeQuote(paymentTokenAddress, functionName, args, apiKey, rpcUrl) { return await this.getQuote(paymentTokenAddress, functionName, args, rpcUrl, apiKey); } async setSigner(_address, options) { await this.validateInput(index_1.DATATYPES.ADDRESS, _address); return this.callContract(FUNCTIONS.SETSIGNER, _address, options); } /** * Get sub-managers for role [callable only by manager] * @params (address _submanager, bytes32 _country) * @returns {address[] memory} */ async getRole(_submanager, options) { await this.validateInput(index_1.DATATYPES.ADDRESS, _submanager); return this.callContract(FUNCTIONS.GETROLE, _submanager, options); } /** * Remove sub-manager from role [callable only by manager] * @params (address _submanager, bytes32 _country, bytes32 _role) * @returns */ async removeRole(_manager, _submanager, _country, _role, _hashedMessage, _v, _r, _s, options) { await this.validateInput(index_1.DATATYPES.ADDRESS, _manager); await this.validateInput(index_1.DATATYPES.ADDRESS, _submanager); await this.validateInput(index_1.DATATYPES.STRING, _country); await this.validateInput(index_1.DATATYPES.STRING, _role); return this.callContract(FUNCTIONS.REMOVEROLE, _manager, _submanager, this.sanitiseInput(index_1.DATATYPES.BYTE32, _country), this.sanitiseInput(index_1.DATATYPES.BYTE32, _role), _hashedMessage, _v, _r, _s, options); } /** * Create role for sub-manager [callable only by manager * @params (address _submanager, bytes32 _country, bytes32 _role) * @returns */ async addRole(_manager, _submanager, _country, _role, _id, _hashedMessage, _v, _r, _s, options) { await this.validateInput(index_1.DATATYPES.ADDRESS, _manager); await this.validateInput(index_1.DATATYPES.ADDRESS, _submanager); await this.validateInput(index_1.DATATYPES.STRING, _country); await this.validateInput(index_1.DATATYPES.STRING, _role); await this.validateInput(index_1.DATATYPES.STRING, _id); return this.callContract(FUNCTIONS.ADDROLE, _manager, _submanager, this.sanitiseInput(index_1.DATATYPES.BYTE32, _country), this.sanitiseInput(index_1.DATATYPES.BYTE32, _role), this.sanitiseInput(index_1.DATATYPES.BYTE32, _id), _hashedMessage, _v, _r, _s, options); } async KycUpdate(client, name, surname, country, contact, status, options) { await this.validateInput(index_1.DATATYPES.ADDRESS, client); await this.validateInput(index_1.DATATYPES.STRING, name); await this.validateInput(index_1.DATATYPES.STRING, surname); await this.validateInput(index_1.DATATYPES.STRING, country); await this.validateInput(index_1.DATATYPES.STRING, contact); await this.validateInput(index_1.DATATYPES.NUMBER, status); return this.callContract(FUNCTIONS.UPDATEKYC, client, this.sanitiseInput(index_1.DATATYPES.BYTE32, name), this.sanitiseInput(index_1.DATATYPES.BYTE32, surname), this.sanitiseInput(index_1.DATATYPES.BYTE32, country), this.sanitiseInput(index_1.DATATYPES.BYTE32, contact), status, options); } async fullKycUpdate(client, identity, videokyc, docs, options) { await this.validateInput(index_1.DATATYPES.ADDRESS, client); await this.validateInput(index_1.DATATYPES.STRING, identity); await this.validateInput(index_1.DATATYPES.STRING, videokyc); await this.validateInput(index_1.DATATYPES.STRING, docs); return this.callContract(FUNCTIONS.FULLKYCUPDATE, client, identity, videokyc, docs, options); } async getClientKYC(_client, options) { await this.validateInput(index_1.DATATYPES.ADDRESS, _client); return this.callContract(FUNCTIONS.GETCLIENTKYC, _client, options); } async getFullClientKYC(_client, options) { await this.validateInput(index_1.DATATYPES.ADDRESS, _client); return this.callContract(FUNCTIONS.GETFULLKYC, _client, options); } async setAmlScore(_client, _score, options) { await this.validateInput(index_1.DATATYPES.ADDRESS, _client); await this.validateInput(index_1.DATATYPES.NUMBER, _score); return this.callContract(FUNCTIONS.SETAMLSCORE, _client, _score, options); } async setCreditScore(_client, _score, options) { await this.validateInput(index_1.DATATYPES.ADDRESS, _client); await this.validateInput(index_1.DATATYPES.NUMBER, _score); return this.callContract(FUNCTIONS.SETCREDITSCORE, _client, _score, options); } async setAmlPassScore(_score, options) { await this.validateInput(index_1.DATATYPES.NUMBER, _score); return this.callContract(FUNCTIONS.SETAMLPASSSCORE, _score, options); } async getAMLStatus(_client, options) { await this.validateInput(index_1.DATATYPES.ADDRESS, _client); return this.callContract(FUNCTIONS.GETAMLSTATUS, _client, options); } async setCustodyAccount(_submanager, _currency, _accountId, options) { await this.validateInput(index_1.DATATYPES.ADDRESS, _submanager); await this.validateInput(index_1.DATATYPES.STRING, _currency); await this.validateInput(index_1.DATATYPES.STRING, _accountId); return this.callContract(FUNCTIONS.SETCUSTODYACCOUNT, _submanager, _currency, _accountId, options); } async getCustodyAccount(_submanager, options) { await this.validateInput(index_1.DATATYPES.ADDRESS, _submanager); return this.callContract(FUNCTIONS.GETCUSTODYACCOUNT, _submanager, options); } async getManagers(_country, _role, options) { await this.validateInput(index_1.DATATYPES.STRING, _country); await this.validateInput(index_1.DATATYPES.STRING, _role); return this.callContract(FUNCTIONS.GETMANAGERS, this.sanitiseInput(index_1.DATATYPES.BYTE32, _country), this.sanitiseInput(index_1.DATATYPES.BYTE32, _role), options); } async setCustody(_client, _account, options) { await this.validateInput(index_1.DATATYPES.ADDRESS, _client); await this.validateInput(index_1.DATATYPES.STRING, _account); return this.callContract(FUNCTIONS.SETCUSTODY, _client, this.sanitiseInput(index_1.DATATYPES.BYTE32, _account), options); } async getCustody(_client, options) { await this.validateInput(index_1.DATATYPES.ADDRESS, _client); return this.callContract(FUNCTIONS.GETCUSTODY, _client, options); } } exports.default = Client;