@frak-labs/core-sdk
Version:
Core SDK of the Frak wallet, low level library to interact directly with the frak ecosystem.
183 lines (175 loc) • 7.17 kB
text/typescript
import { Address } from 'viem';
import { Hex } from 'viem';
/**
* Represent a prepared user interaction, ready to be sent on-chain via the wallet
*/
declare type PreparedInteraction = {
handlerTypeDenominator: Hex;
interactionData: Hex;
};
/**
* Press interactions allow you to track user engagement with articles or other press content on your platform.
* After setting up these interactions, you can create acquisition campaign based on the user engagement with your press content.
*
* :::info
* To properly handle press interactions, ensure that the "Press" product type is enabled in your Business dashboard.
* :::
*
* @description Encode press related user interactions
*
* @group Interactions Encoder
*
* @see {@link PreparedInteraction} The prepared interaction object that can be sent
* @see {@link !actions.sendInteraction | `sendInteraction()`} Action used to send the prepared interaction to the Frak Wallet
*/
export declare const PressInteractionEncoder: {
/**
* Encode an open article interaction
* @param args
* @param args.articleId - The id of the article the user opened (32 bytes), could be a `keccak256` hash of the article slug, or your internal id
*/
openArticle({ articleId }: {
articleId: Hex;
}): PreparedInteraction;
/**
* Encode a read article interaction
* @param args
* @param args.articleId - The id of the article the user opened (32 bytes), could be a `keccak256` hash of the article slug, or your internal id
*/
readArticle({ articleId }: {
articleId: Hex;
}): PreparedInteraction;
};
/**
* Purchase interactions allow you to track user purchases on your platform.
* After setting up these interactions, you can create acquisition campaign based on the user purchase (starting a new one, completed, or even purchase dropped).
*
* :::info
* To properly handle purchase interactions, ensure that the "Purchase" product type is enabled in your Business dashboard, and that you have set up everything correctly in the `Purchasetracker` section.
* :::
*
* :::note
* The `purchaseId` is used on both interactions. It can be computed like this:
*
* ```ts
* const purchaseId = keccak256(concatHex([productId, toHex(externalPurchaseId)]));
* ```
*
* With:
* - `productId`: The id of your product, you can find it in the product dashboard.
* - `externalPurchaseId`: The id of the purchase in your system (e.g. the shopify `order_id`).
* :::
*
* @description Encode purchase related user interactions
*
* @group Interactions Encoder
*
* @see {@link !actions.sendInteraction | `sendInteraction()`} Action used to send the prepared interaction to the Frak Wallet
* @see {@link PreparedInteraction} The prepared interaction object that can be sent
* @see {@link !actions.trackPurchaseStatus | `trackPurchaseStatus()`} Action that will automatically send the purchase upon completion
* @see [Purchase Webhooks](/wallet-sdk/references-api/webhook) Webhooks to be implemented on your side to confirm a purchase
* @see [Purchase Proof](/wallet-sdk/references-api/purchaseProof) Get a merklee proof for the purchase
*/
export declare const PurchaseInteractionEncoder: {
/**
* Encode a start purchase interaction
* @param args
* @param args.purchaseId - The id of the purchase that is being started.
*/
startPurchase({ purchaseId }: {
purchaseId: Hex;
}): PreparedInteraction;
/**
* Encode a complete purchase interaction
* @param args
* @param args.purchaseId - The id of the purchase that is being completed.
* @param args.proof - The merkle proof that the user has completed the purchase (see [Purchase Webhooks](/wallet-sdk/references-api/webhook) for more details).
*/
completedPurchase({ purchaseId, proof, }: {
purchaseId: Hex;
proof: Hex[];
}): PreparedInteraction;
/**
* Encode an unsafe complete purchase interaction (when we can't provide the proof)
* @param args
* @param args.purchaseId - The id of the purchase that is being completed.
*/
unsafeCompletedPurchase({ purchaseId, }: {
purchaseId: Hex;
}): PreparedInteraction;
};
/**
* Referral interactions allow you to track user sharing activities.
* These interactions are essential for platforms looking to grow their user base through user-to-user referrals and reward systems.
*
* :::info
* To properly handle referral interactions, ensure that the "Referral" product type is enabled in your Business dashboard.
* :::
*
* @description Encode referral related user interactions
*
* @group Interactions Encoder
*
* @see {@link PreparedInteraction} The prepared interaction object that can be sent
* @see {@link !actions.sendInteraction | `sendInteraction()`} Action used to send the prepared interaction to the Frak Wallet
*/
export declare const ReferralInteractionEncoder: {
/**
* Records the event of a user creating a referral link. Note that this interaction doesn't actually create the link itself; it only sends an event to track that a link was created.
*/
createLink(): PreparedInteraction;
/**
* Encode a referred interaction
* @param args
* @param args.referrer - The Ethereum address of the user who made the referral
*/
referred({ referrer }: {
referrer: Address;
}): PreparedInteraction;
};
/**
* Retail interactions allow you to track user activities on your retails products.
*
* :::info
* To properly handle retail interactions, ensure that the "Retail" product type is enabled in your Business dashboard.
* :::
*
* @description Encode retail related user interactions
*
* @group Interactions Encoder
*
* @see {@link PreparedInteraction} The prepared interaction object that can be sent
* @see {@link !actions.sendInteraction | `sendInteraction()`} Action used to send the prepared interaction to the Frak Wallet
*/
export declare const RetailInteractionEncoder: {
/**
* Encode a customer meeting retail interaction
* @param args
* @param args.agencyId - The id of the agency that the customer is meeting with
*
*/
customerMeeting({ agencyId }: {
agencyId: Hex;
}): PreparedInteraction;
};
/**
* Webshop interactions allow you to track user activities on your webshop.
*
* :::info
* To properly handle webshop interactions, ensure that the "WebShop" product type is enabled in your Business dashboard.
* :::
*
* @description Encode webshop related user interactions
*
* @group Interactions Encoder
*
* @see {@link PreparedInteraction} The prepared interaction object that can be sent
* @see {@link !actions.sendInteraction | `sendInteraction()`} Action used to send the prepared interaction to the Frak Wallet
*/
export declare const WebShopInteractionEncoder: {
/**
* Encode an open webshop interaction
*/
open(): PreparedInteraction;
};
export { }