Function
Static Public Summary | ||
public |
checkBallotHashBSpec(ballotSpec: *, assertSpecHash: *): boolean |
|
public |
checkBallotHashGBallot(ballotObject: *): * |
|
public |
async checkIfAddressIsEditor(objectPattern: {"svNetwork": *}, objectPattern1: {"userAddress": *, "democHash": *}): * |
|
public |
cleanEthHex(hex: string): string This will take an Ethereum hex string (or a normal hex string) and output a normal hex string (no '0x' header) or throw an error on a bad hex string. |
|
public |
This compares ethereum addresses (taking into account case, etc) |
|
public |
ethSignHash(messageHash: *, privateKey: *): {messageHash: string, r: string, s: string, v: string} Sign a message such that it can be verified with |
|
public |
ethVerifySig(messageHash: string, v, r, s: string[]): {verified: bool, address: EthAddress} Operates |
|
public |
genRange3VoteData(votesArray: array): string Prepares voteData for a Range3 ballot from an array of votes |
|
public |
async getBackendAddress(objectPattern: {"index": *}): * |
|
public |
async getBallotObjectFromIpfs(ballotSpecHash: *): * |
|
public |
async getBallotObjectFromS3(archiveUrl: *, ballotSpecHash: *): * |
|
public |
async getBallotSpec(archiveUrl: *, ballotSpecHash: *): * |
|
public |
async getCommunityBallotPrice(objectPattern: {"payments": *}, democHash: *): * |
|
public |
async getContractAddresses(objectPattern: {"svNetwork": *}): {"indexAddress": *, "backendAddress": *, "auxAddress": *, "lookupAddress": *, "resolverAddress": *, "communityAuctionAddress": *, "delegationAddress": *, "paymentsAddress": *} Takes in the svNetwork object and returns all relevant addresses |
|
public |
async getCurrentGasPrice(): {"safeLow": *, "average": *, "fast": *, "fastest": *} |
|
public |
async getDemocBallots(objectPattern: {"svNetwork": *, "democHash": *}): * |
|
public |
async getDemocInfo(objectPattern: {"backend": *, "democHash": *}): * |
|
public |
async getDemocNthBallot(objectPattern: {"svNetwork": *}, democBallotInfo: *): * |
|
public |
getNetwork(networkId: *, chainId: *): * |
|
public |
hashMsgRaw(data: *): * Like web3.eth.accounts.hashMessage without the envelope. |
|
public |
hexToBase32(hex: string): string This will convert a hex string to Base32 in the bech32 format WITHOUT a checksum. |
|
public |
async initializeSvLight(svConfig: *): {"svConfig": *, "web3": *, "resolver": *, "index": *, "backend": *, "aux": *, "payments": *} |
|
public |
Creates a packed copy of start and end times with submissionBits |
|
public |
mkSignedBallotForProxy(ballotId: string, sequence: number, voteData: string, extra: string, privateKey: string, opts: object): object Take the arguments and produce web3 data fitting the |
|
public |
mkSubmissionBits(toCombine: *): number This combines flags into a finished submissionBits. |
|
public |
networkName(networkId: *): string |
|
public |
async resolveEnsAddress(objectPattern: {"resolver": *}, ensName: *): * |
|
public |
verifySignedBallotForProxy(proxyVote: ProxyVote, opts: *): {verified: bool, address: EthAddress} Verify a signed vote to be submitted via proxy as generated by |
|
public |
async weiToCents(objectPattern: {"payments": *}, wei: *): * |
Static Public
public checkBallotHashBSpec(ballotSpec: *, assertSpecHash: *): boolean source
import {checkBallotHashBSpec} from 'sv-lib/src/light.ts'
Params:
Name | Type | Attribute | Description |
ballotSpec | * | ||
assertSpecHash | * |
public checkBallotHashGBallot(ballotObject: *): * source
import {checkBallotHashGBallot} from 'sv-lib/src/light.ts'
Params:
Name | Type | Attribute | Description |
ballotObject | * |
Return:
* |
public async checkIfAddressIsEditor(objectPattern: {"svNetwork": *}, objectPattern1: {"userAddress": *, "democHash": *}): * source
import {checkIfAddressIsEditor} from 'sv-lib/src/light.ts'
Params:
Name | Type | Attribute | Description |
objectPattern | {"svNetwork": *} |
|
|
objectPattern1 | {"userAddress": *, "democHash": *} |
|
Return:
* |
public cleanEthHex(hex: string): string source
import {cleanEthHex} from 'sv-lib/src/utils.ts'
This will take an Ethereum hex string (or a normal hex string) and output a normal hex string (no '0x' header) or throw an error on a bad hex string.
Params:
Name | Type | Attribute | Description |
hex | string |
public ethAddrEq(addr1: string, addr2: string): bool source
import {ethAddrEq} from 'sv-lib/src/utils.ts'
This compares ethereum addresses (taking into account case, etc)
Return:
bool |
public ethSignHash(messageHash: *, privateKey: *): {messageHash: string, r: string, s: string, v: string} source
import {ethSignHash} from 'sv-lib/src/crypto.ts'
Sign a message such that it can be verified with ecrecover
.
Similar to web3.eth.accounts.sign
except that we sign the hash directly.
Params:
Name | Type | Attribute | Description |
messageHash | * | Hash of a message, as returned by |
|
privateKey | * | Privkey to sign with. |
public ethVerifySig(messageHash: string, v, r, s: string[]): {verified: bool, address: EthAddress} source
import {ethVerifySig} from 'sv-lib/src/crypto.ts'
Operates ecrecover
over the provided signature
Return:
{verified: bool, address: EthAddress} |
public genRange3VoteData(votesArray: array): string source
import {genRange3VoteData} from 'sv-lib/src/ballotBox.ts'
Prepares voteData for a Range3 ballot from an array of votes
Params:
Name | Type | Attribute | Description |
votesArray | array | Takes an array of numbers which represent the votes to be transformed Format: [1, 2, -1] |
public async getBackendAddress(objectPattern: {"index": *}): * source
import {getBackendAddress} from 'sv-lib/src/light.ts'
Params:
Name | Type | Attribute | Description |
objectPattern | {"index": *} |
|
Return:
* |
public async getBallotObjectFromIpfs(ballotSpecHash: *): * source
import {getBallotObjectFromIpfs} from 'sv-lib/src/light.ts'
Params:
Name | Type | Attribute | Description |
ballotSpecHash | * |
Return:
* |
public async getBallotObjectFromS3(archiveUrl: *, ballotSpecHash: *): * source
import {getBallotObjectFromS3} from 'sv-lib/src/light.ts'
Params:
Name | Type | Attribute | Description |
archiveUrl | * | ||
ballotSpecHash | * |
Return:
* |
public async getBallotSpec(archiveUrl: *, ballotSpecHash: *): * source
import {getBallotSpec} from 'sv-lib/src/light.ts'
Params:
Name | Type | Attribute | Description |
archiveUrl | * | ||
ballotSpecHash | * |
Return:
* |
public async getCommunityBallotPrice(objectPattern: {"payments": *}, democHash: *): * source
import {getCommunityBallotPrice} from 'sv-lib/src/light.ts'
Params:
Name | Type | Attribute | Description |
objectPattern | {"payments": *} |
|
|
democHash | * |
Return:
* |
public async getContractAddresses(objectPattern: {"svNetwork": *}): {"indexAddress": *, "backendAddress": *, "auxAddress": *, "lookupAddress": *, "resolverAddress": *, "communityAuctionAddress": *, "delegationAddress": *, "paymentsAddress": *} source
import {getContractAddresses} from 'sv-lib/src/light.ts'
Takes in the svNetwork object and returns all relevant addresses
Params:
Name | Type | Attribute | Description |
objectPattern | {"svNetwork": *} |
|
Return:
{"indexAddress": *, "backendAddress": *, "auxAddress": *, "lookupAddress": *, "resolverAddress": *, "communityAuctionAddress": *, "delegationAddress": *, "paymentsAddress": *} |
public async getCurrentGasPrice(): {"safeLow": *, "average": *, "fast": *, "fastest": *} source
import {getCurrentGasPrice} from 'sv-lib/src/light.ts'
Return:
{"safeLow": *, "average": *, "fast": *, "fastest": *} |
public async getDemocBallots(objectPattern: {"svNetwork": *, "democHash": *}): * source
import {getDemocBallots} from 'sv-lib/src/light.ts'
Params:
Name | Type | Attribute | Description |
objectPattern | {"svNetwork": *, "democHash": *} |
|
Return:
* |
public async getDemocInfo(objectPattern: {"backend": *, "democHash": *}): * source
import {getDemocInfo} from 'sv-lib/src/light.ts'
Params:
Name | Type | Attribute | Description |
objectPattern | {"backend": *, "democHash": *} |
|
Return:
* |
public async getDemocNthBallot(objectPattern: {"svNetwork": *}, democBallotInfo: *): * source
import {getDemocNthBallot} from 'sv-lib/src/light.ts'
Params:
Name | Type | Attribute | Description |
objectPattern | {"svNetwork": *} |
|
|
democBallotInfo | * |
Return:
* |
public getNetwork(networkId: *, chainId: *): * source
import {getNetwork} from 'sv-lib/src/const.ts'
Params:
Name | Type | Attribute | Description |
networkId | * | ||
chainId | * |
Return:
* |
public hashMsgRaw(data: *): * source
import {hashMsgRaw} from 'sv-lib/src/crypto.ts'
Like web3.eth.accounts.hashMessage without the envelope.
Params:
Name | Type | Attribute | Description |
data | * | A message to hash - if it is hex it'll be UTF8 decoded. |
Return:
* | The hashed message (using keccak256) |
public hexToBase32(hex: string): string source
import {hexToBase32} from 'sv-lib/src/utils.ts'
This will convert a hex string to Base32 in the bech32 format WITHOUT a checksum.
Params:
Name | Type | Attribute | Description |
hex | string | The hex string to convert to Base32 - can be an EthHex or plain hex string. |
public async initializeSvLight(svConfig: *): {"svConfig": *, "web3": *, "resolver": *, "index": *, "backend": *, "aux": *, "payments": *} source
import {initializeSvLight} from 'sv-lib/src/light.ts'
Params:
Name | Type | Attribute | Description |
svConfig | * |
Return:
{"svConfig": *, "web3": *, "resolver": *, "index": *, "backend": *, "aux": *, "payments": *} |
public mkPacked(start: number, end: number, submissionBits: number): BN source
import {mkPacked} from 'sv-lib/src/ballotBox.ts'
Creates a packed copy of start and end times with submissionBits
Return:
BN | Returns a |
public mkSignedBallotForProxy(ballotId: string, sequence: number, voteData: string, extra: string, privateKey: string, opts: object): object source
import {mkSignedBallotForProxy} from 'sv-lib/src/ballotBox.ts'
Take the arguments and produce web3 data fitting the submitProxyVote
method.
Params:
Name | Type | Attribute | Description |
ballotId | string | a BN.js or Hex ballotId |
|
sequence | number | the sequence number to use (0 < sequence < 2^32) |
|
voteData | string | the vote data to use, should be 32 bytes hex encoded |
|
extra | string | any extra data included with the vote (such as curve25519 pubkeys) |
|
privateKey | string | the privkey used to sign |
|
opts | object | options:
|
public mkSubmissionBits(toCombine: *): number source
import {mkSubmissionBits} from 'sv-lib/src/ballotBox.ts'
This combines flags into a finished submissionBits. It also does some validation.
Params:
Name | Type | Attribute | Description |
toCombine | * | Array of all submission flags to combine. See SV.ballotBox.flags for flag options. All flags must be a power of 2 (which indicates they occupy a single bit in the number when combining). |
public networkName(networkId: *): string source
import {networkName} from 'sv-lib/src/const.ts'
Params:
Name | Type | Attribute | Description |
networkId | * |
public async resolveEnsAddress(objectPattern: {"resolver": *}, ensName: *): * source
import {resolveEnsAddress} from 'sv-lib/src/light.ts'
Params:
Name | Type | Attribute | Description |
objectPattern | {"resolver": *} |
|
|
ensName | * |
Return:
* |
public verifySignedBallotForProxy(proxyVote: ProxyVote, opts: *): {verified: bool, address: EthAddress} source
import {verifySignedBallotForProxy} from 'sv-lib/src/ballotBox.ts'
Verify a signed vote to be submitted via proxy as generated by mkSignedBallotForProxy
Params:
Name | Type | Attribute | Description |
proxyVote | ProxyVote | The ProxyVote object |
|
opts | * |
|
Not used currently; for future options |
Return:
{verified: bool, address: EthAddress} |
public async weiToCents(objectPattern: {"payments": *}, wei: *): * source
import {weiToCents} from 'sv-lib/src/light.ts'
Params:
Name | Type | Attribute | Description |
objectPattern | {"payments": *} |
|
|
wei | * |
Return:
* |