Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add some documentation for Icrc21 request objects #711

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion packages/ledger-icp/src/types/ledger_converters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,24 @@ export type Icrc2ApproveRequest = Omit<Icrc1TransferRequest, "to"> & {
expires_at?: Icrc1Timestamp;
spender: Account;
};

/**
* Metadata for the consent message in ICRC-21 specification.
* @param {number} [utcOffsetMinutes] - The user's local timezone offset in minutes from UTC. If absent, the default is UTC.
* @param {string} language - BCP-47 language tag. See https://www.rfc-editor.org/rfc/bcp/bcp47.txt
*/
export type Icrc21ConsentMessageMetadata = {
utcOffsetMinutes?: number;
language: string;
};

/**
* Device specification for displaying the consent message.
*
* @param {null} [GenericDisplay] - A generic display able to handle large documents and do line wrapping and pagination / scrolling. Text must be Markdown formatted, no external resources (e.g. images) are allowed.
* @param {Object} [LineDisplay] - Simple display able to handle lines of text with a maximum number of characters per line.
* @param {number} LineDisplay.charactersPerLine - Maximum number of characters that can be displayed per line.
* @param {number} LineDisplay.linesPerPage - Maximum number of lines that can be displayed at once on a single page.
*/
export type Icrc21ConsentMessageDeviceSpec =
| { GenericDisplay: null }
| {
Expand All @@ -70,11 +82,24 @@ export type Icrc21ConsentMessageDeviceSpec =
};
};

/**
* Specification for the consent message, including metadata and device preferences.
*
* @param {Icrc21ConsentMessageMetadata} metadata - Metadata of the consent message.
* @param {Icrc21ConsentMessageDeviceSpec} [deviceSpec] - Information about the device responsible for presenting the consent message to the user.
*/
export type Icrc21ConsentMessageSpec = {
metadata: Icrc21ConsentMessageMetadata;
deriveSpec?: Icrc21ConsentMessageDeviceSpec;
};

/**
* Parameters for the consent message request.
*
* @param {string} method - Method name of the canister call.
* @param {Uint8Array} arg - Argument of the canister call.
* @param {Icrc21ConsentMessageSpec} userPreferences - User preferences with regards to the consent message presented to the end-user.
*/
export type Icrc21ConsentMessageRequest = Omit<
icrc21_consent_message_request,
"user_preferences"
Expand Down
Loading