Skip to content

Instantly share code, notes, and snippets.

@SuddenlyHazel
Created February 25, 2023 00:06
Show Gist options
  • Save SuddenlyHazel/139e38b044e0c7f932ac4bc17a925f7f to your computer and use it in GitHub Desktop.
Save SuddenlyHazel/139e38b044e0c7f932ac4bc17a925f7f to your computer and use it in GitHub Desktop.
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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment