Skip to content

Commit

Permalink
docs: add some documentation for Icrc21 request objects (#711)
Browse files Browse the repository at this point in the history
# Motivation

Add similar doc for Icrc consent message request objects for ICP as for
ICRC provided in PR #710.

Signed-off-by: David Dal Busco <david.dalbusco@dfinity.org>
  • Loading branch information
peterpeterparker authored Sep 3, 2024
1 parent e51ed1d commit d9174b8
Showing 1 changed file with 26 additions and 1 deletion.
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

0 comments on commit d9174b8

Please sign in to comment.