@compound-finance/compound-js
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -6,3 +6,3 @@ /** | ||
*/ | ||
import { CallOptions, TrxResponse, Signature } from './types'; | ||
import { CallOptions, TrxResponse, Signature, Provider } from './types'; | ||
/** | ||
@@ -12,3 +12,4 @@ * Get the balance of COMP tokens held by an address. | ||
* @param {string} _address The address in which to find the COMP balance. | ||
* @param {string} [_provider] A valid Ethereum provider string. | ||
* @param {Provider | string} [_provider] An Ethers.js provider or valid network | ||
* name string. | ||
* | ||
@@ -27,3 +28,3 @@ * @returns {string} Returns a string of the numeric balance of COMP. The value | ||
*/ | ||
export declare function getCompBalance(_address: string, _provider?: string): Promise<string>; | ||
export declare function getCompBalance(_address: string, _provider?: Provider | string): Promise<string>; | ||
/** | ||
@@ -48,3 +49,3 @@ * Get the amount of COMP tokens accrued but not yet claimed by an address. | ||
*/ | ||
export declare function getCompAccrued(_address: string, _provider?: string): Promise<string>; | ||
export declare function getCompAccrued(_address: string, _provider?: Provider | string): Promise<string>; | ||
/** | ||
@@ -51,0 +52,0 @@ * Create a transaction to claim accrued COMP tokens for the user. |
@@ -91,3 +91,4 @@ "use strict"; | ||
* @param {string} _address The address in which to find the COMP balance. | ||
* @param {string} [_provider] A valid Ethereum provider string. | ||
* @param {Provider | string} [_provider] An Ethers.js provider or valid network | ||
* name string. | ||
* | ||
@@ -94,0 +95,0 @@ * @returns {string} Returns a string of the numeric balance of COMP. The value |
@@ -90,3 +90,3 @@ /** | ||
* | ||
* @param {any{} | string} [provider] Optional Ethereum network provider. | ||
* @param {Provider | string} [provider] Optional Ethereum network provider. | ||
* Defaults to Ethers.js fallback mainnet provider. | ||
@@ -104,3 +104,3 @@ * | ||
* @param {string} address The Ethereum address in which to get the ETH balance. | ||
* @param {any{} | string} [provider] Optional Ethereum network provider. | ||
* @param {Provider | string} [provider] Optional Ethereum network provider. | ||
* Defaults to Ethers.js fallback mainnet provider. | ||
@@ -121,3 +121,3 @@ * | ||
*/ | ||
export declare function getBalance(address: string, provider: Provider): Promise<string>; | ||
export declare function getBalance(address: string, provider: Provider | string): Promise<string>; | ||
/** | ||
@@ -124,0 +124,0 @@ * Creates an Ethereum network provider object. |
@@ -247,3 +247,3 @@ "use strict"; | ||
* | ||
* @param {any{} | string} [provider] Optional Ethereum network provider. | ||
* @param {Provider | string} [provider] Optional Ethereum network provider. | ||
* Defaults to Ethers.js fallback mainnet provider. | ||
@@ -292,3 +292,3 @@ * | ||
* @param {string} address The Ethereum address in which to get the ETH balance. | ||
* @param {any{} | string} [provider] Optional Ethereum network provider. | ||
* @param {Provider | string} [provider] Optional Ethereum network provider. | ||
* Defaults to Ethers.js fallback mainnet provider. | ||
@@ -322,6 +322,9 @@ * | ||
providerInstance = _createProvider({ provider: _provider }); | ||
if (!providerInstance.send) { | ||
if (!providerInstance.send && providerInstance.providerConfigs) { | ||
url = providerInstance.providerConfigs[0].provider.connection.url; | ||
providerInstance = new ethers_1.ethers.providers.JsonRpcProvider(url); | ||
} | ||
else if (!providerInstance.send && providerInstance.provider) { | ||
providerInstance = providerInstance.provider; | ||
} | ||
return [4 /*yield*/, providerInstance.send('eth_getBalance', [address, 'latest'])]; | ||
@@ -328,0 +331,0 @@ case 1: |
@@ -15,5 +15,5 @@ /** | ||
* | ||
* @param {any{} | string} [provider] Optional Ethereum network provider. | ||
* @param {Provider | string} [provider] Optional Ethereum network provider. | ||
* Defaults to Ethers.js fallback mainnet provider. | ||
* @param {any{}} [options] Optional provider options. | ||
* @param {object} [options] Optional provider options. | ||
* | ||
@@ -20,0 +20,0 @@ * @example |
@@ -33,5 +33,5 @@ "use strict"; | ||
* | ||
* @param {any{} | string} [provider] Optional Ethereum network provider. | ||
* @param {Provider | string} [provider] Optional Ethereum network provider. | ||
* Defaults to Ethers.js fallback mainnet provider. | ||
* @param {any{}} [options] Optional provider options. | ||
* @param {object} [options] Optional provider options. | ||
* | ||
@@ -38,0 +38,0 @@ * @example |
{ | ||
"name": "@compound-finance/compound-js", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"author": "Compound Labs, Inc.", | ||
@@ -5,0 +5,0 @@ "description": "A JavaScript SDK for Ethereum and the Compound Protocol.", |
@@ -5,3 +5,3 @@ # Compound.js | ||
[Compound.js Documentation](https://compound-finance.github.io/compound-js/docs/) | ||
[Compound.js Documentation](https://compound.finance/docs/compound-js) | ||
@@ -8,0 +8,0 @@ This SDK is in **open beta**, and is constantly under development. **USE AT YOUR OWN RISK**. |
@@ -52,2 +52,5 @@ const fs = require('fs'); | ||
// HTML escape < and > | ||
param = param.replace(/\</g, '<').replace(/\>/g, '>'); | ||
return param; | ||
@@ -118,3 +121,4 @@ } | ||
if (tags.returns) { | ||
const _return = tags.returns.toSingleLine().replace('{', '(').replace('}', ')'); | ||
let _return = tags.returns.toSingleLine().replace('{', '(').replace('}', ')'); | ||
_return = _return.replace(/\</g, '<').replace(/\>/g, '>'); | ||
result += '- `RETURN` ' + _return + '\n\n'; | ||
@@ -121,0 +125,0 @@ } |
@@ -19,4 +19,4 @@ <section id="introduction" name="Introduction"> | ||
- `[provider]` (any{} | string) Optional Ethereum network provider. Defaults to Ethers.js fallback mainnet provider. | ||
- `[options]` (any{}) Optional provider options. | ||
- `[provider]` (Provider | string) Optional Ethereum network provider. Defaults to Ethers.js fallback mainnet provider. | ||
- `[options]` (object) Optional provider options. | ||
- `RETURN` (object) Returns an instance of the Compound.js SDK. | ||
@@ -308,3 +308,3 @@ | ||
- `_address` (string) The address in which to find the COMP balance. | ||
- `[_provider]` (string) A valid Ethereum provider string. | ||
- `[_provider]` (Provider | string) An Ethers.js provider or valid network name string. | ||
- `RETURN` (string) Returns a string of the numeric balance of COMP. The value is scaled up by 18 decimal places. | ||
@@ -516,3 +516,3 @@ | ||
- `[options]` (CallOptions) 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. | ||
- `RETURN` (Promise<any>) Return value of the invoked smart contract member or an error object if the call failed. | ||
- `RETURN` (Promise<any>) Return value of the invoked smart contract member or an error object if the call failed. | ||
@@ -548,3 +548,3 @@ ```js | ||
- `[options]` (CallOptions) Options to set for `eth_sendTransaction`, (as JSON object), and Ethers.js method overrides. The ABI can be a string optional ABI of the single intended method, an array of many methods, or a JSON object of the ABI generated by a Solidity compiler. | ||
- `RETURN` (Promise<any>) Returns an Ethers.js `TransactionResponse` object or an error object if the transaction failed. | ||
- `RETURN` (Promise<any>) Returns an Ethers.js `TransactionResponse` object or an error object if the transaction failed. | ||
@@ -585,3 +585,3 @@ ```js | ||
- `address` (string) The Ethereum address in which to get the ETH balance. | ||
- `[provider]` (any{} | string) Optional Ethereum network provider. Defaults to Ethers.js fallback mainnet provider. | ||
- `[provider]` (Provider | string) Optional Ethereum network provider. Defaults to Ethers.js fallback mainnet provider. | ||
- `RETURN` (BigNumber) Returns a BigNumber hexadecimal value of the ETH balance of the address. | ||
@@ -588,0 +588,0 @@ |
@@ -19,2 +19,3 @@ /** | ||
DelegateSignatureMessage, | ||
Provider, | ||
} from './types'; | ||
@@ -57,3 +58,4 @@ | ||
* @param {string} _address The address in which to find the COMP balance. | ||
* @param {string} [_provider] A valid Ethereum provider string. | ||
* @param {Provider | string} [_provider] An Ethers.js provider or valid network | ||
* name string. | ||
* | ||
@@ -72,3 +74,6 @@ * @returns {string} Returns a string of the numeric balance of COMP. The value | ||
*/ | ||
export async function getCompBalance(_address: string, _provider='mainnet') : Promise<string> { | ||
export async function getCompBalance( | ||
_address: string, | ||
_provider : Provider | string='mainnet' | ||
) : Promise<string> { | ||
const provider = await eth._createProvider({ provider: _provider }); | ||
@@ -119,3 +124,6 @@ const net = await eth.getProviderNetwork(provider); | ||
*/ | ||
export async function getCompAccrued(_address: string, _provider='mainnet') : Promise<string> { | ||
export async function getCompAccrued( | ||
_address: string, | ||
_provider : Provider | string='mainnet' | ||
) : Promise<string> { | ||
const provider = await eth._createProvider({ provider: _provider }); | ||
@@ -122,0 +130,0 @@ const net = await eth.getProviderNetwork(provider); |
@@ -206,3 +206,3 @@ /** | ||
* | ||
* @param {any{} | string} [provider] Optional Ethereum network provider. | ||
* @param {Provider | string} [provider] Optional Ethereum network provider. | ||
* Defaults to Ethers.js fallback mainnet provider. | ||
@@ -246,3 +246,3 @@ * | ||
* @param {string} address The Ethereum address in which to get the ETH balance. | ||
* @param {any{} | string} [provider] Optional Ethereum network provider. | ||
* @param {Provider | string} [provider] Optional Ethereum network provider. | ||
* Defaults to Ethers.js fallback mainnet provider. | ||
@@ -263,3 +263,6 @@ * | ||
*/ | ||
export async function getBalance(address: string, provider: Provider) : Promise<string> { | ||
export async function getBalance( | ||
address: string, | ||
provider: Provider | string | ||
) : Promise<string> { | ||
let _provider; | ||
@@ -274,5 +277,8 @@ if (typeof provider === 'object' && provider._isSigner) { | ||
let providerInstance: any = _createProvider({ provider: _provider }); | ||
if (!providerInstance.send) { | ||
if (!providerInstance.send && providerInstance.providerConfigs) { | ||
const url = providerInstance.providerConfigs[0].provider.connection.url; | ||
providerInstance = new ethers.providers.JsonRpcProvider(url); | ||
} else if (!providerInstance.send && providerInstance.provider) { | ||
providerInstance = providerInstance.provider; | ||
} | ||
@@ -279,0 +285,0 @@ |
@@ -25,5 +25,5 @@ /** | ||
* | ||
* @param {any{} | string} [provider] Optional Ethereum network provider. | ||
* @param {Provider | string} [provider] Optional Ethereum network provider. | ||
* Defaults to Ethers.js fallback mainnet provider. | ||
* @param {any{}} [options] Optional provider options. | ||
* @param {object} [options] Optional provider options. | ||
* | ||
@@ -30,0 +30,0 @@ * @example |
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
1590544
12924