@frak-labs/core-sdk 0.0.6 → 0.0.8

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.
@@ -1,155 +0,0 @@
1
- 'use strict';
2
-
3
- var chunk665P7NO4_cjs = require('./chunk-665P7NO4.cjs');
4
- var viem = require('viem');
5
-
6
- var PressInteractionEncoder = {
7
- /**
8
- * Encode an open article interaction
9
- * @param args
10
- * @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
11
- */
12
- openArticle({ articleId }) {
13
- const interactionData = viem.concatHex([
14
- chunk665P7NO4_cjs.interactionTypes.press.openArticle,
15
- viem.pad(articleId, { size: 32 })
16
- ]);
17
- return {
18
- handlerTypeDenominator: viem.toHex(chunk665P7NO4_cjs.productTypes.press),
19
- interactionData
20
- };
21
- },
22
- /**
23
- * Encode a read article interaction
24
- * @param args
25
- * @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
26
- */
27
- readArticle({ articleId }) {
28
- const interactionData = viem.concatHex([
29
- chunk665P7NO4_cjs.interactionTypes.press.readArticle,
30
- viem.pad(articleId, { size: 32 })
31
- ]);
32
- return {
33
- handlerTypeDenominator: viem.toHex(chunk665P7NO4_cjs.productTypes.press),
34
- interactionData
35
- };
36
- }
37
- };
38
- var ReferralInteractionEncoder = {
39
- /**
40
- * 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.
41
- */
42
- createLink() {
43
- return {
44
- handlerTypeDenominator: viem.toHex(chunk665P7NO4_cjs.productTypes.referral),
45
- interactionData: chunk665P7NO4_cjs.interactionTypes.referral.createLink
46
- };
47
- },
48
- /**
49
- * Encode a referred interaction
50
- * @param args
51
- * @param args.referrer - The Ethereum address of the user who made the referral
52
- */
53
- referred({ referrer }) {
54
- const interactionData = viem.concatHex([
55
- chunk665P7NO4_cjs.interactionTypes.referral.referred,
56
- viem.pad(referrer, { size: 32 })
57
- ]);
58
- return {
59
- handlerTypeDenominator: viem.toHex(chunk665P7NO4_cjs.productTypes.referral),
60
- interactionData
61
- };
62
- }
63
- };
64
- var PurchaseInteractionEncoder = {
65
- /**
66
- * Encode a start purchase interaction
67
- * @param args
68
- * @param args.purchaseId - The id of the purchase that is being started.
69
- */
70
- startPurchase({ purchaseId }) {
71
- const interactionData = viem.concatHex([
72
- chunk665P7NO4_cjs.interactionTypes.purchase.started,
73
- viem.pad(purchaseId, { size: 32 })
74
- ]);
75
- return {
76
- handlerTypeDenominator: viem.toHex(chunk665P7NO4_cjs.productTypes.purchase),
77
- interactionData
78
- };
79
- },
80
- /**
81
- * Encode a complete purchase interaction
82
- * @param args
83
- * @param args.purchaseId - The id of the purchase that is being completed.
84
- * @param args.proof - The merkle proof that the user has completed the purchase (see [Purchase Webhooks](/wallet-sdk/references-api/webhook) for more details).
85
- */
86
- completedPurchase({
87
- purchaseId,
88
- proof
89
- }) {
90
- const innerData = viem.encodeAbiParameters(
91
- [{ type: "uint256" }, { type: "bytes32[]" }],
92
- [BigInt(purchaseId), proof]
93
- );
94
- const interactionData = viem.concatHex([
95
- chunk665P7NO4_cjs.interactionTypes.purchase.completed,
96
- innerData
97
- ]);
98
- return {
99
- handlerTypeDenominator: viem.toHex(chunk665P7NO4_cjs.productTypes.purchase),
100
- interactionData
101
- };
102
- },
103
- /**
104
- * Encode an unsafe complete purchase interaction (when we can't provide the proof)
105
- * @param args
106
- * @param args.purchaseId - The id of the purchase that is being completed.
107
- */
108
- unsafeCompletedPurchase({
109
- purchaseId
110
- }) {
111
- const interactionData = viem.concatHex([
112
- chunk665P7NO4_cjs.interactionTypes.purchase.unsafeCompleted,
113
- viem.pad(purchaseId, { size: 32 })
114
- ]);
115
- return {
116
- handlerTypeDenominator: viem.toHex(chunk665P7NO4_cjs.productTypes.purchase),
117
- interactionData
118
- };
119
- }
120
- };
121
- var WebShopInteractionEncoder = {
122
- /**
123
- * Encode an open webshop interaction
124
- */
125
- open() {
126
- return {
127
- handlerTypeDenominator: viem.toHex(chunk665P7NO4_cjs.productTypes.webshop),
128
- interactionData: chunk665P7NO4_cjs.interactionTypes.webshop.open
129
- };
130
- }
131
- };
132
- var RetailInteractionEncoder = {
133
- /**
134
- * Encode a customer meeting retail interaction
135
- * @param args
136
- * @param args.agencyId - The id of the agency that the customer is meeting with
137
- *
138
- */
139
- customerMeeting({ agencyId }) {
140
- const interactionData = viem.concatHex([
141
- chunk665P7NO4_cjs.interactionTypes.retail.customerMeeting,
142
- viem.pad(agencyId, { size: 32 })
143
- ]);
144
- return {
145
- handlerTypeDenominator: viem.toHex(chunk665P7NO4_cjs.productTypes.retail),
146
- interactionData
147
- };
148
- }
149
- };
150
-
151
- exports.PressInteractionEncoder = PressInteractionEncoder;
152
- exports.PurchaseInteractionEncoder = PurchaseInteractionEncoder;
153
- exports.ReferralInteractionEncoder = ReferralInteractionEncoder;
154
- exports.RetailInteractionEncoder = RetailInteractionEncoder;
155
- exports.WebShopInteractionEncoder = WebShopInteractionEncoder;
@@ -1,75 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __commonJS = (cb, mod) => function __require() {
8
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
19
- // If the importer is in node compatibility mode or this is not an ESM
20
- // file that has been converted to a CommonJS file using a Babel-
21
- // compatible transform (i.e. "__esModule" has not been set), then set
22
- // "default" to the CommonJS "module.exports" for node compatibility.
23
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
24
- mod
25
- ));
26
-
27
- // src/constants/productTypes.ts
28
- var productTypes = {
29
- // content type
30
- dapp: 1,
31
- press: 2,
32
- webshop: 3,
33
- retail: 4,
34
- // feature type
35
- referral: 30,
36
- purchase: 31
37
- };
38
- var productTypesMask = Object.entries(
39
- productTypes
40
- ).reduce(
41
- (acc, [key, value]) => {
42
- acc[key] = BigInt(1) << BigInt(value);
43
- return acc;
44
- },
45
- {}
46
- );
47
-
48
- // src/constants/interactionTypes.ts
49
- var interactionTypes = {
50
- press: {
51
- openArticle: "0xc0a24ffb",
52
- readArticle: "0xd5bd0fbe"
53
- },
54
- dapp: {
55
- proofVerifiableStorageUpdate: "0x2ab2aeef",
56
- callableVerifiableStorageUpdate: "0xa07da986"
57
- },
58
- webshop: {
59
- open: "0xb311798f"
60
- },
61
- referral: {
62
- referred: "0x010cc3b9",
63
- createLink: "0xb2c0f17c"
64
- },
65
- purchase: {
66
- started: "0xd87e90c3",
67
- completed: "0x8403aeb4",
68
- unsafeCompleted: "0x4d5b14e0"
69
- },
70
- retail: {
71
- customerMeeting: "0x74489004"
72
- }
73
- };
74
-
75
- export { __commonJS, __toESM, interactionTypes, productTypes, productTypesMask };
@@ -1,149 +0,0 @@
1
- import { interactionTypes, productTypes } from './chunk-U2NTN5QZ.js';
2
- import { concatHex, pad, toHex, encodeAbiParameters } from 'viem';
3
-
4
- var PressInteractionEncoder = {
5
- /**
6
- * Encode an open article interaction
7
- * @param args
8
- * @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
9
- */
10
- openArticle({ articleId }) {
11
- const interactionData = concatHex([
12
- interactionTypes.press.openArticle,
13
- pad(articleId, { size: 32 })
14
- ]);
15
- return {
16
- handlerTypeDenominator: toHex(productTypes.press),
17
- interactionData
18
- };
19
- },
20
- /**
21
- * Encode a read 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
- readArticle({ articleId }) {
26
- const interactionData = concatHex([
27
- interactionTypes.press.readArticle,
28
- pad(articleId, { size: 32 })
29
- ]);
30
- return {
31
- handlerTypeDenominator: toHex(productTypes.press),
32
- interactionData
33
- };
34
- }
35
- };
36
- var ReferralInteractionEncoder = {
37
- /**
38
- * 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.
39
- */
40
- createLink() {
41
- return {
42
- handlerTypeDenominator: toHex(productTypes.referral),
43
- interactionData: interactionTypes.referral.createLink
44
- };
45
- },
46
- /**
47
- * Encode a referred interaction
48
- * @param args
49
- * @param args.referrer - The Ethereum address of the user who made the referral
50
- */
51
- referred({ referrer }) {
52
- const interactionData = concatHex([
53
- interactionTypes.referral.referred,
54
- pad(referrer, { size: 32 })
55
- ]);
56
- return {
57
- handlerTypeDenominator: toHex(productTypes.referral),
58
- interactionData
59
- };
60
- }
61
- };
62
- var PurchaseInteractionEncoder = {
63
- /**
64
- * Encode a start purchase interaction
65
- * @param args
66
- * @param args.purchaseId - The id of the purchase that is being started.
67
- */
68
- startPurchase({ purchaseId }) {
69
- const interactionData = concatHex([
70
- interactionTypes.purchase.started,
71
- pad(purchaseId, { size: 32 })
72
- ]);
73
- return {
74
- handlerTypeDenominator: toHex(productTypes.purchase),
75
- interactionData
76
- };
77
- },
78
- /**
79
- * Encode a complete purchase interaction
80
- * @param args
81
- * @param args.purchaseId - The id of the purchase that is being completed.
82
- * @param args.proof - The merkle proof that the user has completed the purchase (see [Purchase Webhooks](/wallet-sdk/references-api/webhook) for more details).
83
- */
84
- completedPurchase({
85
- purchaseId,
86
- proof
87
- }) {
88
- const innerData = encodeAbiParameters(
89
- [{ type: "uint256" }, { type: "bytes32[]" }],
90
- [BigInt(purchaseId), proof]
91
- );
92
- const interactionData = concatHex([
93
- interactionTypes.purchase.completed,
94
- innerData
95
- ]);
96
- return {
97
- handlerTypeDenominator: toHex(productTypes.purchase),
98
- interactionData
99
- };
100
- },
101
- /**
102
- * Encode an unsafe complete purchase interaction (when we can't provide the proof)
103
- * @param args
104
- * @param args.purchaseId - The id of the purchase that is being completed.
105
- */
106
- unsafeCompletedPurchase({
107
- purchaseId
108
- }) {
109
- const interactionData = concatHex([
110
- interactionTypes.purchase.unsafeCompleted,
111
- pad(purchaseId, { size: 32 })
112
- ]);
113
- return {
114
- handlerTypeDenominator: toHex(productTypes.purchase),
115
- interactionData
116
- };
117
- }
118
- };
119
- var WebShopInteractionEncoder = {
120
- /**
121
- * Encode an open webshop interaction
122
- */
123
- open() {
124
- return {
125
- handlerTypeDenominator: toHex(productTypes.webshop),
126
- interactionData: interactionTypes.webshop.open
127
- };
128
- }
129
- };
130
- var RetailInteractionEncoder = {
131
- /**
132
- * Encode a customer meeting retail interaction
133
- * @param args
134
- * @param args.agencyId - The id of the agency that the customer is meeting with
135
- *
136
- */
137
- customerMeeting({ agencyId }) {
138
- const interactionData = concatHex([
139
- interactionTypes.retail.customerMeeting,
140
- pad(agencyId, { size: 32 })
141
- ]);
142
- return {
143
- handlerTypeDenominator: toHex(productTypes.retail),
144
- interactionData
145
- };
146
- }
147
- };
148
-
149
- export { PressInteractionEncoder, PurchaseInteractionEncoder, ReferralInteractionEncoder, RetailInteractionEncoder, WebShopInteractionEncoder };