@celo/contractkit
Version:
Celo's ContractKit to interact with Celo network
104 lines • 6.42 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.EscrowWrapper = void 0;
const BaseWrapper_1 = require("./BaseWrapper");
/**
* Contract for handling reserve for stable currencies
*/
class EscrowWrapper extends BaseWrapper_1.BaseWrapper {
constructor() {
super(...arguments);
/**
* @notice Gets the unique escrowed payment for a given payment ID
* @param paymentId The ID of the payment to get.
* @return An EscrowedPayment struct which holds information such
* as; recipient identifier, sender address, token address, value, etc.
*/
this.escrowedPayments = (0, BaseWrapper_1.proxyCall)(this.contract.methods.escrowedPayments);
/**
* @notice Gets array of all Escrowed Payments received by identifier.
* @param identifier The hash of an identifier of the receiver of the escrowed payment.
* @return An array containing all the IDs of the Escrowed Payments that were received
* by the specified receiver.
*/
this.getReceivedPaymentIds = (0, BaseWrapper_1.proxyCall)(this.contract.methods.getReceivedPaymentIds);
/**
* @notice Gets array of all Escrowed Payment IDs sent by sender.
* @param sender The address of the sender of the escrowed payments.
* @return An array containing all the IDs of the Escrowed Payments that were sent by the
* specified sender.
*/
this.getSentPaymentIds = (0, BaseWrapper_1.proxyCall)(this.contract.methods.getSentPaymentIds);
/**
* @notice Gets trusted issuers set as default for payments by `transfer` function.
* @return An array of addresses of trusted issuers.
*/
this.getDefaultTrustedIssuers = (0, BaseWrapper_1.proxyCall)(this.contract.methods.getDefaultTrustedIssuers);
/**
* @notice Gets array of all trusted issuers set per paymentId.
* @param paymentId The ID of the payment to get.
* @return An array of addresses of trusted issuers set for an escrowed payment.
*/
this.getTrustedIssuersPerPayment = (0, BaseWrapper_1.proxyCall)(this.contract.methods.getTrustedIssuersPerPayment);
/**
* @notice Transfer tokens to a specific user. Supports both identity with privacy (an empty
* identifier and 0 minAttestations) and without (with identifier and minAttestations).
* Sets trustedIssuers to the issuers listed in `defaultTrustedIssuers`.
* (To override this and set custom trusted issuers, use `transferWithTrustedIssuers`.)
* @param identifier The hashed identifier of a user to transfer to.
* @param token The token to be transferred.
* @param value The amount to be transferred.
* @param expirySeconds The number of seconds before the sender can revoke the payment.
* @param paymentId The address of the temporary wallet associated with this payment. Users must
* prove ownership of the corresponding private key to withdraw from escrow.
* @param minAttestations The min number of attestations required to withdraw the payment.
* @return True if transfer succeeded.
* @dev Throws if 'token' or 'value' is 0.
* @dev Throws if identifier is null and minAttestations > 0.
* @dev If minAttestations is 0, trustedIssuers will be set to empty list.
* @dev msg.sender needs to have already approved this contract to transfer
*/
this.transfer = (0, BaseWrapper_1.proxySend)(this.connection, this.contract.methods.transfer);
/**
* @notice Withdraws tokens for a verified user.
* @param paymentId The ID for the EscrowedPayment struct that contains all relevant information.
* @param v The recovery id of the incoming ECDSA signature.
* @param r Output value r of the ECDSA signature.
* @param s Output value s of the ECDSA signature.
* @return True if withdraw succeeded.
* @dev Throws if 'token' or 'value' is 0.
* @dev Throws if msg.sender does not prove ownership of the withdraw key.
*/
this.withdraw = (0, BaseWrapper_1.proxySend)(this.connection, this.contract.methods.withdraw);
/**
* @notice Revokes tokens for a sender who is redeeming a payment after it has expired.
* @param paymentId The ID for the EscrowedPayment struct that contains all relevant information.
* @dev Throws if 'token' or 'value' is 0.
* @dev Throws if msg.sender is not the sender of payment.
* @dev Throws if redeem time hasn't been reached yet.
*/
this.revoke = (0, BaseWrapper_1.proxySend)(this.connection, this.contract.methods.revoke);
/**
* @notice Transfer tokens to a specific user. Supports both identity with privacy (an empty
* identifier and 0 minAttestations) and without (with identifier
* and attestations completed by trustedIssuers).
* @param identifier The hashed identifier of a user to transfer to.
* @param token The token to be transferred.
* @param value The amount to be transferred.
* @param expirySeconds The number of seconds before the sender can revoke the payment.
* @param paymentId The address of the temporary wallet associated with this payment. Users must
* prove ownership of the corresponding private key to withdraw from escrow.
* @param minAttestations The min number of attestations required to withdraw the payment.
* @param trustedIssuers Array of issuers whose attestations in FederatedAttestations.sol
* will be accepted to prove ownership over an identifier.
* @return True if transfer succeeded.
* @dev Throws if 'token' or 'value' is 0.
* @dev Throws if identifier is null and minAttestations > 0.
* @dev Throws if minAttestations == 0 but trustedIssuers are provided.
* @dev msg.sender needs to have already approved this contract to transfer.
*/
this.transferWithTrustedIssuers = (0, BaseWrapper_1.proxySend)(this.connection, this.contract.methods.transferWithTrustedIssuers);
}
}
exports.EscrowWrapper = EscrowWrapper;
//# sourceMappingURL=Escrow.js.map