New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@compound-finance/compound-js

Package Overview
Dependencies
Maintainers
3
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@compound-finance/compound-js - npm Package Compare versions

Comparing version 0.0.15 to 0.0.16

33

dist/nodejs/comp.d.ts

@@ -28,1 +28,34 @@ /**

export declare function claimComp(options?: any): Promise<any>;
/**
* Create a transaction to delegate Compound Governance voting rights to an
* address.
*
* @param {string} _address The address in which to find the COMP accrued.
* @param {CallOptions} [options] Options to set for `eth_call`, optional ABI
* (as JSON object), and ethers.js method overrides. The ABI can be a string
* of the single intended method, an array of many methods, or a JSON object
* of the ABI generated by a Solidity compiler.
*
* @returns {object} Returns an Ethers.js transaction object of the vote
* transaction.
*/
export declare function delegate(_address: string, options?: any): Promise<any>;
/**
* Delegate voting rights in Compound Governance using an EIP-712 signature.
*
* @param {string} _address The address to delegate the user's voting rights to.
* @param {number} nonce The contract state required to match the signature.
* This can be retrieved from the COMP contract's public nonces mapping.
* @param {number} expiry The time at which to expire the signature. A block
* timestamp as seconds since the unix epoch.
* @param {object} signature An object that contains the v, r, and, s values of
* an EIP-712 signature.
* @param {CallOptions} [options] Options to set for `eth_call`, optional ABI
* (as JSON object), and ethers.js method overrides. The ABI can be a string
* of the single intended method, an array of many methods, or a JSON object
* of the ABI generated by a Solidity compiler.
*
* @returns {object} Returns an Ethers.js transaction object of the vote
* transaction.
*/
export declare function delegateBySig(_address: string, nonce: number, expiry: number, signature?: any, options?: any): Promise<any>;

118

dist/nodejs/comp.js

@@ -39,3 +39,3 @@ "use strict";

exports.__esModule = true;
exports.claimComp = exports.getCompAccrued = exports.getCompBalance = void 0;
exports.delegateBySig = exports.delegate = exports.claimComp = exports.getCompAccrued = exports.getCompBalance = void 0;
var ethers_1 = require("ethers");

@@ -94,3 +94,3 @@ var eth = require("./eth");

if (typeof _address !== 'string') {
throw Error(errorPrefix + 'Argument `address` must be a string.');
throw Error(errorPrefix + 'Argument `_address` must be a string.');
}

@@ -101,3 +101,3 @@ try {

catch (e) {
throw Error(errorPrefix + 'Argument `address` must be a valid Ethereum address.');
throw Error(errorPrefix + 'Argument `_address` must be a valid Ethereum address.');
}

@@ -142,3 +142,3 @@ compAddress = constants_1.address[net.name].COMP;

if (typeof _address !== 'string') {
throw Error(errorPrefix + 'Argument `address` must be a string.');
throw Error(errorPrefix + 'Argument `_address` must be a string.');
}

@@ -149,3 +149,3 @@ try {

catch (e) {
throw Error(errorPrefix + 'Argument `address` must be a valid Ethereum address.');
throw Error(errorPrefix + 'Argument `_address` must be a valid Ethereum address.');
}

@@ -198,2 +198,110 @@ lensAddress = constants_1.address[net.name].CompoundLens;

exports.claimComp = claimComp;
/**
* Create a transaction to delegate Compound Governance voting rights to an
* address.
*
* @param {string} _address The address in which to find the COMP accrued.
* @param {CallOptions} [options] Options to set for `eth_call`, optional ABI
* (as JSON object), and ethers.js method overrides. The ABI can be a string
* of the single intended method, an array of many methods, or a JSON object
* of the ABI generated by a Solidity compiler.
*
* @returns {object} Returns an Ethers.js transaction object of the vote
* transaction.
*/
function delegate(_address, options) {
if (options === void 0) { options = {}; }
return __awaiter(this, void 0, void 0, function () {
var errorPrefix, compAddress, trxOptions, parameters, method;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, helpers_1.netId(this)];
case 1:
_a.sent();
errorPrefix = 'Compound [delegate] | ';
if (typeof _address !== 'string') {
throw Error(errorPrefix + 'Argument `_address` must be a string.');
}
try {
_address = toChecksumAddress(_address);
}
catch (e) {
throw Error(errorPrefix + 'Argument `_address` must be a valid Ethereum address.');
}
compAddress = constants_1.address[this._network.name].COMP;
trxOptions = options;
trxOptions._compoundProvider = this._provider;
trxOptions.abi = constants_1.abi.COMP;
parameters = [_address];
method = 'delegate(address)';
return [2 /*return*/, eth.trx(compAddress, method, parameters, trxOptions)];
}
});
});
}
exports.delegate = delegate;
/**
* Delegate voting rights in Compound Governance using an EIP-712 signature.
*
* @param {string} _address The address to delegate the user's voting rights to.
* @param {number} nonce The contract state required to match the signature.
* This can be retrieved from the COMP contract's public nonces mapping.
* @param {number} expiry The time at which to expire the signature. A block
* timestamp as seconds since the unix epoch.
* @param {object} signature An object that contains the v, r, and, s values of
* an EIP-712 signature.
* @param {CallOptions} [options] Options to set for `eth_call`, optional ABI
* (as JSON object), and ethers.js method overrides. The ABI can be a string
* of the single intended method, an array of many methods, or a JSON object
* of the ABI generated by a Solidity compiler.
*
* @returns {object} Returns an Ethers.js transaction object of the vote
* transaction.
*/
function delegateBySig(_address, nonce, expiry, signature, options) {
if (signature === void 0) { signature = {}; }
if (options === void 0) { options = {}; }
return __awaiter(this, void 0, void 0, function () {
var errorPrefix, compAddress, trxOptions, v, r, s, parameters, method;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, helpers_1.netId(this)];
case 1:
_a.sent();
errorPrefix = 'Compound [delegateBySig] | ';
if (typeof _address !== 'string') {
throw Error(errorPrefix + 'Argument `_address` must be a string.');
}
try {
_address = toChecksumAddress(_address);
}
catch (e) {
throw Error(errorPrefix + 'Argument `_address` must be a valid Ethereum address.');
}
if (typeof nonce !== 'number') {
throw Error(errorPrefix + 'Argument `nonce` must be an integer.');
}
if (typeof expiry !== 'number') {
throw Error(errorPrefix + 'Argument `expiry` must be an integer.');
}
if (!Object.isExtensible(signature) ||
!signature.v ||
!signature.r ||
!signature.s) {
throw Error(errorPrefix + 'Argument `signature` must be an object that ' +
'contains the v, r, and s pieces of an EIP-712 signature.');
}
compAddress = constants_1.address[this._network.name].COMP;
trxOptions = options;
trxOptions._compoundProvider = this._provider;
trxOptions.abi = constants_1.abi.COMP;
v = signature.v, r = signature.r, s = signature.s;
parameters = [_address, nonce, expiry, v, r, s];
method = 'delegateBySig';
return [2 /*return*/, eth.trx(compAddress, method, parameters, trxOptions)];
}
});
});
}
exports.delegateBySig = delegateBySig;
//# sourceMappingURL=comp.js.map

10

dist/nodejs/gov.d.ts
/**
* Submit a vote on a Compound Governance proposal.
*
* @param {String} proposalId The ID of the proposal to vote on. This is an
* @param {string} proposalId The ID of the proposal to vote on. This is an
* auto-incrementing integer in the Governor Alpha contract.

@@ -12,9 +12,9 @@ *

/**
* Submit a vote on a Compound Governance proposal using a EIP-712 signature.
* Submit a vote on a Compound Governance proposal using an EIP-712 signature.
*
* @param {String} proposalId The ID of the proposal to vote on. This is an
* @param {string} proposalId The ID of the proposal to vote on. This is an
* auto-incrementing integer in the Governor Alpha contract.
* @param {Boolean} support A boolean of true for 'yes' or false for 'no' on the
* @param {boolean} support A boolean of true for 'yes' or false for 'no' on the
* proposal vote.
* @param {Object} signature An object that contains the v, r, and, s values of
* @param {object} signature An object that contains the v, r, and, s values of
* an EIP-712 signature.

@@ -21,0 +21,0 @@ * @param {CallOptions} [options] Options to set for `eth_call`, optional ABI

@@ -46,3 +46,3 @@ "use strict";

*
* @param {String} proposalId The ID of the proposal to vote on. This is an
* @param {string} proposalId The ID of the proposal to vote on. This is an
* auto-incrementing integer in the Governor Alpha contract.

@@ -82,9 +82,9 @@ *

/**
* Submit a vote on a Compound Governance proposal using a EIP-712 signature.
* Submit a vote on a Compound Governance proposal using an EIP-712 signature.
*
* @param {String} proposalId The ID of the proposal to vote on. This is an
* @param {string} proposalId The ID of the proposal to vote on. This is an
* auto-incrementing integer in the Governor Alpha contract.
* @param {Boolean} support A boolean of true for 'yes' or false for 'no' on the
* @param {boolean} support A boolean of true for 'yes' or false for 'no' on the
* proposal vote.
* @param {Object} signature An object that contains the v, r, and, s values of
* @param {object} signature An object that contains the v, r, and, s values of
* an EIP-712 signature.

@@ -91,0 +91,0 @@ * @param {CallOptions} [options] Options to set for `eth_call`, optional ABI

@@ -38,3 +38,3 @@ "use strict";

provider = eth.createProvider(options);
var instance = __assign(__assign(__assign(__assign(__assign({ _provider: provider }, comptroller), cToken), priceFeed), gov), { claimComp: comp.claimComp });
var instance = __assign(__assign(__assign(__assign(__assign({ _provider: provider }, comptroller), cToken), priceFeed), gov), { claimComp: comp.claimComp, delegate: comp.delegate, delegateBySig: comp.delegateBySig });
// Instance needs to know which network the provider connects to, so it can

@@ -41,0 +41,0 @@ // use the correct contract addresses.

{
"name": "@compound-finance/compound-js",
"browser": "dist/browser/compound.min.js",
"version": "0.0.15",
"version": "0.0.16",
"description": "A JavaScript SDK for Ethereum and the Compound Protocol.",

@@ -6,0 +6,0 @@ "main": "dist/nodejs/index.js",

@@ -53,3 +53,3 @@ import { ethers } from 'ethers';

if (typeof _address !== 'string') {
throw Error(errorPrefix + 'Argument `address` must be a string.');
throw Error(errorPrefix + 'Argument `_address` must be a string.');
}

@@ -60,3 +60,3 @@

} catch(e) {
throw Error(errorPrefix + 'Argument `address` must be a valid Ethereum address.');
throw Error(errorPrefix + 'Argument `_address` must be a valid Ethereum address.');
}

@@ -91,3 +91,3 @@

if (typeof _address !== 'string') {
throw Error(errorPrefix + 'Argument `address` must be a string.');
throw Error(errorPrefix + 'Argument `_address` must be a string.');
}

@@ -98,3 +98,3 @@

} catch(e) {
throw Error(errorPrefix + 'Argument `address` must be a valid Ethereum address.');
throw Error(errorPrefix + 'Argument `_address` must be a valid Ethereum address.');
}

@@ -136,1 +136,107 @@

}
/**
* Create a transaction to delegate Compound Governance voting rights to an
* address.
*
* @param {string} _address The address in which to find the COMP accrued.
* @param {CallOptions} [options] Options to set for `eth_call`, optional ABI
* (as JSON object), and ethers.js method overrides. The ABI can be a string
* of the single intended method, an array of many methods, or a JSON object
* of the ABI generated by a Solidity compiler.
*
* @returns {object} Returns an Ethers.js transaction object of the vote
* transaction.
*/
export async function delegate(_address: string, options: any = {}) {
await netId(this);
const errorPrefix = 'Compound [delegate] | ';
if (typeof _address !== 'string') {
throw Error(errorPrefix + 'Argument `_address` must be a string.');
}
try {
_address = toChecksumAddress(_address);
} catch(e) {
throw Error(errorPrefix + 'Argument `_address` must be a valid Ethereum address.');
}
const compAddress = address[this._network.name].COMP;
const trxOptions: any = options;
trxOptions._compoundProvider = this._provider;
trxOptions.abi = abi.COMP;
const parameters = [ _address ];
const method = 'delegate(address)';
return eth.trx(compAddress, method, parameters, trxOptions);
}
/**
* Delegate voting rights in Compound Governance using an EIP-712 signature.
*
* @param {string} _address The address to delegate the user's voting rights to.
* @param {number} nonce The contract state required to match the signature.
* This can be retrieved from the COMP contract's public nonces mapping.
* @param {number} expiry The time at which to expire the signature. A block
* timestamp as seconds since the unix epoch.
* @param {object} signature An object that contains the v, r, and, s values of
* an EIP-712 signature.
* @param {CallOptions} [options] Options to set for `eth_call`, optional ABI
* (as JSON object), and ethers.js method overrides. The ABI can be a string
* of the single intended method, an array of many methods, or a JSON object
* of the ABI generated by a Solidity compiler.
*
* @returns {object} Returns an Ethers.js transaction object of the vote
* transaction.
*/
export async function delegateBySig(
_address: string,
nonce: number,
expiry: number,
signature: any = {},
options: any = {}
) {
await netId(this);
const errorPrefix = 'Compound [delegateBySig] | ';
if (typeof _address !== 'string') {
throw Error(errorPrefix + 'Argument `_address` must be a string.');
}
try {
_address = toChecksumAddress(_address);
} catch(e) {
throw Error(errorPrefix + 'Argument `_address` must be a valid Ethereum address.');
}
if (typeof nonce !== 'number') {
throw Error(errorPrefix + 'Argument `nonce` must be an integer.');
}
if (typeof expiry !== 'number') {
throw Error(errorPrefix + 'Argument `expiry` must be an integer.');
}
if (
!Object.isExtensible(signature) ||
!signature.v ||
!signature.r ||
!signature.s
) {
throw Error(errorPrefix + 'Argument `signature` must be an object that ' +
'contains the v, r, and s pieces of an EIP-712 signature.');
}
const compAddress = address[this._network.name].COMP;
const trxOptions: any = options;
trxOptions._compoundProvider = this._provider;
trxOptions.abi = abi.COMP;
const { v, r, s } = signature;
const parameters = [ _address, nonce, expiry, v, r, s ];
const method = 'delegateBySig';
return eth.trx(compAddress, method, parameters, trxOptions);
}

@@ -9,3 +9,3 @@ import { ethers } from 'ethers';

*
* @param {String} proposalId The ID of the proposal to vote on. This is an
* @param {string} proposalId The ID of the proposal to vote on. This is an
* auto-incrementing integer in the Governor Alpha contract.

@@ -40,9 +40,9 @@ *

/**
* Submit a vote on a Compound Governance proposal using a EIP-712 signature.
* Submit a vote on a Compound Governance proposal using an EIP-712 signature.
*
* @param {String} proposalId The ID of the proposal to vote on. This is an
* @param {string} proposalId The ID of the proposal to vote on. This is an
* auto-incrementing integer in the Governor Alpha contract.
* @param {Boolean} support A boolean of true for 'yes' or false for 'no' on the
* @param {boolean} support A boolean of true for 'yes' or false for 'no' on the
* proposal vote.
* @param {Object} signature An object that contains the v, r, and, s values of
* @param {object} signature An object that contains the v, r, and, s values of
* an EIP-712 signature.

@@ -49,0 +49,0 @@ * @param {CallOptions} [options] Options to set for `eth_call`, optional ABI

@@ -34,2 +34,4 @@ import { ethers } from 'ethers';

claimComp: comp.claimComp,
delegate: comp.delegate,
delegateBySig: comp.delegateBySig,
};

@@ -36,0 +38,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc