@cashie/core-lib 1.0.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.
Files changed (68) hide show
  1. package/README.md +9 -0
  2. package/dist/abi/abi.d.ts +2620 -0
  3. package/dist/abi/index.d.ts +1 -0
  4. package/dist/backend/auth/index.d.ts +4 -0
  5. package/dist/backend/auth/jwt.types.d.ts +3 -0
  6. package/dist/backend/auth/ocap/ocap-build.d.ts +35 -0
  7. package/dist/backend/auth/ocap/ocap-types.d.ts +87 -0
  8. package/dist/backend/auth/siwe.types.d.ts +18 -0
  9. package/dist/backend/blockchain/index.d.ts +1 -0
  10. package/dist/backend/blockchain/types.d.ts +11 -0
  11. package/dist/backend/contracts/badge.types.d.ts +25 -0
  12. package/dist/backend/contracts/balance.types.d.ts +32 -0
  13. package/dist/backend/contracts/event.types.d.ts +34 -0
  14. package/dist/backend/contracts/index.d.ts +4 -0
  15. package/dist/backend/contracts/receipt.types.d.ts +55 -0
  16. package/dist/backend/index.d.ts +4 -0
  17. package/dist/backend/tx-tracking/index.d.ts +1 -0
  18. package/dist/backend/tx-tracking/types.d.ts +41 -0
  19. package/dist/client/index.d.ts +2 -0
  20. package/dist/client/payment-client.d.ts +30 -0
  21. package/dist/client/schemas.d.ts +55 -0
  22. package/dist/client/types.d.ts +163 -0
  23. package/dist/data/cashieDataUrl.d.ts +79 -0
  24. package/dist/data/encoder.d.ts +130 -0
  25. package/dist/data/index.d.ts +3 -0
  26. package/dist/data/types.d.ts +116 -0
  27. package/dist/erc-7715/common.types.d.ts +37 -0
  28. package/dist/erc-7715/index.d.ts +4 -0
  29. package/dist/erc-7715/permission/index.d.ts +2 -0
  30. package/dist/erc-7715/permission/schemas.d.ts +172 -0
  31. package/dist/erc-7715/permission/types.d.ts +27 -0
  32. package/dist/erc-7715/request/index.d.ts +2 -0
  33. package/dist/erc-7715/request/schemas.d.ts +260 -0
  34. package/dist/erc-7715/request/types.d.ts +47 -0
  35. package/dist/erc-7715/rules/index.d.ts +2 -0
  36. package/dist/erc-7715/rules/schemas.d.ts +76 -0
  37. package/dist/erc-7715/rules/types.d.ts +26 -0
  38. package/dist/identity/cashieIdentitySoulTypedData.d.ts +65 -0
  39. package/dist/identity/encoder.d.ts +24 -0
  40. package/dist/identity/index.d.ts +5 -0
  41. package/dist/identity/issuer/error/index.d.ts +1 -0
  42. package/dist/identity/issuer/error/plaidIdvErrors.d.ts +24 -0
  43. package/dist/identity/issuer/identity-issuer.d.ts +30 -0
  44. package/dist/identity/issuer/index.d.ts +3 -0
  45. package/dist/identity/issuer/types.d.ts +35 -0
  46. package/dist/identity/soul/index.d.ts +1 -0
  47. package/dist/identity/soul/soulManager.d.ts +63 -0
  48. package/dist/identity/types.d.ts +196 -0
  49. package/dist/index.cjs +2 -0
  50. package/dist/index.cjs.map +7 -0
  51. package/dist/index.d.ts +10 -0
  52. package/dist/index.mjs +2 -0
  53. package/dist/index.mjs.map +7 -0
  54. package/dist/intent/encoder.d.ts +22 -0
  55. package/dist/intent/index.d.ts +2 -0
  56. package/dist/intent/types.d.ts +88 -0
  57. package/dist/router/index.d.ts +1 -0
  58. package/dist/router/types.d.ts +12 -0
  59. package/dist/shared/either.d.ts +68 -0
  60. package/dist/shared/errorCode.d.ts +115 -0
  61. package/dist/shared/index.d.ts +3 -0
  62. package/dist/shared/types/eip-7702.types.d.ts +21 -0
  63. package/dist/shared/types/index.d.ts +3 -0
  64. package/dist/shared/types/payment-protocol.types.d.ts +17 -0
  65. package/dist/shared/types/rpc.types.d.ts +14 -0
  66. package/dist/utils/index.d.ts +1 -0
  67. package/dist/utils/utils.d.ts +17 -0
  68. package/package.json +67 -0
@@ -0,0 +1 @@
1
+ export * from './abi.js';
@@ -0,0 +1,4 @@
1
+ export * from './siwe.types.js';
2
+ export * from './jwt.types.js';
3
+ export * from './ocap/ocap-types.js';
4
+ export * from './ocap/ocap-build.js';
@@ -0,0 +1,3 @@
1
+ import { Address } from 'viem';
2
+ export type SubJwtPayloadEntry = `${'did:ethereum:'}${string}:${Address}`;
3
+ export type SubJwtPayload = `${'did:ethereum:owner:'}${Address},${'did:ethereum:smart-account:'}${Address}`;
@@ -0,0 +1,35 @@
1
+ import type { Capability } from './ocap-types.js';
2
+ export type BuildOcapParams = {
3
+ resources: Capability['resources'];
4
+ allowedAudiences: string[];
5
+ };
6
+ export type BuildOcapResult = {
7
+ ocap: Capability;
8
+ ocapId: string;
9
+ };
10
+ /**
11
+ * Produce a deterministic JSON string for a capability (sorted keys, sorted arrays).
12
+ *
13
+ * @param capability - The capability to canonicalize
14
+ * @returns The canonicalized capability
15
+ */
16
+ export declare function canonicalOcapPayload(capability: Capability): string;
17
+ /**
18
+ * Compute ocapId as keccak256(canonical_ocap_payload) per spec.
19
+ * OCAPs MUST be deterministic and hashable.
20
+ *
21
+ * @param capability - The capability to build the ocap id for
22
+ * @returns The ocap id
23
+ */
24
+ export declare function buildOcapId(capability: Capability): string;
25
+ export declare class OcapValidationError extends Error {
26
+ constructor(message: string);
27
+ }
28
+ /**
29
+ * Validate requested resources against allowed audiences and build the granted OCAP in a canonical form (sorted keys, sorted arrays).
30
+ * Rejects unsupported resource types or disallowed audiences.
31
+ *
32
+ * @param params - The parameters to validate and build the ocap
33
+ * @returns The validated and built ocap
34
+ */
35
+ export declare function validateAndBuildOcap(params: BuildOcapParams): BuildOcapResult;
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Types for Identity OCAP (Off-Chain Capabilities) per docs/user-identity-ocap.md
3
+ */
4
+ import { SubJwtPayload } from '../jwt.types.js';
5
+ export type ApiMethods = 'POST' | 'GET' | 'PUT' | 'PATCH' | 'DELETE';
6
+ /**
7
+ * A resource that can be accessed via API
8
+ */
9
+ export type ApiResource = {
10
+ type: 'api';
11
+ audience: string;
12
+ data: {
13
+ endpoint: string;
14
+ methods: ApiMethods[];
15
+ };
16
+ };
17
+ export type SupportedResource = ApiResource;
18
+ export type Capability = {
19
+ /**
20
+ * The requested off-chain capabilities resources
21
+ */
22
+ resources: {
23
+ api: ApiResource[];
24
+ };
25
+ };
26
+ /** JWT claims for OCAP identity tokens (RFC 7519 + custom ocap claim) */
27
+ export type OcapJwtPayload = {
28
+ /**
29
+ * The issuer of the JWT
30
+ */
31
+ iss: string;
32
+ /**
33
+ * The subject of the JWT that is the user's public ethereum address
34
+ */
35
+ sub: SubJwtPayload;
36
+ /**
37
+ * The audience of the JWT
38
+ */
39
+ aud: string[];
40
+ /**
41
+ * The expiration time of the JWT(unix timestamp)
42
+ */
43
+ exp: number;
44
+ /**
45
+ * The not before time of the JWT
46
+ */
47
+ nbf: number;
48
+ /**
49
+ * The issued at time of the JWT
50
+ */
51
+ iat: number;
52
+ /**
53
+ * The JWT ID of the JWT
54
+ */
55
+ jti: string;
56
+ /**
57
+ * The granted off-chain capabilities of the JWT
58
+ */
59
+ ocap: Capability;
60
+ };
61
+ /** Request body for POST v1/ocaps/auth */
62
+ export type OcapAuthRequestBody = {
63
+ /**
64
+ * The SIWE message
65
+ */
66
+ message: string;
67
+ /**
68
+ * The signature of the SIWE message
69
+ */
70
+ signature: string;
71
+ /**
72
+ * The request off-chain capabilities resources
73
+ */
74
+ resources: Capability['resources'];
75
+ };
76
+ /** Response from GET v1/ocaps/auth/discovery */
77
+ export type OcapDiscoveryResponse = {
78
+ allowedResources: ApiResource[];
79
+ };
80
+ /**
81
+ * Audiences for OCAP
82
+ */
83
+ export declare enum OcapAudiences {
84
+ ACCOUNT_SERVICE = "account-service",
85
+ PAYMENT_SERVICE = "payment-service",
86
+ IDV_SERVICE = "idv-service"
87
+ }
@@ -0,0 +1,18 @@
1
+ import { Address } from 'viem';
2
+ import { Capability } from './ocap/ocap-types.js';
3
+ /**
4
+ * The default maximum age of a SIWE message in milliseconds of 5 minutes.
5
+ */
6
+ export declare const DEFAULT_MAX_AGE_MS: number;
7
+ /**
8
+ * The prefix of the statement of the SIWE message.
9
+ */
10
+ export declare const OCAP_STATEMENT_PREFIX = "Request OCAP";
11
+ /**
12
+ * Prepare the statement of the SIWE message.
13
+ *
14
+ * @param smartAccountAddress The smart account address
15
+ * @param resources The requested resources
16
+ * @returns The prepared statement
17
+ */
18
+ export declare function prepareStatement(smartAccountAddress: Address, resources: Capability['resources']): string;
@@ -0,0 +1 @@
1
+ export * from './types.js';
@@ -0,0 +1,11 @@
1
+ import { Address, Hex } from 'viem';
2
+ export type Account7702UpgradeDetailsArgs = {
3
+ address: Address;
4
+ chainId: Hex;
5
+ };
6
+ export type Account7702UpgradeDetails = {
7
+ chainId: Hex;
8
+ contractAddress: Address;
9
+ isAccountUpgraded: boolean;
10
+ is7702Supported: boolean;
11
+ };
@@ -0,0 +1,25 @@
1
+ import { Address, Hex } from 'viem';
2
+ import { CashieReceiptBadgeMetadata, CashiePaymentRecordBadgeMetadata } from '../../data/types.js';
3
+ export type BadgeOwner = {
4
+ nftAddress: Address;
5
+ nftTokenId: Hex;
6
+ };
7
+ export type BadgeKind = 'receipt' | 'paymentRecord';
8
+ export type BadgeMetadata = CashieReceiptBadgeMetadata | CashiePaymentRecordBadgeMetadata;
9
+ export type BadgeChainParams = {
10
+ chainHex: Hex;
11
+ };
12
+ export type GetBadgeOwnerOfParams = BadgeChainParams & {
13
+ badgeId: Hex;
14
+ };
15
+ export type GetBadgeMetadataFormatParams = BadgeChainParams;
16
+ export type TotalBadgesOfIdentityParams = BadgeChainParams & {
17
+ account: Address;
18
+ };
19
+ export type BadgeOfIdentityByIndexParams = TotalBadgesOfIdentityParams & {
20
+ index: Hex;
21
+ };
22
+ export type BadgesOfIdentityParams = TotalBadgesOfIdentityParams & {
23
+ offset: Hex;
24
+ limit: Hex;
25
+ };
@@ -0,0 +1,32 @@
1
+ import { Address, Hex } from 'viem';
2
+ export type StablecoinBalanceItem = {
3
+ balance: Hex;
4
+ decimals: number;
5
+ symbol: string;
6
+ contractAddress: Address;
7
+ };
8
+ /**
9
+ * The parameters for the get stablecoin balance method
10
+ *
11
+ * @param chainId - The chain id
12
+ * @param account - The account to get the balance of
13
+ */
14
+ export type StablecoinBalanceResponses = Record<Hex, StablecoinBalanceItem[]>;
15
+ export type StablecoinTokenDetailsByChainIdItem = {
16
+ decimals: number;
17
+ symbol: string;
18
+ };
19
+ /**
20
+ * The details of a stablecoin token by chain id
21
+ *
22
+ * @param decimals - The decimals of the token
23
+ * @param symbol - The symbol of the token
24
+ */
25
+ export type StablecoinTokenDetailsByChainId = Record<Hex, Record<Address, StablecoinTokenDetailsByChainIdItem>>;
26
+ export type Erc20TokenAccountDetails = {
27
+ chainId: Hex;
28
+ balance: Hex;
29
+ decimals: number;
30
+ symbol: string;
31
+ contractAddress: Address;
32
+ };
@@ -0,0 +1,34 @@
1
+ import { Hex, Address } from 'viem';
2
+ export type CashieRouterV1PaymentEvent = {
3
+ type: 'incoming' | 'outgoing';
4
+ payer: Address;
5
+ receiver: Address;
6
+ feeBeneficiaryAddress: Address;
7
+ allowance: Hex;
8
+ recipientAmount: Hex;
9
+ protocolFee: Hex;
10
+ protocolFeeBps: Hex;
11
+ tokenAddress: Address;
12
+ };
13
+ export type CashieRouterV1DepositEvent = {
14
+ type: 'incoming';
15
+ sender: Address;
16
+ recipient: Address;
17
+ amount: Hex;
18
+ tokenAddress: Address;
19
+ };
20
+ export type CashieRouterV1WithdrawEvent = {
21
+ type: 'outgoing';
22
+ account: Address;
23
+ recipient: Address;
24
+ amount: Hex;
25
+ protocolFee: Hex;
26
+ protocolFeeBps: Hex;
27
+ tokenAddress: Address;
28
+ };
29
+ export type CashieRouterV1RewardEvent = {
30
+ type: 'incoming';
31
+ recipient: Address;
32
+ rewardAmount: Hex;
33
+ rewardToken: Address;
34
+ };
@@ -0,0 +1,4 @@
1
+ export * from './balance.types.js';
2
+ export * from './badge.types.js';
3
+ export * from './event.types.js';
4
+ export * from './receipt.types.js';
@@ -0,0 +1,55 @@
1
+ import { Hash, Hex } from 'viem';
2
+ import { CashieRouterV1PaymentEvent, CashieRouterV1DepositEvent, CashieRouterV1WithdrawEvent, CashieRouterV1RewardEvent } from './event.types.js';
3
+ /**
4
+ * @deprecated This type is deprecated and will be removed in the future. Use badge pagination methods instead to generate the account statement.
5
+ */
6
+ export type CashieReceiptBase = {
7
+ transactionHash: Hash;
8
+ blockNumber: Hex;
9
+ chainId: Hex;
10
+ };
11
+ /**
12
+ * @deprecated This type is deprecated and will be removed in the future. Use badge pagination methods instead to generate the account statement.
13
+ */
14
+ export type CashieTransactionReceipt = CashieReceiptBase & {
15
+ args: CashieRouterV1PaymentEvent;
16
+ stablecoinTokenDetail: {
17
+ decimals: number;
18
+ symbol: string;
19
+ };
20
+ };
21
+ /**
22
+ * @deprecated This type is deprecated and will be removed in the future. Use badge pagination methods instead to generate the account statement.
23
+ */
24
+ export type CashieRouterV1DepositReceipt = CashieReceiptBase & {
25
+ args: CashieRouterV1DepositEvent;
26
+ stablecoinTokenDetail: {
27
+ decimals: number;
28
+ symbol: string;
29
+ };
30
+ };
31
+ /**
32
+ * @deprecated This type is deprecated and will be removed in the future. Use badge pagination methods instead to generate the account statement.
33
+ */
34
+ export type CashieRouterV1WithdrawReceipt = CashieReceiptBase & {
35
+ args: CashieRouterV1WithdrawEvent;
36
+ stablecoinTokenDetail: {
37
+ decimals: number;
38
+ symbol: string;
39
+ };
40
+ };
41
+ /**
42
+ * @deprecated This type is deprecated and will be removed in the future. Use badge pagination methods instead to generate the account statement.
43
+ */
44
+ export type CashieRouterV1RewardReceipt = CashieReceiptBase & {
45
+ args: CashieRouterV1RewardEvent;
46
+ };
47
+ /**
48
+ * @deprecated This type is deprecated and will be removed in the future. Use badge pagination methods instead to generate the account statement.
49
+ */
50
+ export type CashieAccountStatement = {
51
+ paymentReceipts: CashieTransactionReceipt[];
52
+ depositReceipts: CashieRouterV1DepositReceipt[];
53
+ withdrawReceipts: CashieRouterV1WithdrawReceipt[];
54
+ rewardReceipts: CashieRouterV1RewardReceipt[];
55
+ };
@@ -0,0 +1,4 @@
1
+ export * from './contracts/index.js';
2
+ export * from './tx-tracking/index.js';
3
+ export * from './auth/index.js';
4
+ export * from './blockchain/index.js';
@@ -0,0 +1 @@
1
+ export * from './types.js';
@@ -0,0 +1,41 @@
1
+ import { Hex, Hash, Address } from 'viem';
2
+ import { BadgeKind, PaymentIntent } from '../../index.js';
3
+ export type SendPaymentIntentTaskEntry = {
4
+ id: string;
5
+ data: {
6
+ paymentIntent: PaymentIntent;
7
+ };
8
+ };
9
+ /**
10
+ * A task transaction entry.
11
+ */
12
+ export type TransactionEntry = {
13
+ txHash: Hash;
14
+ chainId: Hex;
15
+ taskEntries: SendPaymentIntentTaskEntry[];
16
+ };
17
+ /**
18
+ * A payment intent tracking entry.
19
+ */
20
+ export type PaymentIntentTrackingEntry = {
21
+ paymentIntent: PaymentIntent;
22
+ status: 'pending' | 'confirmed' | 'failed';
23
+ txHash?: Hash | null;
24
+ blockNumber?: Hex | null;
25
+ };
26
+ /**
27
+ * Find the transaction hash for a badge id.
28
+ *
29
+ * @param props - The properties of the badge.
30
+ * @param props.badgeId - The id of the badge.
31
+ * @param props.badgeKind - The kind of the badge.
32
+ * @param props.identityContract - The identity contract.
33
+ * @param props.paymentIntentTrackingEntries - The payment intent tracking entries.
34
+ * @returns The transaction hash for the badge id.
35
+ */
36
+ export declare function findTransactionHashForBadgeId(props: {
37
+ badgeId: Hex;
38
+ badgeKind: BadgeKind;
39
+ identityContract: Address;
40
+ paymentIntentTrackingEntries: PaymentIntentTrackingEntry[];
41
+ }): Hex | null;
@@ -0,0 +1,2 @@
1
+ export * from './payment-client.js';
2
+ export * from './types.js';
@@ -0,0 +1,30 @@
1
+ import { PaymentRpcParams, PaymentRpcReturn } from './types.js';
2
+ export type PaymentRpcClientArgs = {
3
+ url: string;
4
+ chainId: number;
5
+ };
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'>>;
23
+ }
24
+ /**
25
+ * Creates a new Payment RPC client.
26
+ *
27
+ * @param args - The arguments for the Payment RPC client
28
+ * @returns The Payment RPC client
29
+ */
30
+ export declare const createPaymentRpcClient: (args: PaymentRpcClientArgs) => PaymentRpcClient;
@@ -0,0 +1,55 @@
1
+ import { z } from 'zod';
2
+ import { BurnAuth } from '../identity/types.js';
3
+ import type { PaymentIntentTrackingEntry } from '../backend/tx-tracking/types.js';
4
+ import type { PaymentRpcMethodNames, PaymentRpcReturn } from './types.js';
5
+ 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
+ payment_getProtocolFeeBps: z.ZodCustom<`0x${string}`, `0x${string}`>;
16
+ 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
+ payment_prepareRouterCallsFromAction: z.ZodArray<z.ZodObject<{
20
+ to: z.ZodCustom<`0x${string}`, `0x${string}`>;
21
+ data: z.ZodCustom<`0x${string}`, `0x${string}`>;
22
+ }, z.core.$strip>>;
23
+ identity_getBurnAuth: z.ZodCustom<BurnAuth, BurnAuth>;
24
+ identity_getTokenURI: z.ZodNullable<z.ZodString>;
25
+ payment_sendPrePaymentSetup: z.ZodCustom<`0x${string}`, `0x${string}`>;
26
+ payment_getPrePaymentSetup: z.ZodNullable<z.ZodObject<{
27
+ signedIdentityMintPayload: z.ZodType<import("../identity/types.js").IdentityMintSignPayloadWithSignature, unknown, z.core.$ZodTypeInternals<import("../identity/types.js").IdentityMintSignPayloadWithSignature, unknown>>;
28
+ initCodeData: z.ZodObject<{
29
+ factory: z.ZodCustom<`0x${string}`, `0x${string}`>;
30
+ factoryData: z.ZodCustom<`0x${string}`, `0x${string}`>;
31
+ }, z.core.$strict>;
32
+ }, z.core.$strict>>;
33
+ badge_getOwnerOf: z.ZodObject<{
34
+ nftAddress: z.ZodCustom<`0x${string}`, `0x${string}`>;
35
+ nftTokenId: z.ZodCustom<`0x${string}`, `0x${string}`>;
36
+ }, z.core.$strip>;
37
+ badge_getBadgeUri: z.ZodNullable<z.ZodString>;
38
+ badge_getMetadataFormat: z.ZodString;
39
+ badge_totalBadgesOfIdentity: z.ZodCustom<`0x${string}`, `0x${string}`>;
40
+ badge_badgeOfIdentityByIndex: z.ZodCustom<`0x${string}`, `0x${string}`>;
41
+ badge_badgesOfIdentity: z.ZodArray<z.ZodCustom<`0x${string}`, `0x${string}`>>;
42
+ };
43
+ export declare class PaymentRpcResponseValidationError extends Error {
44
+ readonly method: PaymentRpcMethodNames;
45
+ readonly zodError: z.ZodError;
46
+ constructor(method: PaymentRpcMethodNames, zodError: z.ZodError);
47
+ }
48
+ /**
49
+ * Parses the result from the RPC call to the corresponding Zod schema.
50
+ *
51
+ * @param method - The method name
52
+ * @param result - The result from the RPC call
53
+ * @returns The parsed result according to the Zod schema
54
+ */
55
+ export declare function parsePaymentRpcReturn<T extends PaymentRpcMethodNames>(method: T, result: unknown): PaymentRpcReturn<T>;
@@ -0,0 +1,163 @@
1
+ import { Address, Hex } from 'viem';
2
+ import { CashieRouterActions, PaymentIntent, RewardIntentDetails } from '../intent/types.js';
3
+ import { BurnAuth, IdentityMintSignPayloadWithSignature, IdentitySoulDiscovery } from '../identity/index.js';
4
+ import type { InitCodeData } from '../erc-7715/request/types.js';
5
+ import type { PaymentIntentTrackingEntry } from '../backend/tx-tracking/types.js';
6
+ type PrepareRouterCallsParams = {
7
+ recipient: Address;
8
+ allowance: Hex;
9
+ tokenAddress: Address;
10
+ chainId: Hex;
11
+ action: CashieRouterActions;
12
+ rewardIntentDetails?: RewardIntentDetails;
13
+ salt: Hex;
14
+ };
15
+ type BadgeOwner = {
16
+ nftAddress: Address;
17
+ nftTokenId: Hex;
18
+ };
19
+ type BadgeKind = 'receipt' | 'paymentRecord';
20
+ type PrePaymentSetup = {
21
+ signedIdentityMintPayload: IdentityMintSignPayloadWithSignature;
22
+ initCodeData: InitCodeData;
23
+ };
24
+ /**
25
+ * The mapping of payment RPC methods to their corresponding parameters and return types.
26
+ */
27
+ interface PaymentRpcMethodMapping {
28
+ discovery_supportedSouls: {
29
+ params: [{
30
+ chainHex: Hex;
31
+ }];
32
+ return: IdentitySoulDiscovery;
33
+ };
34
+ payment_getProtocolFeeBps: {
35
+ params: [{
36
+ chainHex: Hex;
37
+ }];
38
+ return: Hex;
39
+ };
40
+ payment_calculateRewardAmount: {
41
+ params: [
42
+ {
43
+ chainHex: Hex;
44
+ paymentTokenAmount: Hex;
45
+ paymentTokenDecimals: number;
46
+ }
47
+ ];
48
+ return: Hex;
49
+ };
50
+ payment_sendIntent: {
51
+ params: [PaymentIntent];
52
+ return: Hex;
53
+ };
54
+ payment_getIntentStatuses: {
55
+ params: [{
56
+ address: Address;
57
+ }];
58
+ return: PaymentIntentTrackingEntry[];
59
+ };
60
+ payment_prepareRouterCallsFromAction: {
61
+ params: [PrepareRouterCallsParams];
62
+ return: {
63
+ to: Address;
64
+ data: Hex;
65
+ }[];
66
+ };
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
+ /**
82
+ * Submit data required before a payment can run: smart-account init code and
83
+ * a signed identity mint consent payload.
84
+ */
85
+ payment_sendPrePaymentSetup: {
86
+ params: [
87
+ {
88
+ chainHex: Hex;
89
+ signedIdentityMintPayload: IdentityMintSignPayloadWithSignature;
90
+ initCodeData: InitCodeData;
91
+ }
92
+ ];
93
+ return: Hex;
94
+ };
95
+ /**
96
+ * Fetch stored pre-payment setup for an account, or null if none exists.
97
+ */
98
+ payment_getPrePaymentSetup: {
99
+ params: [{
100
+ chainHex: Hex;
101
+ address: Address;
102
+ }];
103
+ return: PrePaymentSetup | null;
104
+ };
105
+ badge_getOwnerOf: {
106
+ params: [{
107
+ chainHex: Hex;
108
+ badgeId: Hex;
109
+ }];
110
+ return: BadgeOwner;
111
+ };
112
+ badge_getBadgeUri: {
113
+ params: [{
114
+ chainHex: Hex;
115
+ badgeId: Hex;
116
+ }];
117
+ return: string | null;
118
+ };
119
+ badge_getMetadataFormat: {
120
+ params: [{
121
+ chainHex: Hex;
122
+ }];
123
+ return: string;
124
+ };
125
+ badge_totalBadgesOfIdentity: {
126
+ params: [{
127
+ chainHex: Hex;
128
+ account: Address;
129
+ badgeKind: BadgeKind;
130
+ }];
131
+ return: Hex;
132
+ };
133
+ badge_badgeOfIdentityByIndex: {
134
+ params: [
135
+ {
136
+ chainHex: Hex;
137
+ account: Address;
138
+ badgeKind: BadgeKind;
139
+ index: Hex;
140
+ }
141
+ ];
142
+ return: Hex;
143
+ };
144
+ badge_badgesOfIdentity: {
145
+ params: [
146
+ {
147
+ chainHex: Hex;
148
+ account: Address;
149
+ badgeKind: BadgeKind;
150
+ offset: Hex;
151
+ limit: Hex;
152
+ }
153
+ ];
154
+ return: Hex[];
155
+ };
156
+ }
157
+ /**
158
+ * The method names for the payment API.
159
+ */
160
+ export type PaymentRpcMethodNames = keyof PaymentRpcMethodMapping;
161
+ export type PaymentRpcParams<T extends PaymentRpcMethodNames> = PaymentRpcMethodMapping[T]['params'];
162
+ export type PaymentRpcReturn<T extends PaymentRpcMethodNames> = PaymentRpcMethodMapping[T]['return'];
163
+ export {};