@cashie/core-lib 1.2.0 → 1.3.0

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,11 +1,11 @@
1
1
  import { Address, Hex } from 'viem';
2
- import { CashieReceiptBadgeMetadata, CashiePaymentRecordBadgeMetadata } from '../../data/types.js';
2
+ import { CashieReceiptBadgeMetadata, CashiePaymentRecordBadgeMetadata, CashieMembershipBadgeMetadata } from '../../data/types.js';
3
3
  export type BadgeOwner = {
4
4
  nftAddress: Address;
5
5
  nftTokenId: Hex;
6
6
  };
7
- export type BadgeKind = 'receipt' | 'paymentRecord';
8
- export type BadgeMetadata = CashieReceiptBadgeMetadata | CashiePaymentRecordBadgeMetadata;
7
+ export type BadgeKind = 'receipt' | 'paymentRecord' | 'membership';
8
+ export type BadgeMetadata = CashieReceiptBadgeMetadata | CashiePaymentRecordBadgeMetadata | CashieMembershipBadgeMetadata;
9
9
  export type BadgeChainParams = {
10
10
  chainHex: Hex;
11
11
  badgeKind: BadgeKind;
@@ -1,9 +1,12 @@
1
1
  import { Hex, Hash, Address } from 'viem';
2
- import { BadgeKind, PaymentIntent } from '../../index.js';
3
- export type SendPaymentIntentTaskEntry = {
2
+ import type { BadgeKind } from '../contracts/badge.types.js';
3
+ import { PaymentIntentActions, type Intent, type IntentActions } from '../../intent/types.js';
4
+ export type TaskEntry<TIntentAction extends IntentActions> = {
5
+ action: TIntentAction;
4
6
  id: string;
5
- data: {
6
- paymentIntent: PaymentIntent;
7
+ data: Intent<TIntentAction>;
8
+ droppedDetails?: {
9
+ reason: string;
7
10
  };
8
11
  };
9
12
  /**
@@ -12,30 +15,47 @@ export type SendPaymentIntentTaskEntry = {
12
15
  export type TransactionEntry = {
13
16
  txHash: Hash;
14
17
  chainId: Hex;
15
- taskEntries: SendPaymentIntentTaskEntry[];
18
+ taskEntries: TaskEntry<IntentActions>[];
16
19
  };
17
20
  /**
18
21
  * A payment intent tracking entry.
19
22
  */
20
- export type PaymentIntentTrackingEntry = {
21
- paymentIntent: PaymentIntent;
23
+ export type IntentTrackingEntry<TIntentAction extends IntentActions> = {
24
+ intent: Intent<TIntentAction>;
22
25
  status: 'pending' | 'confirmed' | 'failed';
23
26
  txHash?: Hash | null;
24
27
  blockNumber?: Hex | null;
25
28
  };
29
+ /**
30
+ * Returns true when `action` is a {@link PaymentIntentActions} value.
31
+ *
32
+ * @param action - The intent action to check
33
+ * @returns Whether the action is a payment intent action
34
+ */
35
+ export declare function isPaymentIntentAction(action: IntentActions): action is PaymentIntentActions;
36
+ /**
37
+ * Returns true when the tracking entry holds a payment intent.
38
+ *
39
+ * @param entry - The intent tracking entry to check
40
+ * @returns Whether the entry is a payment intent tracking entry
41
+ */
42
+ export declare function isPaymentIntentTrackingEntry(entry: IntentTrackingEntry<IntentActions>): entry is IntentTrackingEntry<PaymentIntentActions>;
26
43
  /**
27
44
  * Find the transaction hash for a badge id.
28
45
  *
46
+ * Only confirmed {@link PaymentIntentActions}
47
+ * entries with a transaction hash and block number are considered.
48
+ *
29
49
  * @param props - The properties of the badge.
30
50
  * @param props.badgeId - The id of the badge.
31
51
  * @param props.badgeKind - The kind of the badge.
32
52
  * @param props.identityContract - The identity contract.
33
- * @param props.paymentIntentTrackingEntries - The payment intent tracking entries.
53
+ * @param props.paymentIntentTrackingEntries - Tracking entries for any intent type.
34
54
  * @returns The transaction hash for the badge id.
35
55
  */
36
56
  export declare function findTransactionHashForBadgeId(props: {
37
57
  badgeId: Hex;
38
58
  badgeKind: BadgeKind;
39
59
  identityContract: Address;
40
- paymentIntentTrackingEntries: PaymentIntentTrackingEntry[];
60
+ paymentIntentTrackingEntries: IntentTrackingEntry<PaymentIntentActions>[];
41
61
  }): Hex | null;
@@ -1,25 +1,26 @@
1
- import { PaymentRpcParams, PaymentRpcReturn } from './types.js';
1
+ import { RpcParams, PaymentRpcReturn } from './types.js';
2
2
  export type PaymentRpcClientArgs = {
3
3
  url: string;
4
4
  chainId: number;
5
5
  };
6
6
  export interface PaymentRpcClient {
7
- getIdentitySoulDiscovery(params: PaymentRpcParams<'discovery_supportedSouls'>): Promise<PaymentRpcReturn<'discovery_supportedSouls'>>;
8
- getProtocolFeeBps(params: PaymentRpcParams<'payment_getProtocolFeeBps'>): Promise<PaymentRpcReturn<'payment_getProtocolFeeBps'>>;
9
- calculateRewardAmount(params: PaymentRpcParams<'payment_calculateRewardAmount'>): Promise<PaymentRpcReturn<'payment_calculateRewardAmount'>>;
10
- sendIntent(params: PaymentRpcParams<'payment_sendIntent'>): Promise<PaymentRpcReturn<'payment_sendIntent'>>;
11
- getIntentStatuses(params: PaymentRpcParams<'payment_getIntentStatuses'>): Promise<PaymentRpcReturn<'payment_getIntentStatuses'>>;
12
- prepareRouterCallsFromAction(params: PaymentRpcParams<'payment_prepareRouterCallsFromAction'>): Promise<PaymentRpcReturn<'payment_prepareRouterCallsFromAction'>>;
13
- getBurnAuth(params: PaymentRpcParams<'identity_getBurnAuth'>): Promise<PaymentRpcReturn<'identity_getBurnAuth'>>;
14
- getTokenURI(params: PaymentRpcParams<'identity_getTokenURI'>): Promise<PaymentRpcReturn<'identity_getTokenURI'>>;
15
- sendPrePaymentSetup(params: PaymentRpcParams<'payment_sendPrePaymentSetup'>): Promise<PaymentRpcReturn<'payment_sendPrePaymentSetup'>>;
16
- getPrePaymentSetup(params: PaymentRpcParams<'payment_getPrePaymentSetup'>): Promise<PaymentRpcReturn<'payment_getPrePaymentSetup'>>;
17
- getBadgeOwnerOf(params: PaymentRpcParams<'badge_getOwnerOf'>): Promise<PaymentRpcReturn<'badge_getOwnerOf'>>;
18
- getBadgeUri(params: PaymentRpcParams<'badge_getBadgeUri'>): Promise<PaymentRpcReturn<'badge_getBadgeUri'>>;
19
- getBadgeMetadataFormat(params: PaymentRpcParams<'badge_getMetadataFormat'>): Promise<PaymentRpcReturn<'badge_getMetadataFormat'>>;
20
- getTotalBadgesOfIdentity(params: PaymentRpcParams<'badge_totalBadgesOfIdentity'>): Promise<PaymentRpcReturn<'badge_totalBadgesOfIdentity'>>;
21
- getBadgeOfIdentityByIndex(params: PaymentRpcParams<'badge_badgeOfIdentityByIndex'>): Promise<PaymentRpcReturn<'badge_badgeOfIdentityByIndex'>>;
22
- getBadgesOfIdentity(params: PaymentRpcParams<'badge_badgesOfIdentity'>): Promise<PaymentRpcReturn<'badge_badgesOfIdentity'>>;
7
+ getIdentitySoulDiscovery(params: RpcParams<'discovery_supportedSouls'>): Promise<PaymentRpcReturn<'discovery_supportedSouls'>>;
8
+ getProtocolFeeBps(params: RpcParams<'payment_getProtocolFeeBps'>): Promise<PaymentRpcReturn<'payment_getProtocolFeeBps'>>;
9
+ calculateRewardAmount(params: RpcParams<'payment_calculateRewardAmount'>): Promise<PaymentRpcReturn<'payment_calculateRewardAmount'>>;
10
+ sendIntent(params: RpcParams<'cashie_sendIntent'>): Promise<PaymentRpcReturn<'cashie_sendIntent'>>;
11
+ getIntentStatus(params: RpcParams<'cashie_getIntentStatus'>): Promise<PaymentRpcReturn<'cashie_getIntentStatus'>>;
12
+ getIntentStatuses(params: RpcParams<'cashie_getIntentStatuses'>): Promise<PaymentRpcReturn<'cashie_getIntentStatuses'>>;
13
+ prepareRouterCallsFromAction(params: RpcParams<'payment_prepareRouterCallsFromAction'>): Promise<PaymentRpcReturn<'payment_prepareRouterCallsFromAction'>>;
14
+ getBurnAuth(params: RpcParams<'identity_getBurnAuth'>): Promise<PaymentRpcReturn<'identity_getBurnAuth'>>;
15
+ getTokenURI(params: RpcParams<'identity_getTokenURI'>): Promise<PaymentRpcReturn<'identity_getTokenURI'>>;
16
+ sendPrePaymentSetup(params: RpcParams<'payment_sendPrePaymentSetup'>): Promise<PaymentRpcReturn<'payment_sendPrePaymentSetup'>>;
17
+ getPrePaymentSetup(params: RpcParams<'payment_getPrePaymentSetup'>): Promise<PaymentRpcReturn<'payment_getPrePaymentSetup'>>;
18
+ getBadgeOwnerOf(params: RpcParams<'badge_getOwnerOf'>): Promise<PaymentRpcReturn<'badge_getOwnerOf'>>;
19
+ getBadgeUri(params: RpcParams<'badge_getBadgeUri'>): Promise<PaymentRpcReturn<'badge_getBadgeUri'>>;
20
+ getBadgeMetadataFormat(params: RpcParams<'badge_getMetadataFormat'>): Promise<PaymentRpcReturn<'badge_getMetadataFormat'>>;
21
+ getTotalBadgesOfIdentity(params: RpcParams<'badge_totalBadgesOfIdentity'>): Promise<PaymentRpcReturn<'badge_totalBadgesOfIdentity'>>;
22
+ getBadgeOfIdentityByIndex(params: RpcParams<'badge_badgeOfIdentityByIndex'>): Promise<PaymentRpcReturn<'badge_badgeOfIdentityByIndex'>>;
23
+ getBadgesOfIdentity(params: RpcParams<'badge_badgesOfIdentity'>): Promise<PaymentRpcReturn<'badge_badgesOfIdentity'>>;
23
24
  }
24
25
  /**
25
26
  * Creates a new Payment RPC client.
@@ -1,27 +1,15 @@
1
1
  import { z } from 'zod';
2
2
  import { BurnAuth } from '../identity/types.js';
3
- import type { PaymentIntentTrackingEntry } from '../backend/tx-tracking/types.js';
4
- import type { PaymentRpcMethodNames, PaymentRpcParams, PaymentRpcReturn } from './types.js';
3
+ import { type IntentActions } from '../intent/types.js';
4
+ import type { IntentTrackingEntry } from '../backend/tx-tracking/types.js';
5
+ import type { RpcMethodNames, RpcParams, PaymentRpcReturn } from './types.js';
5
6
  export declare const paymentRpcReturnSchemas: {
6
- discovery_supportedSouls: z.ZodObject<{
7
- identitySoulContract: z.ZodObject<{
8
- address: z.ZodCustom<`0x${string}`, `0x${string}`>;
9
- badgeContracts: z.ZodObject<{
10
- paymentRecordBadgeContract: z.ZodCustom<`0x${string}`, `0x${string}`>;
11
- receiptBadgeContract: z.ZodCustom<`0x${string}`, `0x${string}`>;
12
- }, z.core.$strip>;
13
- }, z.core.$strip>;
14
- }, z.core.$strip>;
15
7
  payment_getProtocolFeeBps: z.ZodCustom<`0x${string}`, `0x${string}`>;
16
8
  payment_calculateRewardAmount: z.ZodCustom<`0x${string}`, `0x${string}`>;
17
- payment_sendIntent: z.ZodCustom<`0x${string}`, `0x${string}`>;
18
- payment_getIntentStatuses: z.ZodArray<z.ZodType<PaymentIntentTrackingEntry, unknown, z.core.$ZodTypeInternals<PaymentIntentTrackingEntry, unknown>>>;
19
9
  payment_prepareRouterCallsFromAction: z.ZodArray<z.ZodObject<{
20
10
  to: z.ZodCustom<`0x${string}`, `0x${string}`>;
21
11
  data: z.ZodCustom<`0x${string}`, `0x${string}`>;
22
12
  }, z.core.$strip>>;
23
- identity_getBurnAuth: z.ZodCustom<BurnAuth, BurnAuth>;
24
- identity_getTokenURI: z.ZodNullable<z.ZodString>;
25
13
  payment_sendPrePaymentSetup: z.ZodCustom<`0x${string}`, `0x${string}`>;
26
14
  payment_getPrePaymentSetup: z.ZodNullable<z.ZodObject<{
27
15
  signedIdentityMintPayload: z.ZodType<import("../identity/types.js").IdentityMintSignPayloadWithSignature, unknown, z.core.$ZodTypeInternals<import("../identity/types.js").IdentityMintSignPayloadWithSignature, unknown>>;
@@ -30,6 +18,21 @@ export declare const paymentRpcReturnSchemas: {
30
18
  factoryData: z.ZodCustom<`0x${string}`, `0x${string}`>;
31
19
  }, z.core.$strict>;
32
20
  }, z.core.$strict>>;
21
+ cashie_sendIntent: z.ZodCustom<`0x${string}`, `0x${string}`>;
22
+ cashie_getIntentStatus: z.ZodNullable<z.ZodType<IntentTrackingEntry<IntentActions>, unknown, z.core.$ZodTypeInternals<IntentTrackingEntry<IntentActions>, unknown>>>;
23
+ cashie_getIntentStatuses: z.ZodArray<z.ZodType<IntentTrackingEntry<IntentActions>, unknown, z.core.$ZodTypeInternals<IntentTrackingEntry<IntentActions>, unknown>>>;
24
+ discovery_supportedSouls: z.ZodObject<{
25
+ identitySoulContract: z.ZodObject<{
26
+ address: z.ZodCustom<`0x${string}`, `0x${string}`>;
27
+ badgeContracts: z.ZodObject<{
28
+ paymentRecordBadgeContract: z.ZodCustom<`0x${string}`, `0x${string}`>;
29
+ receiptBadgeContract: z.ZodCustom<`0x${string}`, `0x${string}`>;
30
+ membershipBadgeContract: z.ZodCustom<`0x${string}`, `0x${string}`>;
31
+ }, z.core.$strip>;
32
+ }, z.core.$strip>;
33
+ }, z.core.$strip>;
34
+ identity_getBurnAuth: z.ZodCustom<BurnAuth, BurnAuth>;
35
+ identity_getTokenURI: z.ZodNullable<z.ZodString>;
33
36
  badge_getOwnerOf: z.ZodObject<{
34
37
  nftAddress: z.ZodCustom<`0x${string}`, `0x${string}`>;
35
38
  nftTokenId: z.ZodCustom<`0x${string}`, `0x${string}`>;
@@ -40,7 +43,7 @@ export declare const paymentRpcReturnSchemas: {
40
43
  badge_badgeOfIdentityByIndex: z.ZodCustom<`0x${string}`, `0x${string}`>;
41
44
  badge_badgesOfIdentity: z.ZodArray<z.ZodCustom<`0x${string}`, `0x${string}`>>;
42
45
  };
43
- export type BadgeRpcMethodNames = Extract<PaymentRpcMethodNames, `badge_${string}`>;
46
+ export type BadgeRpcMethodNames = Extract<RpcMethodNames, `badge_${string}`>;
44
47
  export declare const badgeRpcParamSchemas: {
45
48
  badge_getOwnerOf: z.ZodTuple<[z.ZodObject<{
46
49
  chainHex: z.ZodCustom<`0x${string}`, `0x${string}`>;
@@ -48,6 +51,7 @@ export declare const badgeRpcParamSchemas: {
48
51
  badgeKind: z.ZodEnum<{
49
52
  receipt: "receipt";
50
53
  paymentRecord: "paymentRecord";
54
+ membership: "membership";
51
55
  }>;
52
56
  }, z.core.$strip>], null>;
53
57
  badge_getBadgeUri: z.ZodTuple<[z.ZodObject<{
@@ -56,6 +60,7 @@ export declare const badgeRpcParamSchemas: {
56
60
  badgeKind: z.ZodEnum<{
57
61
  receipt: "receipt";
58
62
  paymentRecord: "paymentRecord";
63
+ membership: "membership";
59
64
  }>;
60
65
  }, z.core.$strip>], null>;
61
66
  badge_getMetadataFormat: z.ZodTuple<[z.ZodObject<{
@@ -63,6 +68,7 @@ export declare const badgeRpcParamSchemas: {
63
68
  badgeKind: z.ZodEnum<{
64
69
  receipt: "receipt";
65
70
  paymentRecord: "paymentRecord";
71
+ membership: "membership";
66
72
  }>;
67
73
  }, z.core.$strip>], null>;
68
74
  badge_totalBadgesOfIdentity: z.ZodTuple<[z.ZodObject<{
@@ -71,6 +77,7 @@ export declare const badgeRpcParamSchemas: {
71
77
  badgeKind: z.ZodEnum<{
72
78
  receipt: "receipt";
73
79
  paymentRecord: "paymentRecord";
80
+ membership: "membership";
74
81
  }>;
75
82
  }, z.core.$strip>], null>;
76
83
  badge_badgeOfIdentityByIndex: z.ZodTuple<[z.ZodObject<{
@@ -79,6 +86,7 @@ export declare const badgeRpcParamSchemas: {
79
86
  badgeKind: z.ZodEnum<{
80
87
  receipt: "receipt";
81
88
  paymentRecord: "paymentRecord";
89
+ membership: "membership";
82
90
  }>;
83
91
  index: z.ZodCustom<`0x${string}`, `0x${string}`>;
84
92
  }, z.core.$strip>], null>;
@@ -88,6 +96,7 @@ export declare const badgeRpcParamSchemas: {
88
96
  badgeKind: z.ZodEnum<{
89
97
  receipt: "receipt";
90
98
  paymentRecord: "paymentRecord";
99
+ membership: "membership";
91
100
  }>;
92
101
  offset: z.ZodCustom<`0x${string}`, `0x${string}`>;
93
102
  limit: z.ZodCustom<`0x${string}`, `0x${string}`>;
@@ -99,9 +108,9 @@ export declare class PaymentRpcParamsValidationError extends Error {
99
108
  constructor(method: BadgeRpcMethodNames, zodError: z.ZodError);
100
109
  }
101
110
  export declare class PaymentRpcResponseValidationError extends Error {
102
- readonly method: PaymentRpcMethodNames;
111
+ readonly method: RpcMethodNames;
103
112
  readonly zodError: z.ZodError;
104
- constructor(method: PaymentRpcMethodNames, zodError: z.ZodError);
113
+ constructor(method: RpcMethodNames, zodError: z.ZodError);
105
114
  }
106
115
  /**
107
116
  * Parses the result from the RPC call to the corresponding Zod schema.
@@ -110,7 +119,7 @@ export declare class PaymentRpcResponseValidationError extends Error {
110
119
  * @param result - The result from the RPC call
111
120
  * @returns The parsed result according to the Zod schema
112
121
  */
113
- export declare function parsePaymentRpcReturn<T extends PaymentRpcMethodNames>(method: T, result: unknown): PaymentRpcReturn<T>;
122
+ export declare function parsePaymentRpcReturn<T extends RpcMethodNames>(method: T, result: unknown): PaymentRpcReturn<T>;
114
123
  /**
115
124
  * Parses badge RPC params against the corresponding Zod schema.
116
125
  *
@@ -118,4 +127,4 @@ export declare function parsePaymentRpcReturn<T extends PaymentRpcMethodNames>(m
118
127
  * @param params - The params from the RPC call
119
128
  * @returns The parsed params according to the Zod schema
120
129
  */
121
- export declare function parsePaymentRpcParams<T extends BadgeRpcMethodNames>(method: T, params: unknown): PaymentRpcParams<T>;
130
+ export declare function parsePaymentRpcParams<T extends BadgeRpcMethodNames>(method: T, params: unknown): RpcParams<T>;
@@ -1,16 +1,16 @@
1
1
  import { Address, Hex } from 'viem';
2
- import { CashieRouterActions, PaymentIntent, RewardIntentDetails } from '../intent/types.js';
2
+ import { Intent, IntentActions, PaymentIntentActions, RewardData } from '../intent/types.js';
3
3
  import { BurnAuth, IdentityMintSignPayloadWithSignature, IdentitySoulDiscovery } from '../identity/index.js';
4
4
  import type { InitCodeData } from '../erc-7715/request/types.js';
5
- import type { PaymentIntentTrackingEntry } from '../backend/tx-tracking/types.js';
5
+ import type { IntentTrackingEntry } from '../backend/tx-tracking/types.js';
6
6
  import type { BadgeKind } from '../backend/contracts/badge.types.js';
7
7
  type PrepareRouterCallsParams = {
8
8
  recipient: Address;
9
9
  allowance: Hex;
10
10
  tokenAddress: Address;
11
11
  chainId: Hex;
12
- action: CashieRouterActions;
13
- rewardIntentDetails?: RewardIntentDetails;
12
+ action: PaymentIntentActions;
13
+ rewardData?: RewardData;
14
14
  salt: Hex;
15
15
  };
16
16
  type BadgeOwner = {
@@ -24,13 +24,7 @@ type PrePaymentSetup = {
24
24
  /**
25
25
  * The mapping of payment RPC methods to their corresponding parameters and return types.
26
26
  */
27
- interface PaymentRpcMethodMapping {
28
- discovery_supportedSouls: {
29
- params: [{
30
- chainHex: Hex;
31
- }];
32
- return: IdentitySoulDiscovery;
33
- };
27
+ interface RpcMethodMapping {
34
28
  payment_getProtocolFeeBps: {
35
29
  params: [{
36
30
  chainHex: Hex;
@@ -47,16 +41,6 @@ interface PaymentRpcMethodMapping {
47
41
  ];
48
42
  return: Hex;
49
43
  };
50
- payment_sendIntent: {
51
- params: [PaymentIntent];
52
- return: Hex;
53
- };
54
- payment_getIntentStatuses: {
55
- params: [{
56
- address: Address;
57
- }];
58
- return: PaymentIntentTrackingEntry[];
59
- };
60
44
  payment_prepareRouterCallsFromAction: {
61
45
  params: [PrepareRouterCallsParams];
62
46
  return: {
@@ -64,20 +48,6 @@ interface PaymentRpcMethodMapping {
64
48
  data: Hex;
65
49
  }[];
66
50
  };
67
- identity_getBurnAuth: {
68
- params: [{
69
- chainHex: Hex;
70
- tokenId: Hex;
71
- }];
72
- return: BurnAuth;
73
- };
74
- identity_getTokenURI: {
75
- params: [{
76
- chainHex: Hex;
77
- tokenId: Hex;
78
- }];
79
- return: string | null;
80
- };
81
51
  /**
82
52
  * Submit data required before a payment can run: smart-account init code and
83
53
  * a signed identity mint consent payload.
@@ -102,6 +72,43 @@ interface PaymentRpcMethodMapping {
102
72
  }];
103
73
  return: PrePaymentSetup | null;
104
74
  };
75
+ cashie_sendIntent: {
76
+ params: [Intent<IntentActions>];
77
+ return: Hex;
78
+ };
79
+ /**
80
+ * Get intent status given an intent hash.
81
+ */
82
+ cashie_getIntentStatus: {
83
+ params: [Hex];
84
+ return: IntentTrackingEntry<IntentActions> | null;
85
+ };
86
+ cashie_getIntentStatuses: {
87
+ params: [{
88
+ address: Address;
89
+ }];
90
+ return: IntentTrackingEntry<IntentActions>[];
91
+ };
92
+ discovery_supportedSouls: {
93
+ params: [{
94
+ chainHex: Hex;
95
+ }];
96
+ return: IdentitySoulDiscovery;
97
+ };
98
+ identity_getBurnAuth: {
99
+ params: [{
100
+ chainHex: Hex;
101
+ tokenId: Hex;
102
+ }];
103
+ return: BurnAuth;
104
+ };
105
+ identity_getTokenURI: {
106
+ params: [{
107
+ chainHex: Hex;
108
+ tokenId: Hex;
109
+ }];
110
+ return: string | null;
111
+ };
105
112
  badge_getOwnerOf: {
106
113
  params: [{
107
114
  chainHex: Hex;
@@ -160,7 +167,7 @@ interface PaymentRpcMethodMapping {
160
167
  /**
161
168
  * The method names for the payment API.
162
169
  */
163
- export type PaymentRpcMethodNames = keyof PaymentRpcMethodMapping;
164
- export type PaymentRpcParams<T extends PaymentRpcMethodNames> = PaymentRpcMethodMapping[T]['params'];
165
- export type PaymentRpcReturn<T extends PaymentRpcMethodNames> = PaymentRpcMethodMapping[T]['return'];
170
+ export type RpcMethodNames = keyof RpcMethodMapping;
171
+ export type RpcParams<T extends RpcMethodNames> = RpcMethodMapping[T]['params'];
172
+ export type PaymentRpcReturn<T extends RpcMethodNames> = RpcMethodMapping[T]['return'];
166
173
  export {};
@@ -5,10 +5,12 @@
5
5
  * Validation uses Zod schemas in `./types.js`. Parsed identity fields align with
6
6
  * **`IdentityType`** / **`BurnAuth`** from `identity/types.ts`.
7
7
  *
8
- * Pair **`parseCashieReceiptBadgeMetadataFromBadgeUri`** / **`parseCashiePaymentRecordBadgeMetadataFromBadgeUri`**
8
+ * Pair **`parseCashieReceiptBadgeMetadataFromBadgeUri`**,
9
+ * **`parseCashiePaymentRecordBadgeMetadataFromBadgeUri`**, and
10
+ * **`parseCashieMembershipBadgeMetadataFromBadgeUri`**
9
11
  * with **`IERC5114.metadataFormat()`** once the badge is minted on-chain.
10
12
  */
11
- import { type CashieIdentitySoulTokenMetadata, type CashiePaymentRecordBadgeMetadata, type CashieReceiptBadgeMetadata, type ParsedCashieMetadata } from './types.js';
13
+ import { type CashieIdentitySoulTokenMetadata, type CashieMembershipBadgeMetadata, type CashiePaymentRecordBadgeMetadata, type CashieReceiptBadgeMetadata, type ParsedCashieMetadata } from './types.js';
12
14
  /**
13
15
  * Strips {@link CASHIE_JSON_DATA_URI_BASE64_PREFIX} and returns the UTF-8 JSON string inside.
14
16
  *
@@ -69,9 +71,26 @@ export declare function parseCashiePaymentRecordBadgeMetadata(dataUri: string):
69
71
  * @returns The parsed payment record badge metadata
70
72
  */
71
73
  export declare function parseCashiePaymentRecordBadgeMetadataFromBadgeUri(badgeUri: string, metadataFormatFromContract: string): CashiePaymentRecordBadgeMetadata;
74
+ /**
75
+ * Parses `CashieMembershipBadge.badgeUri` metadata (`MembershipBadgeMetadataEncoderLib`).
76
+ *
77
+ * @param dataUri The data URI to parse
78
+ * @returns The parsed membership badge metadata
79
+ */
80
+ export declare function parseCashieMembershipBadgeMetadata(dataUri: string): CashieMembershipBadgeMetadata;
81
+ /**
82
+ * Same as {@link parseCashieMembershipBadgeMetadata}, but enforces that
83
+ * `IERC5114.metadataFormat()` matches {@link CASHIE_MEMBERSHIP_BADGE_METADATA_FORMAT}.
84
+ *
85
+ * @param badgeUri The badge URI to parse
86
+ * @param metadataFormatFromContract The metadata format from the contract
87
+ * @returns The parsed membership badge metadata
88
+ */
89
+ export declare function parseCashieMembershipBadgeMetadataFromBadgeUri(badgeUri: string, metadataFormatFromContract: string): CashieMembershipBadgeMetadata;
72
90
  /**
73
91
  * Dispatches on JSON shape: **`identityType`** ⇒ identity soul; **`receiptType`** ⇒ receipt badge;
74
- * **`receiptBadgeId`** (without **`receiptType`**) ⇒ payment record badge.
92
+ * **`receiptBadgeId`** (without **`receiptType`**) ⇒ payment record badge;
93
+ * **`isMembershipActive`** ⇒ membership badge.
75
94
  *
76
95
  * @param dataUri The data URI to parse
77
96
  * @returns The parsed metadata
@@ -1,5 +1,5 @@
1
1
  import type { Address, Hex } from 'viem';
2
- import type { PaymentIntent } from '../intent/types.js';
2
+ import type { Intent, PaymentIntentActions } from '../intent/types.js';
3
3
  /**
4
4
  * Mirrors on-chain `ReceiptType`
5
5
  */
@@ -57,7 +57,7 @@ export declare function receiptBadgeIdFromMintPayload(payload: ReceiptBadgeMintP
57
57
  * @param receiptType Receipt badge type from `ReceiptBadgeRouterMintPayload`
58
58
  * @returns Receipt badge mint tuple in router/storage shape
59
59
  */
60
- export declare function receiptBadgeMintPayloadFromPaymentIntent(identityContract: Address, paymentIntent: PaymentIntent, blockNumber: bigint, receiptType: ReceiptType): ReceiptBadgeMintPayload;
60
+ export declare function receiptBadgeMintPayloadFromPaymentIntent(identityContract: Address, paymentIntent: Intent<PaymentIntentActions>, blockNumber: bigint, receiptType: ReceiptType): ReceiptBadgeMintPayload;
61
61
  /**
62
62
  * Deterministic receipt badge id for a payment intent (matches on-chain `CashieReceiptBadge.mint`).
63
63
  *
@@ -67,7 +67,7 @@ export declare function receiptBadgeMintPayloadFromPaymentIntent(identityContrac
67
67
  * @param receiptType Receipt badge type from `ReceiptBadgeRouterMintPayload`
68
68
  * @returns Deterministic receipt badge id
69
69
  */
70
- export declare function receiptBadgeIdFromPaymentIntent(identityContract: Address, paymentIntent: PaymentIntent, blockNumber: bigint, receiptType: ReceiptType): bigint;
70
+ export declare function receiptBadgeIdFromPaymentIntent(identityContract: Address, paymentIntent: Intent<PaymentIntentActions>, blockNumber: bigint, receiptType: ReceiptType): bigint;
71
71
  /**
72
72
  * Fields ABI-encoded in the same order as `PaymentRecordBadgeEncoderLib.encodeMintPayload`
73
73
  * (`packages/contracts/src/identity/libraries/PaymentRecordBadgeEncoderLib.sol`).
@@ -117,7 +117,7 @@ export declare function paymentRecordBadgeIdFromMintPayload(payload: PaymentReco
117
117
  * @param receiptBadgeId Linked receipt badge id from the same payment
118
118
  * @returns Payment record badge mint tuple in router/storage shape
119
119
  */
120
- export declare function paymentRecordBadgeMintPayloadFromPaymentIntent(identityContract: Address, paymentIntent: PaymentIntent, blockNumber: bigint, receiptBadgeId: bigint): PaymentRecordBadgeMintPayload;
120
+ export declare function paymentRecordBadgeMintPayloadFromPaymentIntent(identityContract: Address, paymentIntent: Intent<PaymentIntentActions>, blockNumber: bigint, receiptBadgeId: bigint): PaymentRecordBadgeMintPayload;
121
121
  /**
122
122
  * Deterministic payment record badge id for a payment intent (matches on-chain `CashiePaymentRecordBadge.mint`).
123
123
  *
@@ -127,4 +127,41 @@ export declare function paymentRecordBadgeMintPayloadFromPaymentIntent(identityC
127
127
  * @param receiptType Receipt badge type from `ReceiptBadgeRouterMintPayload`
128
128
  * @returns Deterministic payment record badge id
129
129
  */
130
- export declare function paymentRecordBadgeIdFromPaymentIntent(identityContract: Address, paymentIntent: PaymentIntent, blockNumber: bigint, receiptType: ReceiptType): bigint;
130
+ export declare function paymentRecordBadgeIdFromPaymentIntent(identityContract: Address, paymentIntent: Intent<PaymentIntentActions>, blockNumber: bigint, receiptType: ReceiptType): bigint;
131
+ /**
132
+ * Fields ABI-encoded in the same order as `MembershipBadgeEncoderLib.encodeMintPayload`
133
+ * (`packages/contracts/src/identity/libraries/MembershipBadgeEncoderLib.sol`).
134
+ * `isMembershipActive` is stored on-chain and omitted from this type because it does not affect the digest.
135
+ */
136
+ export type MembershipBadgeMintPayload = {
137
+ soulBoundTo: {
138
+ identityContract: Address;
139
+ tokenId: bigint;
140
+ };
141
+ blockNumber: bigint;
142
+ chainId: bigint;
143
+ recipient: Address;
144
+ salt: Hex;
145
+ };
146
+ /**
147
+ * Canonical `abi.encode` of the stable membership mint fields (matches Solidity `MembershipBadgeEncoderLib.encodeMintPayload`).
148
+ *
149
+ * @param payload Mint tuple fields in router/storage shape
150
+ * @returns ABI-encoded bytes as hex
151
+ */
152
+ export declare function encodeMembershipBadgeMintPayload(payload: MembershipBadgeMintPayload): Hex;
153
+ /**
154
+ * `keccak256(encodeMembershipBadgeMintPayload(payload))` — matches `MembershipBadgeEncoderLib.getMintPayloadHash`.
155
+ * On-chain `badgeId == uint256(bytes32 digest)`.
156
+ *
157
+ * @param payload Mint tuple fields in router/storage shape
158
+ * @returns 32-byte digest (`0x…`)
159
+ */
160
+ export declare function getMembershipBadgeMintPayloadHash(payload: MembershipBadgeMintPayload): Hex;
161
+ /**
162
+ * Deterministic ERC-5114 badge id: `uint256(getMembershipBadgeMintPayloadHash(payload))`.
163
+ *
164
+ * @param payload Mint tuple fields in router/storage shape
165
+ * @returns Badge id as bigint
166
+ */
167
+ export declare function membershipBadgeIdFromMintPayload(payload: MembershipBadgeMintPayload): bigint;
@@ -13,6 +13,11 @@ export declare const CASHIE_RECEIPT_BADGE_METADATA_FORMAT: "Cashie-ReceiptBadge-
13
13
  * ERC-5114 JSON does not embed this string; compare against the contract when resolving badges.
14
14
  */
15
15
  export declare const CASHIE_PAYMENT_RECORD_BADGE_METADATA_FORMAT: "Cashie-PaymentRecordBadge-v1";
16
+ /**
17
+ * Matches `CashieMembershipBadge.metadataFormat()` (`_METADATA_FORMAT`).
18
+ * ERC-5114 JSON does not embed this string; compare against the contract when resolving badges.
19
+ */
20
+ export declare const CASHIE_MEMBERSHIP_BADGE_METADATA_FORMAT: "Cashie-MembershipBadge-v1";
16
21
  /**
17
22
  * `identityType` strings emitted by `IdentitySoulMetadataEncoderLib` — parallel to {@link IdentityType} ordinals.
18
23
  */
@@ -70,6 +75,24 @@ export declare const cashiePaymentRecordBadgeMetadataSchema: z.ZodObject<{
70
75
  receiptBadgeId: z.ZodString;
71
76
  salt: z.ZodString;
72
77
  }, z.core.$strict>;
78
+ /** EIP-721 JSON from `MembershipBadgeMetadataEncoderLib`. */
79
+ export declare const cashieMembershipBadgeMetadataSchema: z.ZodObject<{
80
+ name: z.ZodString;
81
+ description: z.ZodString;
82
+ image: z.ZodString;
83
+ soulBoundTo: z.ZodObject<{
84
+ identityContract: z.ZodString;
85
+ tokenId: z.ZodString;
86
+ }, z.core.$strict>;
87
+ blockNumber: z.ZodString;
88
+ chainId: z.ZodString;
89
+ recipient: z.ZodString;
90
+ isMembershipActive: z.ZodEnum<{
91
+ true: "true";
92
+ false: "false";
93
+ }>;
94
+ salt: z.ZodString;
95
+ }, z.core.$strict>;
73
96
  /**
74
97
  * EIP-721 JSON from `IdentitySoulMetadataEncoderLib` (on-chain wire format).
75
98
  * Use `.parse()` on decoded token URI JSON.
@@ -101,6 +124,7 @@ export declare const cashieIdentitySoulTokenMetadataSchema: z.ZodObject<{
101
124
  export type CashieReceiptBadgeSoulBoundTo = z.infer<typeof cashieReceiptBadgeSoulBoundToSchema>;
102
125
  export type CashieReceiptBadgeMetadata = z.infer<typeof cashieReceiptBadgeMetadataSchema>;
103
126
  export type CashiePaymentRecordBadgeMetadata = z.infer<typeof cashiePaymentRecordBadgeMetadataSchema>;
127
+ export type CashieMembershipBadgeMetadata = z.infer<typeof cashieMembershipBadgeMetadataSchema>;
104
128
  export type CashieIdentitySoulTokenMetadata = z.infer<typeof cashieIdentitySoulTokenMetadataSchema>;
105
129
  export type ParsedCashieMetadata = {
106
130
  kind: 'identitySoul';
@@ -113,4 +137,8 @@ export type ParsedCashieMetadata = {
113
137
  kind: 'paymentRecordBadge';
114
138
  format: typeof CASHIE_PAYMENT_RECORD_BADGE_METADATA_FORMAT;
115
139
  data: CashiePaymentRecordBadgeMetadata;
140
+ } | {
141
+ kind: 'membershipBadge';
142
+ format: typeof CASHIE_MEMBERSHIP_BADGE_METADATA_FORMAT;
143
+ data: CashieMembershipBadgeMetadata;
116
144
  };
@@ -1,6 +1,6 @@
1
1
  import { type Address, type Hex } from 'viem';
2
2
  import { IdentityIssuer, IssueIdentityProofRequest } from '../issuer/index.js';
3
- import { CashieIdentitySoulTokenMetadata, CashieReceiptBadgeMetadata, CashiePaymentRecordBadgeMetadata } from '../../data/index.js';
3
+ import { CashieIdentitySoulTokenMetadata, CashieReceiptBadgeMetadata, CashiePaymentRecordBadgeMetadata, CashieMembershipBadgeMetadata } from '../../data/index.js';
4
4
  import { IdentityMintConsentArgs } from '../../identity/cashieIdentitySoulTypedData.js';
5
5
  interface ISoulManagerConstructorArgs {
6
6
  identityIssuer: IdentityIssuer;
@@ -46,9 +46,16 @@ export interface ISoulManager {
46
46
  * @returns The payment record badge metadata
47
47
  */
48
48
  getCashiePaymentRecordBadgeMetadata(badgeId: Hex): Promise<CashiePaymentRecordBadgeMetadata | undefined>;
49
+ /**
50
+ * Get the membership badge metadata for an account.
51
+ *
52
+ * @param account - The account address
53
+ * @returns The membership badge metadata, or undefined when none is minted
54
+ */
55
+ getCashieMembershipBadgeMetadata(account: Address): Promise<CashieMembershipBadgeMetadata | undefined>;
49
56
  }
50
57
  /**
51
- * Soul manager class is responsible for managing the (ERC-5484) identity soul tokens and (ERC-5114) receipt and payment record badges
58
+ * Soul manager class is responsible for managing the (ERC-5484) identity soul tokens and (ERC-5114) receipt, payment record, and membership badges
52
59
  */
53
60
  export declare class SoulManager implements ISoulManager {
54
61
  #private;
@@ -59,5 +66,6 @@ export declare class SoulManager implements ISoulManager {
59
66
  getCashieIdentitySoulTokenMetadata(account: Address): Promise<CashieIdentitySoulTokenMetadata | undefined>;
60
67
  getCashieReceiptBadgeMetadata(badgeId: Hex): Promise<CashieReceiptBadgeMetadata | undefined>;
61
68
  getCashiePaymentRecordBadgeMetadata(badgeId: Hex): Promise<CashiePaymentRecordBadgeMetadata | undefined>;
69
+ getCashieMembershipBadgeMetadata(account: Address): Promise<CashieMembershipBadgeMetadata | undefined>;
62
70
  }
63
71
  export {};
@@ -152,6 +152,11 @@ export type IdentityMintSignPayloadWithSignature = IdentityMintSignPayload & {
152
152
  * Recipient EIP-1271 consent signature over `IdentityMintConsent` (includes `proof`).
153
153
  */
154
154
  signature: Hex;
155
+ /**
156
+ * `bytes32` salt of the identity mint. Not part of the EIP-712 proof or consent hash.
157
+ * The router uses it as the membership badge salt.
158
+ */
159
+ salt: Hex;
155
160
  };
156
161
  /**
157
162
  * EIP-712 domain for `CashieIdentitySoul` (`EIP712(NAME, DOMAIN_VERSION)`).
@@ -191,6 +196,7 @@ export type IdentitySoulDiscovery = {
191
196
  badgeContracts: {
192
197
  paymentRecordBadgeContract: Address;
193
198
  receiptBadgeContract: Address;
199
+ membershipBadgeContract: Address;
194
200
  };
195
201
  };
196
202
  };