@cashie/core-lib 1.1.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.
- package/README.md +3 -1
- package/dist/abi/abi.d.ts +763 -0
- package/dist/backend/contracts/badge.types.d.ts +7 -3
- package/dist/backend/tx-tracking/types.d.ts +29 -9
- package/dist/client/payment-client.d.ts +18 -17
- package/dist/client/schemas.d.ts +93 -18
- package/dist/client/types.d.ts +49 -39
- package/dist/data/cashieDataUrl.d.ts +22 -3
- package/dist/data/encoder.d.ts +42 -5
- package/dist/data/types.d.ts +28 -0
- package/dist/identity/soul/soulManager.d.ts +10 -2
- package/dist/identity/types.d.ts +6 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +3 -3
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +3 -3
- package/dist/intent/encoder.d.ts +29 -12
- package/dist/intent/types.d.ts +66 -23
- package/dist/shared/errorCode.d.ts +1 -1
- package/dist/utils/utils.d.ts +3 -3
- package/package.json +3 -3
|
@@ -1,17 +1,21 @@
|
|
|
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
|
+
badgeKind: BadgeKind;
|
|
11
12
|
};
|
|
12
13
|
export type GetBadgeOwnerOfParams = BadgeChainParams & {
|
|
13
14
|
badgeId: Hex;
|
|
14
15
|
};
|
|
16
|
+
export type GetBadgeUriParams = BadgeChainParams & {
|
|
17
|
+
badgeId: Hex;
|
|
18
|
+
};
|
|
15
19
|
export type GetBadgeMetadataFormatParams = BadgeChainParams;
|
|
16
20
|
export type TotalBadgesOfIdentityParams = BadgeChainParams & {
|
|
17
21
|
account: Address;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { Hex, Hash, Address } from 'viem';
|
|
2
|
-
import { BadgeKind
|
|
3
|
-
|
|
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
|
-
|
|
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:
|
|
18
|
+
taskEntries: TaskEntry<IntentActions>[];
|
|
16
19
|
};
|
|
17
20
|
/**
|
|
18
21
|
* A payment intent tracking entry.
|
|
19
22
|
*/
|
|
20
|
-
export type
|
|
21
|
-
|
|
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 -
|
|
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:
|
|
60
|
+
paymentIntentTrackingEntries: IntentTrackingEntry<PaymentIntentActions>[];
|
|
41
61
|
}): Hex | null;
|
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
import {
|
|
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:
|
|
8
|
-
getProtocolFeeBps(params:
|
|
9
|
-
calculateRewardAmount(params:
|
|
10
|
-
sendIntent(params:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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.
|
package/dist/client/schemas.d.ts
CHANGED
|
@@ -1,27 +1,15 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { BurnAuth } from '../identity/types.js';
|
|
3
|
-
import type
|
|
4
|
-
import type {
|
|
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,10 +43,74 @@ 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
|
};
|
|
46
|
+
export type BadgeRpcMethodNames = Extract<RpcMethodNames, `badge_${string}`>;
|
|
47
|
+
export declare const badgeRpcParamSchemas: {
|
|
48
|
+
badge_getOwnerOf: z.ZodTuple<[z.ZodObject<{
|
|
49
|
+
chainHex: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
50
|
+
badgeId: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
51
|
+
badgeKind: z.ZodEnum<{
|
|
52
|
+
receipt: "receipt";
|
|
53
|
+
paymentRecord: "paymentRecord";
|
|
54
|
+
membership: "membership";
|
|
55
|
+
}>;
|
|
56
|
+
}, z.core.$strip>], null>;
|
|
57
|
+
badge_getBadgeUri: z.ZodTuple<[z.ZodObject<{
|
|
58
|
+
chainHex: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
59
|
+
badgeId: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
60
|
+
badgeKind: z.ZodEnum<{
|
|
61
|
+
receipt: "receipt";
|
|
62
|
+
paymentRecord: "paymentRecord";
|
|
63
|
+
membership: "membership";
|
|
64
|
+
}>;
|
|
65
|
+
}, z.core.$strip>], null>;
|
|
66
|
+
badge_getMetadataFormat: z.ZodTuple<[z.ZodObject<{
|
|
67
|
+
chainHex: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
68
|
+
badgeKind: z.ZodEnum<{
|
|
69
|
+
receipt: "receipt";
|
|
70
|
+
paymentRecord: "paymentRecord";
|
|
71
|
+
membership: "membership";
|
|
72
|
+
}>;
|
|
73
|
+
}, z.core.$strip>], null>;
|
|
74
|
+
badge_totalBadgesOfIdentity: z.ZodTuple<[z.ZodObject<{
|
|
75
|
+
chainHex: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
76
|
+
account: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
77
|
+
badgeKind: z.ZodEnum<{
|
|
78
|
+
receipt: "receipt";
|
|
79
|
+
paymentRecord: "paymentRecord";
|
|
80
|
+
membership: "membership";
|
|
81
|
+
}>;
|
|
82
|
+
}, z.core.$strip>], null>;
|
|
83
|
+
badge_badgeOfIdentityByIndex: z.ZodTuple<[z.ZodObject<{
|
|
84
|
+
chainHex: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
85
|
+
account: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
86
|
+
badgeKind: z.ZodEnum<{
|
|
87
|
+
receipt: "receipt";
|
|
88
|
+
paymentRecord: "paymentRecord";
|
|
89
|
+
membership: "membership";
|
|
90
|
+
}>;
|
|
91
|
+
index: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
92
|
+
}, z.core.$strip>], null>;
|
|
93
|
+
badge_badgesOfIdentity: z.ZodTuple<[z.ZodObject<{
|
|
94
|
+
chainHex: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
95
|
+
account: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
96
|
+
badgeKind: z.ZodEnum<{
|
|
97
|
+
receipt: "receipt";
|
|
98
|
+
paymentRecord: "paymentRecord";
|
|
99
|
+
membership: "membership";
|
|
100
|
+
}>;
|
|
101
|
+
offset: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
102
|
+
limit: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
103
|
+
}, z.core.$strip>], null>;
|
|
104
|
+
};
|
|
105
|
+
export declare class PaymentRpcParamsValidationError extends Error {
|
|
106
|
+
readonly method: BadgeRpcMethodNames;
|
|
107
|
+
readonly zodError: z.ZodError;
|
|
108
|
+
constructor(method: BadgeRpcMethodNames, zodError: z.ZodError);
|
|
109
|
+
}
|
|
43
110
|
export declare class PaymentRpcResponseValidationError extends Error {
|
|
44
|
-
readonly method:
|
|
111
|
+
readonly method: RpcMethodNames;
|
|
45
112
|
readonly zodError: z.ZodError;
|
|
46
|
-
constructor(method:
|
|
113
|
+
constructor(method: RpcMethodNames, zodError: z.ZodError);
|
|
47
114
|
}
|
|
48
115
|
/**
|
|
49
116
|
* Parses the result from the RPC call to the corresponding Zod schema.
|
|
@@ -52,4 +119,12 @@ export declare class PaymentRpcResponseValidationError extends Error {
|
|
|
52
119
|
* @param result - The result from the RPC call
|
|
53
120
|
* @returns The parsed result according to the Zod schema
|
|
54
121
|
*/
|
|
55
|
-
export declare function parsePaymentRpcReturn<T extends
|
|
122
|
+
export declare function parsePaymentRpcReturn<T extends RpcMethodNames>(method: T, result: unknown): PaymentRpcReturn<T>;
|
|
123
|
+
/**
|
|
124
|
+
* Parses badge RPC params against the corresponding Zod schema.
|
|
125
|
+
*
|
|
126
|
+
* @param method - The badge RPC method name
|
|
127
|
+
* @param params - The params from the RPC call
|
|
128
|
+
* @returns The parsed params according to the Zod schema
|
|
129
|
+
*/
|
|
130
|
+
export declare function parsePaymentRpcParams<T extends BadgeRpcMethodNames>(method: T, params: unknown): RpcParams<T>;
|
package/dist/client/types.d.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { Address, Hex } from 'viem';
|
|
2
|
-
import {
|
|
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 {
|
|
5
|
+
import type { IntentTrackingEntry } from '../backend/tx-tracking/types.js';
|
|
6
|
+
import type { BadgeKind } from '../backend/contracts/badge.types.js';
|
|
6
7
|
type PrepareRouterCallsParams = {
|
|
7
8
|
recipient: Address;
|
|
8
9
|
allowance: Hex;
|
|
9
10
|
tokenAddress: Address;
|
|
10
11
|
chainId: Hex;
|
|
11
|
-
action:
|
|
12
|
-
|
|
12
|
+
action: PaymentIntentActions;
|
|
13
|
+
rewardData?: RewardData;
|
|
13
14
|
salt: Hex;
|
|
14
15
|
};
|
|
15
16
|
type BadgeOwner = {
|
|
16
17
|
nftAddress: Address;
|
|
17
18
|
nftTokenId: Hex;
|
|
18
19
|
};
|
|
19
|
-
type BadgeKind = 'receipt' | 'paymentRecord';
|
|
20
20
|
type PrePaymentSetup = {
|
|
21
21
|
signedIdentityMintPayload: IdentityMintSignPayloadWithSignature;
|
|
22
22
|
initCodeData: InitCodeData;
|
|
@@ -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
|
|
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,10 +72,48 @@ 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;
|
|
108
115
|
badgeId: Hex;
|
|
116
|
+
badgeKind: BadgeKind;
|
|
109
117
|
}];
|
|
110
118
|
return: BadgeOwner;
|
|
111
119
|
};
|
|
@@ -113,12 +121,14 @@ interface PaymentRpcMethodMapping {
|
|
|
113
121
|
params: [{
|
|
114
122
|
chainHex: Hex;
|
|
115
123
|
badgeId: Hex;
|
|
124
|
+
badgeKind: BadgeKind;
|
|
116
125
|
}];
|
|
117
126
|
return: string | null;
|
|
118
127
|
};
|
|
119
128
|
badge_getMetadataFormat: {
|
|
120
129
|
params: [{
|
|
121
130
|
chainHex: Hex;
|
|
131
|
+
badgeKind: BadgeKind;
|
|
122
132
|
}];
|
|
123
133
|
return: string;
|
|
124
134
|
};
|
|
@@ -157,7 +167,7 @@ interface PaymentRpcMethodMapping {
|
|
|
157
167
|
/**
|
|
158
168
|
* The method names for the payment API.
|
|
159
169
|
*/
|
|
160
|
-
export type
|
|
161
|
-
export type
|
|
162
|
-
export type PaymentRpcReturn<T extends
|
|
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'];
|
|
163
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
|
|
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
|
package/dist/data/encoder.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Address, Hex } from 'viem';
|
|
2
|
-
import type {
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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;
|
package/dist/data/types.d.ts
CHANGED
|
@@ -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
|
|
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 {};
|