Class ORClientReader

Client for reading from ORDAO system

Hierarchy (view full)

Constructors

Properties

_clientToNode: ClientToNodeTransformer
_ctx: ORContext
_nodeToClient: NodeToClientTransformer
_vetoLength: undefined | number
_voteLength: undefined | number

Accessors

Methods

  • Get metadata of specific Respect award NTT. Throws if token is not found or is burned.

    Parameters

    • tokenId: string

      id of a token.

    Returns Promise<{
        description?: string;
        image?: string;
        name: string;
        properties: {
            burn?: null | {
                burnReason?: string;
                burnTxHash?: string;
            };
            denomination: number;
            groupNum?: number;
            level?: number;
            mintProposalId?: string;
            mintTs?: number;
            mintTxHash?: string;
            mintType: number;
            periodNumber: number;
            reason?: string;
            recipient: string;
            title?: string;
            tokenId: string;
        };
    }>

    Throws if token is not found or is burned.

  • Get metadata of Respect award NTTs, sorted from latest to oldest.

    Parameters

    • Optionalspec: {
          before?: Date;
          burned?: boolean;
          limit?: number;
          recipient?: string;
          tokenIdFilter?: string[];
      } | {
          burned?: boolean;
          limit?: number;
          recipient?: string;
          skip?: number;
          tokenIdFilter?: string[];
      } | {
          burned?: boolean;
          limit?: number;
          recipient?: string;
          tokenIdFilter?: string[];
      }

      specification for a query

      • before - newest mint date for a token. If specified, only tokens which were created up to this date will be returned;
      • limit - maximum number of tokens to return. If not specified, it's up to ornode implementation.
      • recipient - recipient of the awards. If specified only awards which belong to this account are returned.
      • burned - whether to return burned tokens or not. Default: false.

    Returns Promise<{
        description?: string;
        image?: string;
        name: string;
        properties: {
            burn?: null | {
                burnReason?: string;
                burnTxHash?: string;
            };
            denomination: number;
            groupNum?: number;
            level?: number;
            mintProposalId?: string;
            mintTs?: number;
            mintTxHash?: string;
            mintType: number;
            periodNumber: number;
            reason?: string;
            recipient: string;
            title?: string;
            tokenId: string;
        };
    }[]>

    list of token metadata objects sorted by mint datetime from latest to oldest.

    • By default this function does not return burned awards. Set burned in the spec to true to change this behaviour.
    await c.getAwards() // Return latest awards unfiltered
    await c.getAwards({ before: new Date("2024-08-30T11:42:59.000Z"), limit: 50 }) // Return up to 50 awards that happened before the specified date
    await c.getAwards({ recipient: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266" }) // Get latest awards belonging to specified accounts
  • Get a proposal by id or by OffchainPropId.

    Behavior:

    • If id is a PropId (bytes32), this returns the earliest-created instance for that id to preserve legacy links that referenced only the on-chain id.
    • If id is an OffchainPropId ({ id, createTxHash }), this returns the exact instance created by the given transaction.

    Parameters

    • id: string | {
          createTxHash: string;
          id: string;
      }

      PropId or { id, createTxHash }

    Returns Promise<{
        addr?: string;
        cancelTxHash?: string;
        cdata?: any;
        createTime: Date;
        createTxHash?: string;
        decoded?:
            | {
                groupNum: number;
                meetingNum: number;
                metadata: {
                    propDescription?: string;
                    propTitle?: string;
                };
                mintData: string;
                propType: "respectBreakout";
                rankings: string[];
            }
            | {
                groupNum: number;
                meetingNum: number;
                metadata: {
                    propDescription?: string;
                    propTitle?: string;
                };
                mintData: string;
                propType: "respectBreakoutX2";
                rankings: string[];
            }
            | {
                account: string;
                groupNum?: number;
                meetingNum: number;
                metadata: {
                    propDescription?: string;
                    propTitle?: string;
                };
                mintType: number;
                propType: "respectAccount";
                reason: string;
                title: string;
                tokenId: string;
                value: bigint;
            }
            | {
                awards: {
                    account: string;
                    groupNum?: number;
                    meetingNum: number;
                    mintType: number;
                    reason: string;
                    title: string;
                    tokenId: string;
                    value: bigint;
                }[];
                metadata: {
                    propDescription?: string;
                    propTitle?: string;
                };
                propType: "respectAccountBatch";
            }
            | {
                metadata: {
                    propDescription?: string;
                    propTitle?: string;
                };
                propType: "burnRespect";
                reason: string;
                tokenId: string;
            }
            | {
                metadata: {
                    propDescription?: string;
                    propTitle?: string;
                };
                propType: "burnRespectBatch";
                reason: string;
                tokenIds: string[];
            }
            | {
                data: string;
                link?: string;
                metadata: {
                    propDescription?: string;
                    propTitle?: string;
                };
                propType: "customSignal";
                signalType: number;
            }
            | {
                data?: string;
                link?: string;
                metadata: {
                    propDescription?: string;
                    propTitle?: string;
                };
                propType: "tick";
            }
            | {
                address: string;
                cdata: string;
                metadata: {
                    propDescription?: string;
                    propTitle?: string;
                };
                propType: "customCall";
            }
            | {
                canceledId: string;
                metadata: {
                    propDescription?: string;
                    propTitle?: string;
                };
                propType: "cancelProposal";
            }
            | {
                metadata: {
                    propDescription?: string;
                    propTitle?: string;
                };
                newVetoLen: bigint;
                newVoteLen: bigint;
                propType: "setPeriods";
            }
            | {
                metadata: {
                    propDescription?: string;
                    propTitle?: string;
                };
                newMinWeight: string;
                propType: "setMinWeight";
            }
            | {
                metadata: {
                    propDescription?: string;
                    propTitle?: string;
                };
                newMaxLiveYesVotes: number;
                propType: "setMaxLiveYesVotes";
            };
        execError?: {
            args: any[];
            data: null | string;
            name: null | string;
            reason: null | string;
            selector: null | string;
            signature: null | string;
            type: ErrorType;
        };
        executeTxHash?: string;
        id: string;
        memo?: any;
        noWeight?: string;
        stage:
            | "Voting"
            | "Veto"
            | "Execution"
            | "Expired";
        status:
            | "NotExecuted"
            | "Executed"
            | "ExecutionFailed"
            | "Canceled";
        vetoTimeLeftMs: ((...args: unknown[]) => number);
        voteStatus:
            | "Passing"
            | "Failing"
            | "Passed"
            | "Failed";
        voteTimeLeftMs: ((...args: unknown[]) => number);
        yesWeight?: string;
    }>

    // Legacy: first instance with this on-chain id
    await c.getProposal("0x2f5e1602a2e1ccc9cf707bc57361ae6587cd87e8ae27105cae38c0db12f4fab1")
    // Specific instance by offchain identifier
    await c.getProposal({ id: "0x...", createTxHash: "0x..." })
  • Get proposals ordered from latest to oldest.

    Parameters

    • Optionalspec: {
          before?: number;
          execStatFilter?: (
              | "NotExecuted"
              | "Executed"
              | "ExecutionFailed"
              | "Canceled")[];
          idFilter?: string;
          limit?: number;
          stageFilter?: (
              | "Voting"
              | "Veto"
              | "Execution"
              | "Expired")[];
          voteStatFilter?: (
              | "Passing"
              | "Failing"
              | "Passed"
              | "Failed")[];
      } | {
          execStatFilter?: (
              | "NotExecuted"
              | "Executed"
              | "ExecutionFailed"
              | "Canceled")[];
          idFilter?: string;
          limit?: number;
          skip?: number;
          stageFilter?: (
              | "Voting"
              | "Veto"
              | "Execution"
              | "Expired")[];
          voteStatFilter?: (
              | "Passing"
              | "Failing"
              | "Passed"
              | "Failed")[];
      } | {
          execStatFilter?: (
              | "NotExecuted"
              | "Executed"
              | "ExecutionFailed"
              | "Canceled")[];
          idFilter?: string;
          limit?: number;
          stageFilter?: (
              | "Voting"
              | "Veto"
              | "Execution"
              | "Expired")[];
          voteStatFilter?: (
              | "Passing"
              | "Failing"
              | "Passed"
              | "Failed")[];
      }

      Query specification:

      • before - newest allowed creation timestamp; only proposals created up to this time are returned.
      • limit - maximum number of proposals to return.
      • execStatFilter - filter by execution status (includes "Canceled"). If undefined, no exec-status filtering.
      • voteStatFilter - filter by vote status. If undefined, no vote-status filtering.
      • stageFilter - filter by stage. If undefined, no stage filtering.
      • idFilter - filter by a specific PropId when supported by the server.

    Returns Promise<{
        addr?: string;
        cancelTxHash?: string;
        cdata?: any;
        createTime: Date;
        createTxHash?: string;
        decoded?:
            | {
                groupNum: number;
                meetingNum: number;
                metadata: {
                    propDescription?: string;
                    propTitle?: string;
                };
                mintData: string;
                propType: "respectBreakout";
                rankings: string[];
            }
            | {
                groupNum: number;
                meetingNum: number;
                metadata: {
                    propDescription?: string;
                    propTitle?: string;
                };
                mintData: string;
                propType: "respectBreakoutX2";
                rankings: string[];
            }
            | {
                account: string;
                groupNum?: number;
                meetingNum: number;
                metadata: {
                    propDescription?: string;
                    propTitle?: string;
                };
                mintType: number;
                propType: "respectAccount";
                reason: string;
                title: string;
                tokenId: string;
                value: bigint;
            }
            | {
                awards: {
                    account: string;
                    groupNum?: number;
                    meetingNum: number;
                    mintType: number;
                    reason: string;
                    title: string;
                    tokenId: string;
                    value: bigint;
                }[];
                metadata: {
                    propDescription?: string;
                    propTitle?: string;
                };
                propType: "respectAccountBatch";
            }
            | {
                metadata: {
                    propDescription?: string;
                    propTitle?: string;
                };
                propType: "burnRespect";
                reason: string;
                tokenId: string;
            }
            | {
                metadata: {
                    propDescription?: string;
                    propTitle?: string;
                };
                propType: "burnRespectBatch";
                reason: string;
                tokenIds: string[];
            }
            | {
                data: string;
                link?: string;
                metadata: {
                    propDescription?: string;
                    propTitle?: string;
                };
                propType: "customSignal";
                signalType: number;
            }
            | {
                data?: string;
                link?: string;
                metadata: {
                    propDescription?: string;
                    propTitle?: string;
                };
                propType: "tick";
            }
            | {
                address: string;
                cdata: string;
                metadata: {
                    propDescription?: string;
                    propTitle?: string;
                };
                propType: "customCall";
            }
            | {
                canceledId: string;
                metadata: {
                    propDescription?: string;
                    propTitle?: string;
                };
                propType: "cancelProposal";
            }
            | {
                metadata: {
                    propDescription?: string;
                    propTitle?: string;
                };
                newVetoLen: bigint;
                newVoteLen: bigint;
                propType: "setPeriods";
            }
            | {
                metadata: {
                    propDescription?: string;
                    propTitle?: string;
                };
                newMinWeight: string;
                propType: "setMinWeight";
            }
            | {
                metadata: {
                    propDescription?: string;
                    propTitle?: string;
                };
                newMaxLiveYesVotes: number;
                propType: "setMaxLiveYesVotes";
            };
        execError?: {
            args: any[];
            data: null | string;
            name: null | string;
            reason: null | string;
            selector: null | string;
            signature: null | string;
            type: ErrorType;
        };
        executeTxHash?: string;
        id: string;
        memo?: any;
        noWeight?: string;
        stage:
            | "Voting"
            | "Veto"
            | "Execution"
            | "Expired";
        status:
            | "NotExecuted"
            | "Executed"
            | "ExecutionFailed"
            | "Canceled";
        vetoTimeLeftMs: ((...args: unknown[]) => number);
        voteStatus:
            | "Passing"
            | "Failing"
            | "Passed"
            | "Failed";
        voteTimeLeftMs: ((...args: unknown[]) => number);
        yesWeight?: string;
    }[]>

    Proposals sorted from latest to oldest.

    await c.getProposals()
    
  • Get metadata of fungible non-transferrable Respect token.

    Returns Promise<{
        decimals: 0;
        description?: string;
        image?: string;
        name?: string;
        properties?: {};
    }>

  • Get metadata of specific token. The token can be fungible Respect token or Respect award token (NTT).

    Parameters

    • tokenId: string

      id of a token.

    Returns Promise<{
        decimals?: number;
        description?: string;
        image?: string;
        name?: string;
        properties?: {};
    }>

    Throws if token is not found or is burned.

  • Get information on votes submitted on proposals. Votes returned are sorted from newest to oldest.

    Parameters

    • Optionalspec: {
          before?: Date;
          limit?: number;
          minWeight?: string;
          propFilter?: string[];
          voterFilter?: string[];
          voteType?: "Yes" | "No";
      }

      specification for a query

      • before - newest possible date of a vote. If specified, only votes made up to this date will be returned.
      • limit - maximum number of objects to return. If not specified it is up to implementation of ornode.
      • propFilter - list of proposal ids. If specified, then only votes on proposals in this list are returned.
      • voterFilter - list of ethereum addresses. If specified, only votes from this list of accounts are returned.
      • minWeight - minimum vote weight. If specified, only votes which have equal or greater weight are returned.
      • voteType - Yes / No. If specified only votes of specified type are returned.
      • Optionalbefore?: Date
      • Optionallimit?: number
      • OptionalminWeight?: string
      • OptionalpropFilter?: string[]
      • OptionalvoterFilter?: string[]
      • OptionalvoteType?: "Yes" | "No"

    Returns Promise<{
        date?: Date;
        memo?: string;
        proposalId: string;
        txHash?: string;
        vote: "None" | "Yes" | "No";
        voter: string;
        weight: string;
    }[]>

    await c.getVotes({ 
    voterFilter: [ "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", "0xcd3B766CCDd6AE721141F452C550Ca635964ce71" ],
    propFilter: [ "0xcc55ee4f4b5d61a9b90b5a5d915d8e7edede19e26b1a68be043d837654313760" ],
    limit: 10,
    minWeight: 1
    })