Skip to content

Instantly share code, notes, and snippets.

@SuddenlyHazel
Created February 25, 2023 00:06

Revisions

  1. SuddenlyHazel created this gist Feb 25, 2023.
    69 changes: 69 additions & 0 deletions archive.did
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,69 @@
    type BlockIndex = nat64;
    type Memo = nat64;
    type AccountIdentifier = blob;
    type Tokens = record { e8s : nat64 };
    type Timestamp = record { timestamp_nanos : nat64 };

    type Operation = variant {
    Mint : record {
    to : AccountIdentifier;
    amount : Tokens;
    };
    Burn : record {
    from : AccountIdentifier;
    amount : Tokens;
    };
    Transfer : record {
    from : AccountIdentifier;
    to : AccountIdentifier;
    amount : Tokens;
    fee : Tokens;
    };
    };

    type Transaction = record {
    memo : Memo;
    // Optional to support potential future variant extensions.
    operation : Operation;
    created_at_time : Timestamp;
    };

    type Block = record {
    parent_hash : opt blob;
    transaction : Transaction;
    timestamp : Timestamp;
    };

    type GetBlocksArgs = record {
    start : BlockIndex;
    length : nat64;
    };

    type BlockRange = record {
    blocks : vec Block;
    };

    type GetBlocksError = variant {

    /// The [GetBlocksArgs.start] is below the first block that
    /// archive node stores.
    BadFirstBlockIndex : record {
    requested_index : BlockIndex;
    first_valid_index : BlockIndex;
    };

    /// Reserved for future use.
    Other : record {
    error_code : nat64;
    error_message : text;
    };
    };

    type GetBlocksResult = variant {
    Ok : BlockRange;
    Err : GetBlocksError;
    };

    service : {
    get_blocks : (GetBlocksArgs) -> (GetBlocksResult) query;
    }