@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.
- package/README.md +9 -0
- package/dist/abi/abi.d.ts +2620 -0
- package/dist/abi/index.d.ts +1 -0
- package/dist/backend/auth/index.d.ts +4 -0
- package/dist/backend/auth/jwt.types.d.ts +3 -0
- package/dist/backend/auth/ocap/ocap-build.d.ts +35 -0
- package/dist/backend/auth/ocap/ocap-types.d.ts +87 -0
- package/dist/backend/auth/siwe.types.d.ts +18 -0
- package/dist/backend/blockchain/index.d.ts +1 -0
- package/dist/backend/blockchain/types.d.ts +11 -0
- package/dist/backend/contracts/badge.types.d.ts +25 -0
- package/dist/backend/contracts/balance.types.d.ts +32 -0
- package/dist/backend/contracts/event.types.d.ts +34 -0
- package/dist/backend/contracts/index.d.ts +4 -0
- package/dist/backend/contracts/receipt.types.d.ts +55 -0
- package/dist/backend/index.d.ts +4 -0
- package/dist/backend/tx-tracking/index.d.ts +1 -0
- package/dist/backend/tx-tracking/types.d.ts +41 -0
- package/dist/client/index.d.ts +2 -0
- package/dist/client/payment-client.d.ts +30 -0
- package/dist/client/schemas.d.ts +55 -0
- package/dist/client/types.d.ts +163 -0
- package/dist/data/cashieDataUrl.d.ts +79 -0
- package/dist/data/encoder.d.ts +130 -0
- package/dist/data/index.d.ts +3 -0
- package/dist/data/types.d.ts +116 -0
- package/dist/erc-7715/common.types.d.ts +37 -0
- package/dist/erc-7715/index.d.ts +4 -0
- package/dist/erc-7715/permission/index.d.ts +2 -0
- package/dist/erc-7715/permission/schemas.d.ts +172 -0
- package/dist/erc-7715/permission/types.d.ts +27 -0
- package/dist/erc-7715/request/index.d.ts +2 -0
- package/dist/erc-7715/request/schemas.d.ts +260 -0
- package/dist/erc-7715/request/types.d.ts +47 -0
- package/dist/erc-7715/rules/index.d.ts +2 -0
- package/dist/erc-7715/rules/schemas.d.ts +76 -0
- package/dist/erc-7715/rules/types.d.ts +26 -0
- package/dist/identity/cashieIdentitySoulTypedData.d.ts +65 -0
- package/dist/identity/encoder.d.ts +24 -0
- package/dist/identity/index.d.ts +5 -0
- package/dist/identity/issuer/error/index.d.ts +1 -0
- package/dist/identity/issuer/error/plaidIdvErrors.d.ts +24 -0
- package/dist/identity/issuer/identity-issuer.d.ts +30 -0
- package/dist/identity/issuer/index.d.ts +3 -0
- package/dist/identity/issuer/types.d.ts +35 -0
- package/dist/identity/soul/index.d.ts +1 -0
- package/dist/identity/soul/soulManager.d.ts +63 -0
- package/dist/identity/types.d.ts +196 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +7 -0
- package/dist/intent/encoder.d.ts +22 -0
- package/dist/intent/index.d.ts +2 -0
- package/dist/intent/types.d.ts +88 -0
- package/dist/router/index.d.ts +1 -0
- package/dist/router/types.d.ts +12 -0
- package/dist/shared/either.d.ts +68 -0
- package/dist/shared/errorCode.d.ts +115 -0
- package/dist/shared/index.d.ts +3 -0
- package/dist/shared/types/eip-7702.types.d.ts +21 -0
- package/dist/shared/types/index.d.ts +3 -0
- package/dist/shared/types/payment-protocol.types.d.ts +17 -0
- package/dist/shared/types/rpc.types.d.ts +14 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/utils.d.ts +17 -0
- package/package.json +67 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decode `tokenURI` / `badgeUri` payloads produced by on-chain
|
|
3
|
+
* `TokenMetadataEncoderLib` (`MetadataEncodingPrimitives.JSON_DATA_URI_BASE64_PREFIX`).
|
|
4
|
+
*
|
|
5
|
+
* Validation uses Zod schemas in `./types.js`. Parsed identity fields align with
|
|
6
|
+
* **`IdentityType`** / **`BurnAuth`** from `identity/types.ts`.
|
|
7
|
+
*
|
|
8
|
+
* Pair **`parseCashieReceiptBadgeMetadataFromBadgeUri`** / **`parseCashiePaymentRecordBadgeMetadataFromBadgeUri`**
|
|
9
|
+
* with **`IERC5114.metadataFormat()`** once the badge is minted on-chain.
|
|
10
|
+
*/
|
|
11
|
+
import { type CashieIdentitySoulTokenMetadata, type CashiePaymentRecordBadgeMetadata, type CashieReceiptBadgeMetadata, type ParsedCashieMetadata } from './types.js';
|
|
12
|
+
/**
|
|
13
|
+
* Strips {@link CASHIE_JSON_DATA_URI_BASE64_PREFIX} and returns the UTF-8 JSON string inside.
|
|
14
|
+
*
|
|
15
|
+
* @param dataUri The data URI to decode
|
|
16
|
+
* @returns The UTF-8 JSON string
|
|
17
|
+
*/
|
|
18
|
+
export declare function decodeCashieJsonDataUriToUtf8(dataUri: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Strips {@link CASHIE_SVG_DATA_URI_BASE64_PREFIX} and returns the UTF-8 SVG markup inside.
|
|
21
|
+
*
|
|
22
|
+
* @param dataUri The SVG data URI to decode
|
|
23
|
+
* @returns The UTF-8 SVG markup string
|
|
24
|
+
*/
|
|
25
|
+
export declare function decodeCashieSvgDataUriToUtf8(dataUri: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* Decodes the URI and parses JSON (untyped).
|
|
28
|
+
*
|
|
29
|
+
* @param dataUri The data URI to parse
|
|
30
|
+
* @returns The parsed JSON
|
|
31
|
+
*/
|
|
32
|
+
export declare function parseCashieJsonDataUriJson(dataUri: string): unknown;
|
|
33
|
+
/**
|
|
34
|
+
* Parses `CashieIdentitySoul.tokenURI` metadata (`IdentitySoulMetadataEncoderLib`).
|
|
35
|
+
*
|
|
36
|
+
* @param dataUri The data URI to parse
|
|
37
|
+
* @returns The parsed identity soul metadata
|
|
38
|
+
*/
|
|
39
|
+
export declare function parseCashieIdentitySoulTokenMetadata(dataUri: string): CashieIdentitySoulTokenMetadata;
|
|
40
|
+
/**
|
|
41
|
+
* Parses `CashieReceiptBadge.badgeUri` metadata (`ReceiptBadgeMetadataEncoderLib`).
|
|
42
|
+
*
|
|
43
|
+
* @param dataUri The data URI to parse
|
|
44
|
+
* @returns The parsed receipt badge metadata
|
|
45
|
+
*/
|
|
46
|
+
export declare function parseCashieReceiptBadgeMetadata(dataUri: string): CashieReceiptBadgeMetadata;
|
|
47
|
+
/**
|
|
48
|
+
* Same as {@link parseCashieReceiptBadgeMetadata}, but enforces that
|
|
49
|
+
* `IERC5114.metadataFormat()` matches {@link CASHIE_RECEIPT_BADGE_METADATA_FORMAT}.
|
|
50
|
+
*
|
|
51
|
+
* @param badgeUri The badge URI to parse
|
|
52
|
+
* @param metadataFormatFromContract The metadata format from the contract
|
|
53
|
+
* @returns The parsed receipt badge metadata
|
|
54
|
+
*/
|
|
55
|
+
export declare function parseCashieReceiptBadgeMetadataFromBadgeUri(badgeUri: string, metadataFormatFromContract: string): CashieReceiptBadgeMetadata;
|
|
56
|
+
/**
|
|
57
|
+
* Parses `CashiePaymentRecordBadge.badgeUri` metadata (`PaymentRecordBadgeMetadataEncoderLib`).
|
|
58
|
+
*
|
|
59
|
+
* @param dataUri The data URI to parse
|
|
60
|
+
* @returns The parsed payment record badge metadata
|
|
61
|
+
*/
|
|
62
|
+
export declare function parseCashiePaymentRecordBadgeMetadata(dataUri: string): CashiePaymentRecordBadgeMetadata;
|
|
63
|
+
/**
|
|
64
|
+
* Same as {@link parseCashiePaymentRecordBadgeMetadata}, but enforces that
|
|
65
|
+
* `IERC5114.metadataFormat()` matches {@link CASHIE_PAYMENT_RECORD_BADGE_METADATA_FORMAT}.
|
|
66
|
+
*
|
|
67
|
+
* @param badgeUri The badge URI to parse
|
|
68
|
+
* @param metadataFormatFromContract The metadata format from the contract
|
|
69
|
+
* @returns The parsed payment record badge metadata
|
|
70
|
+
*/
|
|
71
|
+
export declare function parseCashiePaymentRecordBadgeMetadataFromBadgeUri(badgeUri: string, metadataFormatFromContract: string): CashiePaymentRecordBadgeMetadata;
|
|
72
|
+
/**
|
|
73
|
+
* Dispatches on JSON shape: **`identityType`** ⇒ identity soul; **`receiptType`** ⇒ receipt badge;
|
|
74
|
+
* **`receiptBadgeId`** (without **`receiptType`**) ⇒ payment record badge.
|
|
75
|
+
*
|
|
76
|
+
* @param dataUri The data URI to parse
|
|
77
|
+
* @returns The parsed metadata
|
|
78
|
+
*/
|
|
79
|
+
export declare function parseCashieMetadataDataUri(dataUri: string): ParsedCashieMetadata;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import type { Address, Hex } from 'viem';
|
|
2
|
+
import type { PaymentIntent } from '../intent/types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Mirrors on-chain `ReceiptType`
|
|
5
|
+
*/
|
|
6
|
+
export declare const ReceiptType: {
|
|
7
|
+
readonly OneTime: 0;
|
|
8
|
+
readonly Recurring: 1;
|
|
9
|
+
};
|
|
10
|
+
export type ReceiptType = (typeof ReceiptType)[keyof typeof ReceiptType];
|
|
11
|
+
/**
|
|
12
|
+
* Fields ABI-encoded in the same order as `ReceiptBadgeEncoderLib.encodeMintPayload`
|
|
13
|
+
* (`packages/contracts/src/identity/libraries/ReceiptBadgeEncoderLib.sol`).
|
|
14
|
+
*/
|
|
15
|
+
export type ReceiptBadgeMintPayload = {
|
|
16
|
+
soulBoundTo: {
|
|
17
|
+
identityContract: Address;
|
|
18
|
+
tokenId: bigint;
|
|
19
|
+
};
|
|
20
|
+
receiptType: ReceiptType;
|
|
21
|
+
blockNumber: bigint;
|
|
22
|
+
recipient: Address;
|
|
23
|
+
chainId: bigint;
|
|
24
|
+
tokenAddress: Address;
|
|
25
|
+
allowance: bigint;
|
|
26
|
+
/** `bytes32` salt (`0x` + 64 hex chars). */
|
|
27
|
+
salt: Hex;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Canonical `abi.encode` of `ReceiptBadgeMintPayload` (matches Solidity `ReceiptBadgeEncoderLib.encodeMintPayload`).
|
|
31
|
+
*
|
|
32
|
+
* @param payload Mint tuple fields in router/storage shape
|
|
33
|
+
* @returns ABI-encoded bytes as hex
|
|
34
|
+
*/
|
|
35
|
+
export declare function encodeReceiptBadgeMintPayload(payload: ReceiptBadgeMintPayload): Hex;
|
|
36
|
+
/**
|
|
37
|
+
* `keccak256(encodeReceiptBadgeMintPayload(payload))` — matches `ReceiptBadgeEncoderLib.getMintPayloadHash`.
|
|
38
|
+
* On-chain `badgeId == uint256(bytes32 digest)`.
|
|
39
|
+
*
|
|
40
|
+
* @param payload Mint tuple fields in router/storage shape
|
|
41
|
+
* @returns 32-byte digest (`0x…`)
|
|
42
|
+
*/
|
|
43
|
+
export declare function getReceiptBadgeMintPayloadHash(payload: ReceiptBadgeMintPayload): Hex;
|
|
44
|
+
/**
|
|
45
|
+
* Deterministic ERC-5114 badge id: `uint256(getReceiptBadgeMintPayloadHash(payload))`.
|
|
46
|
+
*
|
|
47
|
+
* @param payload Mint tuple fields in router/storage shape
|
|
48
|
+
* @returns Badge id as bigint
|
|
49
|
+
*/
|
|
50
|
+
export declare function receiptBadgeIdFromMintPayload(payload: ReceiptBadgeMintPayload): bigint;
|
|
51
|
+
/**
|
|
52
|
+
* Maps a {@link PaymentIntent} to {@link ReceiptBadgeMintPayload} (matches `TokenDistributor._issueReceiptBadge`).
|
|
53
|
+
*
|
|
54
|
+
* @param identityContract `CashieIdentitySoul` address bound in `soulBoundTo`
|
|
55
|
+
* @param paymentIntent Payment fields and mint salt
|
|
56
|
+
* @param blockNumber Execution block (`block.number` at mint)
|
|
57
|
+
* @param receiptType Receipt badge type from `ReceiptBadgeRouterMintPayload`
|
|
58
|
+
* @returns Receipt badge mint tuple in router/storage shape
|
|
59
|
+
*/
|
|
60
|
+
export declare function receiptBadgeMintPayloadFromPaymentIntent(identityContract: Address, paymentIntent: PaymentIntent, blockNumber: bigint, receiptType: ReceiptType): ReceiptBadgeMintPayload;
|
|
61
|
+
/**
|
|
62
|
+
* Deterministic receipt badge id for a payment intent (matches on-chain `CashieReceiptBadge.mint`).
|
|
63
|
+
*
|
|
64
|
+
* @param identityContract `CashieIdentitySoul` address
|
|
65
|
+
* @param paymentIntent Payment fields and mint salt
|
|
66
|
+
* @param blockNumber Execution block (`block.number` at mint)
|
|
67
|
+
* @param receiptType Receipt badge type from `ReceiptBadgeRouterMintPayload`
|
|
68
|
+
* @returns Deterministic receipt badge id
|
|
69
|
+
*/
|
|
70
|
+
export declare function receiptBadgeIdFromPaymentIntent(identityContract: Address, paymentIntent: PaymentIntent, blockNumber: bigint, receiptType: ReceiptType): bigint;
|
|
71
|
+
/**
|
|
72
|
+
* Fields ABI-encoded in the same order as `PaymentRecordBadgeEncoderLib.encodeMintPayload`
|
|
73
|
+
* (`packages/contracts/src/identity/libraries/PaymentRecordBadgeEncoderLib.sol`).
|
|
74
|
+
*/
|
|
75
|
+
export type PaymentRecordBadgeMintPayload = {
|
|
76
|
+
soulBoundTo: {
|
|
77
|
+
identityContract: Address;
|
|
78
|
+
tokenId: bigint;
|
|
79
|
+
};
|
|
80
|
+
blockNumber: bigint;
|
|
81
|
+
payer: Address;
|
|
82
|
+
chainId: bigint;
|
|
83
|
+
tokenAddress: Address;
|
|
84
|
+
allowance: bigint;
|
|
85
|
+
receiptBadgeId: bigint;
|
|
86
|
+
/** `bytes32` salt (`0x` + 64 hex chars). */
|
|
87
|
+
salt: Hex;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Canonical `abi.encode` of `PaymentRecordBadgeMintPayload` (matches Solidity `PaymentRecordBadgeEncoderLib.encodeMintPayload`).
|
|
91
|
+
*
|
|
92
|
+
* @param payload Mint tuple fields in router/storage shape
|
|
93
|
+
* @returns ABI-encoded bytes as hex
|
|
94
|
+
*/
|
|
95
|
+
export declare function encodePaymentRecordBadgeMintPayload(payload: PaymentRecordBadgeMintPayload): Hex;
|
|
96
|
+
/**
|
|
97
|
+
* `keccak256(encodePaymentRecordBadgeMintPayload(payload))` — matches `PaymentRecordBadgeEncoderLib.getMintPayloadHash`.
|
|
98
|
+
* On-chain `badgeId == uint256(bytes32 digest)`.
|
|
99
|
+
*
|
|
100
|
+
* @param payload Mint tuple fields in router/storage shape
|
|
101
|
+
* @returns 32-byte digest (`0x…`)
|
|
102
|
+
*/
|
|
103
|
+
export declare function getPaymentRecordBadgeMintPayloadHash(payload: PaymentRecordBadgeMintPayload): Hex;
|
|
104
|
+
/**
|
|
105
|
+
* Deterministic ERC-5114 badge id: `uint256(getPaymentRecordBadgeMintPayloadHash(payload))`.
|
|
106
|
+
*
|
|
107
|
+
* @param payload Mint tuple fields in router/storage shape
|
|
108
|
+
* @returns Badge id as bigint
|
|
109
|
+
*/
|
|
110
|
+
export declare function paymentRecordBadgeIdFromMintPayload(payload: PaymentRecordBadgeMintPayload): bigint;
|
|
111
|
+
/**
|
|
112
|
+
* Maps a {@link PaymentIntent} to {@link PaymentRecordBadgeMintPayload} (matches `TokenDistributor._issuePaymentRecordBadge`).
|
|
113
|
+
*
|
|
114
|
+
* @param identityContract `CashieIdentitySoul` address bound in `soulBoundTo`
|
|
115
|
+
* @param paymentIntent Payment fields and mint salt
|
|
116
|
+
* @param blockNumber Execution block (`block.number` at mint)
|
|
117
|
+
* @param receiptBadgeId Linked receipt badge id from the same payment
|
|
118
|
+
* @returns Payment record badge mint tuple in router/storage shape
|
|
119
|
+
*/
|
|
120
|
+
export declare function paymentRecordBadgeMintPayloadFromPaymentIntent(identityContract: Address, paymentIntent: PaymentIntent, blockNumber: bigint, receiptBadgeId: bigint): PaymentRecordBadgeMintPayload;
|
|
121
|
+
/**
|
|
122
|
+
* Deterministic payment record badge id for a payment intent (matches on-chain `CashiePaymentRecordBadge.mint`).
|
|
123
|
+
*
|
|
124
|
+
* @param identityContract `CashieIdentitySoul` address
|
|
125
|
+
* @param paymentIntent Payment fields and mint salt
|
|
126
|
+
* @param blockNumber Execution block (`block.number` at mint)
|
|
127
|
+
* @param receiptType Receipt badge type from `ReceiptBadgeRouterMintPayload`
|
|
128
|
+
* @returns Deterministic payment record badge id
|
|
129
|
+
*/
|
|
130
|
+
export declare function paymentRecordBadgeIdFromPaymentIntent(identityContract: Address, paymentIntent: PaymentIntent, blockNumber: bigint, receiptType: ReceiptType): bigint;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** Matches `MetadataEncodingPrimitives.JSON_DATA_URI_BASE64_PREFIX`. */
|
|
3
|
+
export declare const CASHIE_JSON_DATA_URI_BASE64_PREFIX: "data:application/json;base64,";
|
|
4
|
+
/** Matches `MetadataEncodingPrimitives` SVG data URI prefix (`svgMarkupToImageDataUri`). */
|
|
5
|
+
export declare const CASHIE_SVG_DATA_URI_BASE64_PREFIX: "data:image/svg+xml;base64,";
|
|
6
|
+
/**
|
|
7
|
+
* Matches `CashieReceiptBadge.metadataFormat()` (`_METADATA_FORMAT`).
|
|
8
|
+
* ERC-5114 JSON does not embed this string; compare against the contract when resolving badges.
|
|
9
|
+
*/
|
|
10
|
+
export declare const CASHIE_RECEIPT_BADGE_METADATA_FORMAT: "Cashie-ReceiptBadge-v1";
|
|
11
|
+
/**
|
|
12
|
+
* Matches `CashiePaymentRecordBadge.metadataFormat()` (`_METADATA_FORMAT`).
|
|
13
|
+
* ERC-5114 JSON does not embed this string; compare against the contract when resolving badges.
|
|
14
|
+
*/
|
|
15
|
+
export declare const CASHIE_PAYMENT_RECORD_BADGE_METADATA_FORMAT: "Cashie-PaymentRecordBadge-v1";
|
|
16
|
+
/**
|
|
17
|
+
* `identityType` strings emitted by `IdentitySoulMetadataEncoderLib` — parallel to {@link IdentityType} ordinals.
|
|
18
|
+
*/
|
|
19
|
+
export declare const cashieIdentitySoulIdentityTypeJsonSchema: z.ZodEnum<{
|
|
20
|
+
Individual: "Individual";
|
|
21
|
+
Business: "Business";
|
|
22
|
+
}>;
|
|
23
|
+
/** Map JSON `identityType` labels to {@link IdentityType} values used in EIP-712 / structs. */
|
|
24
|
+
export declare const JSON_IDENTITY_TYPE_LABEL_TO_IDENTITY_TYPE: {
|
|
25
|
+
readonly Individual: 0;
|
|
26
|
+
readonly Business: 1;
|
|
27
|
+
};
|
|
28
|
+
/** Non-empty `0x` hex (addresses, arbitrary commitment bytes on-chain). */
|
|
29
|
+
export declare const hex0xSchema: z.ZodString;
|
|
30
|
+
/** `bytes32` serialized like Solidity `Strings.toHexString(..., 32)`. */
|
|
31
|
+
export declare const bytes32HexSchema: z.ZodString;
|
|
32
|
+
export declare const cashieReceiptBadgeSoulBoundToSchema: z.ZodObject<{
|
|
33
|
+
identityContract: z.ZodString;
|
|
34
|
+
tokenId: z.ZodString;
|
|
35
|
+
}, z.core.$strict>;
|
|
36
|
+
/** EIP-721 JSON from `ReceiptBadgeMetadataEncoderLib`. */
|
|
37
|
+
export declare const cashieReceiptBadgeMetadataSchema: z.ZodObject<{
|
|
38
|
+
name: z.ZodString;
|
|
39
|
+
description: z.ZodString;
|
|
40
|
+
image: z.ZodString;
|
|
41
|
+
soulBoundTo: z.ZodObject<{
|
|
42
|
+
identityContract: z.ZodString;
|
|
43
|
+
tokenId: z.ZodString;
|
|
44
|
+
}, z.core.$strict>;
|
|
45
|
+
receiptType: z.ZodEnum<{
|
|
46
|
+
OneTime: "OneTime";
|
|
47
|
+
Recurring: "Recurring";
|
|
48
|
+
}>;
|
|
49
|
+
blockNumber: z.ZodString;
|
|
50
|
+
recipient: z.ZodString;
|
|
51
|
+
chainId: z.ZodString;
|
|
52
|
+
tokenAddress: z.ZodString;
|
|
53
|
+
allowance: z.ZodString;
|
|
54
|
+
salt: z.ZodString;
|
|
55
|
+
}, z.core.$strict>;
|
|
56
|
+
/** EIP-721 JSON from `PaymentRecordBadgeMetadataEncoderLib`. */
|
|
57
|
+
export declare const cashiePaymentRecordBadgeMetadataSchema: z.ZodObject<{
|
|
58
|
+
name: z.ZodString;
|
|
59
|
+
description: z.ZodString;
|
|
60
|
+
image: z.ZodString;
|
|
61
|
+
soulBoundTo: z.ZodObject<{
|
|
62
|
+
identityContract: z.ZodString;
|
|
63
|
+
tokenId: z.ZodString;
|
|
64
|
+
}, z.core.$strict>;
|
|
65
|
+
blockNumber: z.ZodString;
|
|
66
|
+
payer: z.ZodString;
|
|
67
|
+
chainId: z.ZodString;
|
|
68
|
+
tokenAddress: z.ZodString;
|
|
69
|
+
allowance: z.ZodString;
|
|
70
|
+
receiptBadgeId: z.ZodString;
|
|
71
|
+
salt: z.ZodString;
|
|
72
|
+
}, z.core.$strict>;
|
|
73
|
+
/**
|
|
74
|
+
* EIP-721 JSON from `IdentitySoulMetadataEncoderLib` (on-chain wire format).
|
|
75
|
+
* Use `.parse()` on decoded token URI JSON.
|
|
76
|
+
*/
|
|
77
|
+
export declare const cashieIdentitySoulTokenMetadataJsonSchema: z.ZodObject<{
|
|
78
|
+
name: z.ZodString;
|
|
79
|
+
description: z.ZodString;
|
|
80
|
+
image: z.ZodString;
|
|
81
|
+
identityType: z.ZodPipe<z.ZodEnum<{
|
|
82
|
+
Individual: "Individual";
|
|
83
|
+
Business: "Business";
|
|
84
|
+
}>, z.ZodTransform<0 | 1, "Individual" | "Business">>;
|
|
85
|
+
domain: z.ZodString;
|
|
86
|
+
burnAuth: z.ZodPipe<z.ZodString, z.ZodTransform<0 | 1 | 2 | 3, string>>;
|
|
87
|
+
identityCommitment: z.ZodString;
|
|
88
|
+
}, z.core.$strict>;
|
|
89
|
+
/**
|
|
90
|
+
* Parsed identity soul metadata (`IdentityType` / `BurnAuth` ordinals).
|
|
91
|
+
*/
|
|
92
|
+
export declare const cashieIdentitySoulTokenMetadataSchema: z.ZodObject<{
|
|
93
|
+
name: z.ZodString;
|
|
94
|
+
description: z.ZodString;
|
|
95
|
+
image: z.ZodString;
|
|
96
|
+
identityType: z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodLiteral<1>]>;
|
|
97
|
+
domain: z.ZodString;
|
|
98
|
+
burnAuth: z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>]>;
|
|
99
|
+
identityCommitment: z.ZodString;
|
|
100
|
+
}, z.core.$strict>;
|
|
101
|
+
export type CashieReceiptBadgeSoulBoundTo = z.infer<typeof cashieReceiptBadgeSoulBoundToSchema>;
|
|
102
|
+
export type CashieReceiptBadgeMetadata = z.infer<typeof cashieReceiptBadgeMetadataSchema>;
|
|
103
|
+
export type CashiePaymentRecordBadgeMetadata = z.infer<typeof cashiePaymentRecordBadgeMetadataSchema>;
|
|
104
|
+
export type CashieIdentitySoulTokenMetadata = z.infer<typeof cashieIdentitySoulTokenMetadataSchema>;
|
|
105
|
+
export type ParsedCashieMetadata = {
|
|
106
|
+
kind: 'identitySoul';
|
|
107
|
+
data: CashieIdentitySoulTokenMetadata;
|
|
108
|
+
} | {
|
|
109
|
+
kind: 'receiptBadge';
|
|
110
|
+
format: typeof CASHIE_RECEIPT_BADGE_METADATA_FORMAT;
|
|
111
|
+
data: CashieReceiptBadgeMetadata;
|
|
112
|
+
} | {
|
|
113
|
+
kind: 'paymentRecordBadge';
|
|
114
|
+
format: typeof CASHIE_PAYMENT_RECORD_BADGE_METADATA_FORMAT;
|
|
115
|
+
data: CashiePaymentRecordBadgeMetadata;
|
|
116
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const addressSchema: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
3
|
+
export declare const hexSchema: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
4
|
+
export declare const baseScopeSchema: z.ZodObject<{
|
|
5
|
+
type: z.ZodString;
|
|
6
|
+
isAdjustmentAllowed: z.ZodBoolean;
|
|
7
|
+
justification: z.ZodString;
|
|
8
|
+
data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
9
|
+
}, z.core.$strict>;
|
|
10
|
+
/**
|
|
11
|
+
* A custom error class for ERC-7715 validation errors.
|
|
12
|
+
*/
|
|
13
|
+
export declare class ERC7715ValidationError extends Error {
|
|
14
|
+
readonly schemaName: string;
|
|
15
|
+
readonly zodError: z.ZodError;
|
|
16
|
+
constructor(schemaName: string, zodError: z.ZodError);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Parses a value with a given schema and throws an error if the value is invalid.
|
|
20
|
+
*
|
|
21
|
+
* @param schemaName - The name of the schema
|
|
22
|
+
* @param schema - The schema to parse the value with
|
|
23
|
+
* @param value - The value to parse
|
|
24
|
+
* @returns The parsed value
|
|
25
|
+
*/
|
|
26
|
+
export declare function parseWithSchema<TSchema extends z.ZodType>(schemaName: string, schema: TSchema, value: unknown): z.output<TSchema>;
|
|
27
|
+
/**
|
|
28
|
+
* A base scope type that all scopes must inherit from.
|
|
29
|
+
*/
|
|
30
|
+
export type BaseScopeSchema = z.infer<typeof baseScopeSchema>;
|
|
31
|
+
/**
|
|
32
|
+
* Parses a base scope schema and throws an error if the value is invalid.
|
|
33
|
+
*
|
|
34
|
+
* @param scope - The scope to parse
|
|
35
|
+
* @returns The parsed base scope schema
|
|
36
|
+
*/
|
|
37
|
+
export declare function parseBaseScopeSchema(scope: unknown): BaseScopeSchema;
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { RewardItem } from '../../intent/index.js';
|
|
3
|
+
import type { BillingPeriod, ERC20TokenPaymentPermission, PaymentDetailsType, PaymentDetailsTypeMapping, Permission } from './types.js';
|
|
4
|
+
export declare const billingPeriodSchema: z.ZodEnum<{
|
|
5
|
+
weekly: "weekly";
|
|
6
|
+
monthly: "monthly";
|
|
7
|
+
annually: "annually";
|
|
8
|
+
}>;
|
|
9
|
+
export declare const paymentDetailsTypeSchema: z.ZodEnum<{
|
|
10
|
+
single: "single";
|
|
11
|
+
recurring: "recurring";
|
|
12
|
+
}>;
|
|
13
|
+
export declare const rewardItemSchema: z.ZodType<RewardItem>;
|
|
14
|
+
export declare const basePaymentDetailsDataSchema: z.ZodObject<{
|
|
15
|
+
allowance: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
16
|
+
tokenAddress: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
17
|
+
rewardItems: z.ZodOptional<z.ZodArray<z.ZodType<RewardItem, unknown, z.core.$ZodTypeInternals<RewardItem, unknown>>>>;
|
|
18
|
+
}, z.core.$strict>;
|
|
19
|
+
export declare const singlePaymentDetailsSchema: z.ZodObject<{
|
|
20
|
+
allowance: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
21
|
+
tokenAddress: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
22
|
+
rewardItems: z.ZodOptional<z.ZodArray<z.ZodType<RewardItem, unknown, z.core.$ZodTypeInternals<RewardItem, unknown>>>>;
|
|
23
|
+
type: z.ZodLiteral<"single">;
|
|
24
|
+
}, z.core.$strict>;
|
|
25
|
+
export declare const recurringPaymentDetailsSchema: z.ZodObject<{
|
|
26
|
+
allowance: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
27
|
+
tokenAddress: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
28
|
+
rewardItems: z.ZodOptional<z.ZodArray<z.ZodType<RewardItem, unknown, z.core.$ZodTypeInternals<RewardItem, unknown>>>>;
|
|
29
|
+
type: z.ZodLiteral<"recurring">;
|
|
30
|
+
startDate: z.ZodOptional<z.ZodNumber>;
|
|
31
|
+
billingPeriod: z.ZodEnum<{
|
|
32
|
+
weekly: "weekly";
|
|
33
|
+
monthly: "monthly";
|
|
34
|
+
annually: "annually";
|
|
35
|
+
}>;
|
|
36
|
+
}, z.core.$strict>;
|
|
37
|
+
export declare const paymentDetailsSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
38
|
+
allowance: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
39
|
+
tokenAddress: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
40
|
+
rewardItems: z.ZodOptional<z.ZodArray<z.ZodType<RewardItem, unknown, z.core.$ZodTypeInternals<RewardItem, unknown>>>>;
|
|
41
|
+
type: z.ZodLiteral<"single">;
|
|
42
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
43
|
+
allowance: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
44
|
+
tokenAddress: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
45
|
+
rewardItems: z.ZodOptional<z.ZodArray<z.ZodType<RewardItem, unknown, z.core.$ZodTypeInternals<RewardItem, unknown>>>>;
|
|
46
|
+
type: z.ZodLiteral<"recurring">;
|
|
47
|
+
startDate: z.ZodOptional<z.ZodNumber>;
|
|
48
|
+
billingPeriod: z.ZodEnum<{
|
|
49
|
+
weekly: "weekly";
|
|
50
|
+
monthly: "monthly";
|
|
51
|
+
annually: "annually";
|
|
52
|
+
}>;
|
|
53
|
+
}, z.core.$strict>], "type">;
|
|
54
|
+
export declare const erc20TokenPaymentPermissionSchema: z.ZodObject<{
|
|
55
|
+
isAdjustmentAllowed: z.ZodBoolean;
|
|
56
|
+
justification: z.ZodString;
|
|
57
|
+
type: z.ZodLiteral<"erc20-token-payment">;
|
|
58
|
+
data: z.ZodObject<{
|
|
59
|
+
recipient: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
60
|
+
paymentDetails: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
61
|
+
allowance: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
62
|
+
tokenAddress: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
63
|
+
rewardItems: z.ZodOptional<z.ZodArray<z.ZodType<RewardItem, unknown, z.core.$ZodTypeInternals<RewardItem, unknown>>>>;
|
|
64
|
+
type: z.ZodLiteral<"single">;
|
|
65
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
66
|
+
allowance: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
67
|
+
tokenAddress: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
68
|
+
rewardItems: z.ZodOptional<z.ZodArray<z.ZodType<RewardItem, unknown, z.core.$ZodTypeInternals<RewardItem, unknown>>>>;
|
|
69
|
+
type: z.ZodLiteral<"recurring">;
|
|
70
|
+
startDate: z.ZodOptional<z.ZodNumber>;
|
|
71
|
+
billingPeriod: z.ZodEnum<{
|
|
72
|
+
weekly: "weekly";
|
|
73
|
+
monthly: "monthly";
|
|
74
|
+
annually: "annually";
|
|
75
|
+
}>;
|
|
76
|
+
}, z.core.$strict>], "type">;
|
|
77
|
+
}, z.core.$strict>;
|
|
78
|
+
}, z.core.$strict>;
|
|
79
|
+
export declare const permissionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
80
|
+
isAdjustmentAllowed: z.ZodBoolean;
|
|
81
|
+
justification: z.ZodString;
|
|
82
|
+
type: z.ZodLiteral<"erc20-token-payment">;
|
|
83
|
+
data: z.ZodObject<{
|
|
84
|
+
recipient: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
85
|
+
paymentDetails: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
86
|
+
allowance: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
87
|
+
tokenAddress: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
88
|
+
rewardItems: z.ZodOptional<z.ZodArray<z.ZodType<RewardItem, unknown, z.core.$ZodTypeInternals<RewardItem, unknown>>>>;
|
|
89
|
+
type: z.ZodLiteral<"single">;
|
|
90
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
91
|
+
allowance: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
92
|
+
tokenAddress: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
93
|
+
rewardItems: z.ZodOptional<z.ZodArray<z.ZodType<RewardItem, unknown, z.core.$ZodTypeInternals<RewardItem, unknown>>>>;
|
|
94
|
+
type: z.ZodLiteral<"recurring">;
|
|
95
|
+
startDate: z.ZodOptional<z.ZodNumber>;
|
|
96
|
+
billingPeriod: z.ZodEnum<{
|
|
97
|
+
weekly: "weekly";
|
|
98
|
+
monthly: "monthly";
|
|
99
|
+
annually: "annually";
|
|
100
|
+
}>;
|
|
101
|
+
}, z.core.$strict>], "type">;
|
|
102
|
+
}, z.core.$strict>;
|
|
103
|
+
}, z.core.$strict>], "type">;
|
|
104
|
+
export declare const permissionSchemas: {
|
|
105
|
+
'erc20-token-payment': z.ZodObject<{
|
|
106
|
+
isAdjustmentAllowed: z.ZodBoolean;
|
|
107
|
+
justification: z.ZodString;
|
|
108
|
+
type: z.ZodLiteral<"erc20-token-payment">;
|
|
109
|
+
data: z.ZodObject<{
|
|
110
|
+
recipient: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
111
|
+
paymentDetails: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
112
|
+
allowance: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
113
|
+
tokenAddress: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
114
|
+
rewardItems: z.ZodOptional<z.ZodArray<z.ZodType<RewardItem, unknown, z.core.$ZodTypeInternals<RewardItem, unknown>>>>;
|
|
115
|
+
type: z.ZodLiteral<"single">;
|
|
116
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
117
|
+
allowance: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
118
|
+
tokenAddress: z.ZodCustom<`0x${string}`, `0x${string}`>;
|
|
119
|
+
rewardItems: z.ZodOptional<z.ZodArray<z.ZodType<RewardItem, unknown, z.core.$ZodTypeInternals<RewardItem, unknown>>>>;
|
|
120
|
+
type: z.ZodLiteral<"recurring">;
|
|
121
|
+
startDate: z.ZodOptional<z.ZodNumber>;
|
|
122
|
+
billingPeriod: z.ZodEnum<{
|
|
123
|
+
weekly: "weekly";
|
|
124
|
+
monthly: "monthly";
|
|
125
|
+
annually: "annually";
|
|
126
|
+
}>;
|
|
127
|
+
}, z.core.$strict>], "type">;
|
|
128
|
+
}, z.core.$strict>;
|
|
129
|
+
}, z.core.$strict>;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* Parses a billing period.
|
|
133
|
+
*
|
|
134
|
+
* @param value - The value to parse.
|
|
135
|
+
* @returns The parsed billing period.
|
|
136
|
+
*/
|
|
137
|
+
export declare function parseBillingPeriod(value: unknown): BillingPeriod;
|
|
138
|
+
/**
|
|
139
|
+
* Parses a payment details type.
|
|
140
|
+
*
|
|
141
|
+
* @param value - The value to parse.
|
|
142
|
+
* @returns The parsed payment details type.
|
|
143
|
+
*/
|
|
144
|
+
export declare function parsePaymentDetailsType(value: unknown): PaymentDetailsType;
|
|
145
|
+
/**
|
|
146
|
+
* Parses a base payment details data.
|
|
147
|
+
*
|
|
148
|
+
* @param value - The value to parse.
|
|
149
|
+
* @returns The parsed base payment details data.
|
|
150
|
+
*/
|
|
151
|
+
export declare function parseBasePaymentDetailsData(value: unknown): z.infer<typeof basePaymentDetailsDataSchema>;
|
|
152
|
+
/**
|
|
153
|
+
* Parses a payment details.
|
|
154
|
+
*
|
|
155
|
+
* @param value - The value to parse.
|
|
156
|
+
* @returns The parsed payment details.
|
|
157
|
+
*/
|
|
158
|
+
export declare function parsePaymentDetails<T extends PaymentDetailsType>(value: unknown): PaymentDetailsTypeMapping[T];
|
|
159
|
+
/**
|
|
160
|
+
* Parses an ERC20 token payment permission.
|
|
161
|
+
*
|
|
162
|
+
* @param value - The value to parse.
|
|
163
|
+
* @returns The parsed ERC20 token payment permission.
|
|
164
|
+
*/
|
|
165
|
+
export declare function parseERC20TokenPaymentPermission(value: unknown): ERC20TokenPaymentPermission;
|
|
166
|
+
/**
|
|
167
|
+
* Parses a permission.
|
|
168
|
+
*
|
|
169
|
+
* @param value - The value to parse.
|
|
170
|
+
* @returns The parsed permission.
|
|
171
|
+
*/
|
|
172
|
+
export declare function parsePermission(value: unknown): Permission;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { basePaymentDetailsDataSchema, billingPeriodSchema, erc20TokenPaymentPermissionSchema, paymentDetailsTypeSchema, recurringPaymentDetailsSchema, singlePaymentDetailsSchema } from './schemas.js';
|
|
3
|
+
export type BasePaymentDetailsData = z.infer<typeof basePaymentDetailsDataSchema>;
|
|
4
|
+
export type BillingPeriod = z.infer<typeof billingPeriodSchema>;
|
|
5
|
+
export type PaymentDetailsTypeMapping = {
|
|
6
|
+
single: z.infer<typeof singlePaymentDetailsSchema>;
|
|
7
|
+
recurring: z.infer<typeof recurringPaymentDetailsSchema>;
|
|
8
|
+
};
|
|
9
|
+
export type PaymentDetailsType = z.infer<typeof paymentDetailsTypeSchema>;
|
|
10
|
+
/**
|
|
11
|
+
* A permission to make a payment using an ERC20 token.
|
|
12
|
+
*/
|
|
13
|
+
export type ERC20TokenPaymentPermission = z.infer<typeof erc20TokenPaymentPermissionSchema>;
|
|
14
|
+
/**
|
|
15
|
+
* A mapping of permission types to their corresponding permission schemas.
|
|
16
|
+
*/
|
|
17
|
+
export type PermissionTypeMapping = {
|
|
18
|
+
'erc20-token-payment': ERC20TokenPaymentPermission;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* A type that represents the different types of permissions.
|
|
22
|
+
*/
|
|
23
|
+
export type SupportedPermissionTypes = keyof PermissionTypeMapping;
|
|
24
|
+
/**
|
|
25
|
+
* A type that represents a permission.
|
|
26
|
+
*/
|
|
27
|
+
export type Permission<TPermission extends SupportedPermissionTypes = SupportedPermissionTypes> = PermissionTypeMapping[TPermission];
|