@frak-labs/core-sdk 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,140 @@
1
+ import { Hex, Address } from 'viem';
2
+ import { P as PreparedInteraction } from '../interaction-CTQ5-kqe.cjs';
3
+
4
+ /**
5
+ * Press interactions allow you to track user engagement with articles or other press content on your platform.
6
+ * After setting up these interactions, you can create acquisition campaign based on the user engagement with your press content.
7
+ *
8
+ * :::info
9
+ * To properly handle press interactions, ensure that the "Press" product type is enabled in your Business dashboard.
10
+ * :::
11
+ *
12
+ * @description Encode press related user interactions
13
+ *
14
+ * @group Interactions Encoder
15
+ *
16
+ * @see {@link PreparedInteraction} The prepared interaction object that can be sent
17
+ * @see {@link !actions.sendInteraction | `sendInteraction()`} Action used to send the prepared interaction to the Frak Wallet
18
+ */
19
+ declare const PressInteractionEncoder: {
20
+ /**
21
+ * Encode an open article interaction
22
+ * @param args
23
+ * @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
24
+ */
25
+ openArticle({ articleId }: {
26
+ articleId: Hex;
27
+ }): PreparedInteraction;
28
+ /**
29
+ * Encode a read article interaction
30
+ * @param args
31
+ * @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
32
+ */
33
+ readArticle({ articleId }: {
34
+ articleId: Hex;
35
+ }): PreparedInteraction;
36
+ };
37
+
38
+ /**
39
+ * Referral interactions allow you to track user sharing activities.
40
+ * These interactions are essential for platforms looking to grow their user base through user-to-user referrals and reward systems.
41
+ *
42
+ * :::info
43
+ * To properly handle referral interactions, ensure that the "Referral" product type is enabled in your Business dashboard.
44
+ * :::
45
+ *
46
+ * @description Encode referral related user interactions
47
+ *
48
+ * @group Interactions Encoder
49
+ *
50
+ * @see {@link PreparedInteraction} The prepared interaction object that can be sent
51
+ * @see {@link !actions.sendInteraction | `sendInteraction()`} Action used to send the prepared interaction to the Frak Wallet
52
+ */
53
+ declare const ReferralInteractionEncoder: {
54
+ /**
55
+ * 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.
56
+ */
57
+ createLink(): PreparedInteraction;
58
+ /**
59
+ * Encode a referred interaction
60
+ * @param args
61
+ * @param args.referrer - The Ethereum address of the user who made the referral
62
+ */
63
+ referred({ referrer }: {
64
+ referrer: Address;
65
+ }): PreparedInteraction;
66
+ };
67
+
68
+ /**
69
+ * Purchase interactions allow you to track user purchases on your platform.
70
+ * After setting up these interactions, you can create acquisition campaign based on the user purchase (starting a new one, completed, or even purchase dropped).
71
+ *
72
+ * :::info
73
+ * 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.
74
+ * :::
75
+ *
76
+ * :::note
77
+ * The `purchaseId` is used on both interactions. It can be computed like this:
78
+ *
79
+ * ```ts
80
+ * const purchaseId = keccak256(concatHex([productId, toHex(externalPurchaseId)]));
81
+ * ```
82
+ *
83
+ * With:
84
+ * - `productId`: The id of your product, you can find it in the product dashboard.
85
+ * - `externalPurchaseId`: The id of the purchase in your system (e.g. the shopify `order_id`).
86
+ * :::
87
+ *
88
+ * @description Encode purchase related user interactions
89
+ *
90
+ * @group Interactions Encoder
91
+ *
92
+ * @see {@link !actions.sendInteraction | `sendInteraction()`} Action used to send the prepared interaction to the Frak Wallet
93
+ * @see {@link PreparedInteraction} The prepared interaction object that can be sent
94
+ * @see {@link !actions.trackPurchaseStatus | `trackPurchaseStatus()`} Action that will automatically send the purchase upon completion
95
+ * @see [Purchase Webhooks](/wallet-sdk/references-api/webhook) Webhooks to be implemented on your side to confirm a purchase
96
+ * @see [Purchase Proof](/wallet-sdk/references-api/purchaseProof) Get a merklee proof for the purchase
97
+ */
98
+ declare const PurchaseInteractionEncoder: {
99
+ /**
100
+ * Encode a start purchase interaction
101
+ * @param args
102
+ * @param args.purchaseId - The id of the purchase that is being started.
103
+ */
104
+ startPurchase({ purchaseId }: {
105
+ purchaseId: Hex;
106
+ }): PreparedInteraction;
107
+ /**
108
+ * Encode a complete purchase interaction
109
+ * @param args
110
+ * @param args.purchaseId - The id of the purchase that is being completed.
111
+ * @param args.proof - The merkle proof that the user has completed the purchase (see [Purchase Webhooks](/wallet-sdk/references-api/webhook) for more details).
112
+ */
113
+ completedPurchase({ purchaseId, proof, }: {
114
+ purchaseId: Hex;
115
+ proof: Hex[];
116
+ }): PreparedInteraction;
117
+ };
118
+
119
+ /**
120
+ * Webshop interactions allow you to track user activities on your webshop.
121
+ *
122
+ * :::info
123
+ * To properly handle webshop interactions, ensure that the "WebShop" product type is enabled in your Business dashboard.
124
+ * :::
125
+ *
126
+ * @description Encode webshop related user interactions
127
+ *
128
+ * @group Interactions Encoder
129
+ *
130
+ * @see {@link PreparedInteraction} The prepared interaction object that can be sent
131
+ * @see {@link !actions.sendInteraction | `sendInteraction()`} Action used to send the prepared interaction to the Frak Wallet
132
+ */
133
+ declare const WebShopInteractionEncoder: {
134
+ /**
135
+ * Encode an open webshop interaction
136
+ */
137
+ open(): PreparedInteraction;
138
+ };
139
+
140
+ export { PressInteractionEncoder, PurchaseInteractionEncoder, ReferralInteractionEncoder, WebShopInteractionEncoder };
@@ -0,0 +1,140 @@
1
+ import { Hex, Address } from 'viem';
2
+ import { P as PreparedInteraction } from '../interaction-CTQ5-kqe.js';
3
+
4
+ /**
5
+ * Press interactions allow you to track user engagement with articles or other press content on your platform.
6
+ * After setting up these interactions, you can create acquisition campaign based on the user engagement with your press content.
7
+ *
8
+ * :::info
9
+ * To properly handle press interactions, ensure that the "Press" product type is enabled in your Business dashboard.
10
+ * :::
11
+ *
12
+ * @description Encode press related user interactions
13
+ *
14
+ * @group Interactions Encoder
15
+ *
16
+ * @see {@link PreparedInteraction} The prepared interaction object that can be sent
17
+ * @see {@link !actions.sendInteraction | `sendInteraction()`} Action used to send the prepared interaction to the Frak Wallet
18
+ */
19
+ declare const PressInteractionEncoder: {
20
+ /**
21
+ * Encode an open article interaction
22
+ * @param args
23
+ * @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
24
+ */
25
+ openArticle({ articleId }: {
26
+ articleId: Hex;
27
+ }): PreparedInteraction;
28
+ /**
29
+ * Encode a read article interaction
30
+ * @param args
31
+ * @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
32
+ */
33
+ readArticle({ articleId }: {
34
+ articleId: Hex;
35
+ }): PreparedInteraction;
36
+ };
37
+
38
+ /**
39
+ * Referral interactions allow you to track user sharing activities.
40
+ * These interactions are essential for platforms looking to grow their user base through user-to-user referrals and reward systems.
41
+ *
42
+ * :::info
43
+ * To properly handle referral interactions, ensure that the "Referral" product type is enabled in your Business dashboard.
44
+ * :::
45
+ *
46
+ * @description Encode referral related user interactions
47
+ *
48
+ * @group Interactions Encoder
49
+ *
50
+ * @see {@link PreparedInteraction} The prepared interaction object that can be sent
51
+ * @see {@link !actions.sendInteraction | `sendInteraction()`} Action used to send the prepared interaction to the Frak Wallet
52
+ */
53
+ declare const ReferralInteractionEncoder: {
54
+ /**
55
+ * 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.
56
+ */
57
+ createLink(): PreparedInteraction;
58
+ /**
59
+ * Encode a referred interaction
60
+ * @param args
61
+ * @param args.referrer - The Ethereum address of the user who made the referral
62
+ */
63
+ referred({ referrer }: {
64
+ referrer: Address;
65
+ }): PreparedInteraction;
66
+ };
67
+
68
+ /**
69
+ * Purchase interactions allow you to track user purchases on your platform.
70
+ * After setting up these interactions, you can create acquisition campaign based on the user purchase (starting a new one, completed, or even purchase dropped).
71
+ *
72
+ * :::info
73
+ * 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.
74
+ * :::
75
+ *
76
+ * :::note
77
+ * The `purchaseId` is used on both interactions. It can be computed like this:
78
+ *
79
+ * ```ts
80
+ * const purchaseId = keccak256(concatHex([productId, toHex(externalPurchaseId)]));
81
+ * ```
82
+ *
83
+ * With:
84
+ * - `productId`: The id of your product, you can find it in the product dashboard.
85
+ * - `externalPurchaseId`: The id of the purchase in your system (e.g. the shopify `order_id`).
86
+ * :::
87
+ *
88
+ * @description Encode purchase related user interactions
89
+ *
90
+ * @group Interactions Encoder
91
+ *
92
+ * @see {@link !actions.sendInteraction | `sendInteraction()`} Action used to send the prepared interaction to the Frak Wallet
93
+ * @see {@link PreparedInteraction} The prepared interaction object that can be sent
94
+ * @see {@link !actions.trackPurchaseStatus | `trackPurchaseStatus()`} Action that will automatically send the purchase upon completion
95
+ * @see [Purchase Webhooks](/wallet-sdk/references-api/webhook) Webhooks to be implemented on your side to confirm a purchase
96
+ * @see [Purchase Proof](/wallet-sdk/references-api/purchaseProof) Get a merklee proof for the purchase
97
+ */
98
+ declare const PurchaseInteractionEncoder: {
99
+ /**
100
+ * Encode a start purchase interaction
101
+ * @param args
102
+ * @param args.purchaseId - The id of the purchase that is being started.
103
+ */
104
+ startPurchase({ purchaseId }: {
105
+ purchaseId: Hex;
106
+ }): PreparedInteraction;
107
+ /**
108
+ * Encode a complete purchase interaction
109
+ * @param args
110
+ * @param args.purchaseId - The id of the purchase that is being completed.
111
+ * @param args.proof - The merkle proof that the user has completed the purchase (see [Purchase Webhooks](/wallet-sdk/references-api/webhook) for more details).
112
+ */
113
+ completedPurchase({ purchaseId, proof, }: {
114
+ purchaseId: Hex;
115
+ proof: Hex[];
116
+ }): PreparedInteraction;
117
+ };
118
+
119
+ /**
120
+ * Webshop interactions allow you to track user activities on your webshop.
121
+ *
122
+ * :::info
123
+ * To properly handle webshop interactions, ensure that the "WebShop" product type is enabled in your Business dashboard.
124
+ * :::
125
+ *
126
+ * @description Encode webshop related user interactions
127
+ *
128
+ * @group Interactions Encoder
129
+ *
130
+ * @see {@link PreparedInteraction} The prepared interaction object that can be sent
131
+ * @see {@link !actions.sendInteraction | `sendInteraction()`} Action used to send the prepared interaction to the Frak Wallet
132
+ */
133
+ declare const WebShopInteractionEncoder: {
134
+ /**
135
+ * Encode an open webshop interaction
136
+ */
137
+ open(): PreparedInteraction;
138
+ };
139
+
140
+ export { PressInteractionEncoder, PurchaseInteractionEncoder, ReferralInteractionEncoder, WebShopInteractionEncoder };
@@ -0,0 +1,13 @@
1
+ import {
2
+ PressInteractionEncoder,
3
+ PurchaseInteractionEncoder,
4
+ ReferralInteractionEncoder,
5
+ WebShopInteractionEncoder
6
+ } from "../chunk-VAINYZSV.js";
7
+ import "../chunk-QZL2KCSB.js";
8
+ export {
9
+ PressInteractionEncoder,
10
+ PurchaseInteractionEncoder,
11
+ ReferralInteractionEncoder,
12
+ WebShopInteractionEncoder
13
+ };
package/package.json ADDED
@@ -0,0 +1,95 @@
1
+ {
2
+ "name": "@frak-labs/core-sdk",
3
+ "author": "Frak Labs",
4
+ "maintainers": [
5
+ {
6
+ "name": "srod",
7
+ "url": "https://twitter.com/srod"
8
+ },
9
+ {
10
+ "name": "Quentin Nivelais",
11
+ "url": "https://twitter.com/QNivelais"
12
+ }
13
+ ],
14
+ "version": "0.0.2",
15
+ "description": "Core SDK of the Frak wallet, low level library to interact directly with the frak ecosystem.",
16
+ "repository": {
17
+ "url": "https://github.com/frak-id/wallet",
18
+ "directory": "sdk/core"
19
+ },
20
+ "homepage": "https://docs.frak.id/wallet-sdk/overview",
21
+ "keywords": [
22
+ "frak-labs",
23
+ "frak-wallet",
24
+ "erc-4337",
25
+ "eip-4337",
26
+ "smart-wallet"
27
+ ],
28
+ "license": "GNU GPL 3.0",
29
+ "sideEffects": false,
30
+ "private": false,
31
+ "publishConfig": {
32
+ "access": "public"
33
+ },
34
+ "type": "module",
35
+ "files": [
36
+ "/dist",
37
+ "/cdn"
38
+ ],
39
+ "browser": "./cdn/bundle.js",
40
+ "exports": {
41
+ ".": {
42
+ "import": {
43
+ "types": "./dist/index.d.ts",
44
+ "default": "./dist/index.js"
45
+ },
46
+ "require": {
47
+ "types": "./dist/index.d.cts",
48
+ "default": "./dist/index.cjs"
49
+ }
50
+ },
51
+ "./actions": {
52
+ "import": {
53
+ "types": "./dist/actions/index.d.ts",
54
+ "default": "./dist/actions/index.js"
55
+ },
56
+ "require": {
57
+ "types": "./dist/actions/index.d.cts",
58
+ "default": "./dist/actions/index.cjs"
59
+ }
60
+ },
61
+ "./interactions": {
62
+ "import": {
63
+ "types": "./dist/interactions/index.d.ts",
64
+ "default": "./dist/interactions/index.js"
65
+ },
66
+ "require": {
67
+ "types": "./dist/interactions/index.d.cts",
68
+ "default": "./dist/interactions/index.cjs"
69
+ }
70
+ }
71
+ },
72
+ "scripts": {
73
+ "lint": "biome lint .",
74
+ "format:check": "biome check .",
75
+ "format": "biome check --write .",
76
+ "clean": "rimraf dist",
77
+ "build": "tsup && bun run check-exports",
78
+ "build:watch": "tsup --watch",
79
+ "check-exports": "attw --pack --profile node16 .",
80
+ "typecheck": "tsc --noEmit"
81
+ },
82
+ "peerDependencies": {
83
+ "viem": "^2.x"
84
+ },
85
+ "dependencies": {
86
+ "async-lz-string": "^1.1.0",
87
+ "js-sha256": "^0.11.0"
88
+ },
89
+ "devDependencies": {
90
+ "@arethetypeswrong/cli": "^0.17.1",
91
+ "@types/node": "^22",
92
+ "tsup": "^8.3.5",
93
+ "typescript": "^5"
94
+ }
95
+ }