UNPKG

@frak-labs/core-sdk

Version:

Core SDK of the Frak wallet, low level library to interact directly with the frak ecosystem.

1 lines 1.57 kB
import{concatHex as e,encodeAbiParameters as r,pad as t,toHex as n}from"viem";let a="0xc0a24ffb",o="0xd5bd0fbe",i="0xb311798f",c="0x010cc3b9",l="0xb2c0f17c",p="0xd87e90c3",s="0x8403aeb4",d="0x4d5b14e0",h="0x74489004",u={dapp:1,press:2,webshop:3,retail:4,referral:30,purchase:31};Object.entries(u).reduce((e,[r,t])=>(e[r]=BigInt(1)<<BigInt(t),e),{});let m={openArticle({articleId:r}){let o=e([a,t(r,{size:32})]);return{handlerTypeDenominator:n(u.press),interactionData:o}},readArticle({articleId:r}){let a=e([o,t(r,{size:32})]);return{handlerTypeDenominator:n(u.press),interactionData:a}}},b={createLink:()=>({handlerTypeDenominator:n(u.referral),interactionData:l}),referred({referrer:r}){let a=e([c,t(r,{size:32})]);return{handlerTypeDenominator:n(u.referral),interactionData:a}}},f={startPurchase({purchaseId:r}){let a=e([p,t(r,{size:32})]);return{handlerTypeDenominator:n(u.purchase),interactionData:a}},completedPurchase({purchaseId:t,proof:a}){let o=r([{type:"uint256"},{type:"bytes32[]"}],[BigInt(t),a]),i=e([s,o]);return{handlerTypeDenominator:n(u.purchase),interactionData:i}},unsafeCompletedPurchase({purchaseId:r}){let a=e([d,t(r,{size:32})]);return{handlerTypeDenominator:n(u.purchase),interactionData:a}}},y={open:()=>({handlerTypeDenominator:n(u.webshop),interactionData:i})},D={customerMeeting({agencyId:r}){let a=e([h,t(r,{size:32})]);return{handlerTypeDenominator:n(u.retail),interactionData:a}}};export{m as PressInteractionEncoder,f as PurchaseInteractionEncoder,b as ReferralInteractionEncoder,D as RetailInteractionEncoder,y as WebShopInteractionEncoder};