@pafi-dev/core 0.9.6 → 0.13.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 (43) hide show
  1. package/README.md +146 -188
  2. package/dist/abi/index.cjs +2 -2
  3. package/dist/abi/index.cjs.map +1 -1
  4. package/dist/abi/index.d.cts +58 -106
  5. package/dist/abi/index.d.ts +58 -106
  6. package/dist/abi/index.js +3 -3
  7. package/dist/{chunk-Y5EYH2SQ.js → chunk-H3X3FYUU.js} +1 -10
  8. package/dist/chunk-H3X3FYUU.js.map +1 -0
  9. package/dist/{chunk-5NEAI2BH.cjs → chunk-NT2ZPF72.cjs} +50 -72
  10. package/dist/chunk-NT2ZPF72.cjs.map +1 -0
  11. package/dist/{chunk-BNO5SM25.cjs → chunk-TRYGIC2I.cjs} +2 -11
  12. package/dist/chunk-TRYGIC2I.cjs.map +1 -0
  13. package/dist/{chunk-HJYHGCMT.js → chunk-UEO4YN6T.js} +53 -75
  14. package/dist/chunk-UEO4YN6T.js.map +1 -0
  15. package/dist/{chunk-MIQA46E3.cjs → chunk-XXLIIWIF.cjs} +45 -53
  16. package/dist/chunk-XXLIIWIF.cjs.map +1 -0
  17. package/dist/{chunk-CWH4KOUW.js → chunk-ZJXXCG5P.js} +45 -53
  18. package/dist/chunk-ZJXXCG5P.js.map +1 -0
  19. package/dist/contract/index.cjs +2 -4
  20. package/dist/contract/index.cjs.map +1 -1
  21. package/dist/contract/index.d.cts +5 -15
  22. package/dist/contract/index.d.ts +5 -15
  23. package/dist/contract/index.js +1 -3
  24. package/dist/eip712/index.cjs +2 -8
  25. package/dist/eip712/index.cjs.map +1 -1
  26. package/dist/eip712/index.d.cts +29 -43
  27. package/dist/eip712/index.d.ts +29 -43
  28. package/dist/eip712/index.js +3 -9
  29. package/dist/index.cjs +141 -158
  30. package/dist/index.cjs.map +1 -1
  31. package/dist/index.d.cts +201 -182
  32. package/dist/index.d.ts +201 -182
  33. package/dist/index.js +135 -152
  34. package/dist/index.js.map +1 -1
  35. package/dist/{types-DWLZNgcw.d.cts → types-C17pznGz.d.cts} +72 -30
  36. package/dist/{types-DWLZNgcw.d.ts → types-C17pznGz.d.ts} +72 -30
  37. package/package.json +15 -5
  38. package/dist/chunk-5NEAI2BH.cjs.map +0 -1
  39. package/dist/chunk-BNO5SM25.cjs.map +0 -1
  40. package/dist/chunk-CWH4KOUW.js.map +0 -1
  41. package/dist/chunk-HJYHGCMT.js.map +0 -1
  42. package/dist/chunk-MIQA46E3.cjs.map +0 -1
  43. package/dist/chunk-Y5EYH2SQ.js.map +0 -1
@@ -7,14 +7,13 @@ import {
7
7
  getMintRequestNonce,
8
8
  getPointTokenBalance,
9
9
  getPointTokenIssuer,
10
- getReceiverConsentNonce,
11
10
  getTokenCap,
12
11
  getTokenName,
13
12
  isActiveIssuer,
14
13
  isMinter,
15
14
  issuerRegistryGetIssuerFlatAbi,
16
15
  verifyMintCap
17
- } from "../chunk-Y5EYH2SQ.js";
16
+ } from "../chunk-H3X3FYUU.js";
18
17
  import "../chunk-LF5GIN5P.js";
19
18
  import "../chunk-UCO5DXD6.js";
20
19
  import "../chunk-DGUM43GV.js";
@@ -27,7 +26,6 @@ export {
27
26
  getPointTokenBalance,
28
27
  getPointTokenIssuer,
29
28
  getIssuer as getPointTokenIssuerAddress,
30
- getReceiverConsentNonce,
31
29
  getTokenCap,
32
30
  getTokenName,
33
31
  isActiveIssuer,
@@ -8,10 +8,7 @@
8
8
 
9
9
 
10
10
 
11
-
12
-
13
-
14
- var _chunk5NEAI2BHcjs = require('../chunk-5NEAI2BH.cjs');
11
+ var _chunkNT2ZPF72cjs = require('../chunk-NT2ZPF72.cjs');
15
12
  require('../chunk-KRHGFUDI.cjs');
16
13
  require('../chunk-JEQ2X3Z6.cjs');
17
14
 
@@ -24,8 +21,5 @@ require('../chunk-JEQ2X3Z6.cjs');
24
21
 
25
22
 
26
23
 
27
-
28
-
29
-
30
- exports.Eip712DomainMismatchError = _chunk5NEAI2BHcjs.Eip712DomainMismatchError; exports.assertDomainMatchesContract = _chunk5NEAI2BHcjs.assertDomainMatchesContract; exports.buildBurnRequestTypedData = _chunk5NEAI2BHcjs.buildBurnRequestTypedData; exports.buildDomain = _chunk5NEAI2BHcjs.buildDomain; exports.buildMintRequestTypedData = _chunk5NEAI2BHcjs.buildMintRequestTypedData; exports.buildReceiverConsentTypedData = _chunk5NEAI2BHcjs.buildReceiverConsentTypedData; exports.signBurnRequest = _chunk5NEAI2BHcjs.signBurnRequest; exports.signMintRequest = _chunk5NEAI2BHcjs.signMintRequest; exports.signReceiverConsent = _chunk5NEAI2BHcjs.signReceiverConsent; exports.verifyBurnRequest = _chunk5NEAI2BHcjs.verifyBurnRequest; exports.verifyMintRequest = _chunk5NEAI2BHcjs.verifyMintRequest; exports.verifyReceiverConsent = _chunk5NEAI2BHcjs.verifyReceiverConsent;
24
+ exports.Eip712DomainMismatchError = _chunkNT2ZPF72cjs.Eip712DomainMismatchError; exports.assertDomainMatchesContract = _chunkNT2ZPF72cjs.assertDomainMatchesContract; exports.buildBurnRequestTypedData = _chunkNT2ZPF72cjs.buildBurnRequestTypedData; exports.buildDomain = _chunkNT2ZPF72cjs.buildDomain; exports.buildMintRequestTypedData = _chunkNT2ZPF72cjs.buildMintRequestTypedData; exports.signBurnRequest = _chunkNT2ZPF72cjs.signBurnRequest; exports.signMintRequest = _chunkNT2ZPF72cjs.signMintRequest; exports.verifyBurnRequest = _chunkNT2ZPF72cjs.verifyBurnRequest; exports.verifyMintRequest = _chunkNT2ZPF72cjs.verifyMintRequest;
31
25
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/phitran/Pacific-Finance/pafi-backend/pafi-sdk/packages/core/dist/eip712/index.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,yDAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,+1BAAC","file":"/Users/phitran/Pacific-Finance/pafi-backend/pafi-sdk/packages/core/dist/eip712/index.cjs"}
1
+ {"version":3,"sources":["/Users/phitran/Pacific-Finance/pafi-backend/pafi-sdk/packages/core/dist/eip712/index.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,yDAA8B;AAC9B,iCAA8B;AAC9B,iCAA8B;AAC9B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wnBAAC","file":"/Users/phitran/Pacific-Finance/pafi-backend/pafi-sdk/packages/core/dist/eip712/index.cjs"}
@@ -1,5 +1,5 @@
1
1
  import { PublicClient, WalletClient, Hex, Address } from 'viem';
2
- import { b as PointTokenDomainConfig, M as MintRequest, E as EIP712Signature, S as SignatureVerification, d as BurnRequest, R as ReceiverConsent } from '../types-DWLZNgcw.cjs';
2
+ import { b as PointTokenDomainConfig, M as MintRequest, E as EIP712Signature, S as SignatureVerifyOptions, c as SignatureVerification, e as BurnRequest } from '../types-C17pznGz.cjs';
3
3
 
4
4
  /**
5
5
  * Build the EIP-712 domain struct from a PointToken config. Uses
@@ -49,7 +49,7 @@ declare class Eip712DomainMismatchError extends Error {
49
49
  declare function assertDomainMatchesContract(client: PublicClient, expected: ReturnType<typeof buildDomain>): Promise<void>;
50
50
 
51
51
  /**
52
- * Build the EIP-712 typed data object for a v1.6 MintForRequest.
52
+ * Build the EIP-712 typed data object for a MintForRequest.
53
53
  * Returns the standard `{ domain, types, primaryType, message }` structure
54
54
  * that any EIP-712 signer (viem, ethers, Privy, WalletConnect) can consume.
55
55
  */
@@ -82,7 +82,7 @@ declare function buildMintRequestTypedData(domain: PointTokenDomainConfig, messa
82
82
  message: MintRequest;
83
83
  };
84
84
  /**
85
- * Sign a v1.6 MintForRequest. Caller passes the full 5-field message:
85
+ * Sign a MintForRequest. Caller passes the full 5-field message:
86
86
  * - user = off-chain spender (drives nonce stream)
87
87
  * - receiver = on-chain caller (= msg.sender of `mint()`; wrapper or user)
88
88
  * - amount = PT amount
@@ -90,7 +90,27 @@ declare function buildMintRequestTypedData(domain: PointTokenDomainConfig, messa
90
90
  * - deadline = unix seconds
91
91
  */
92
92
  declare function signMintRequest(walletClient: WalletClient, domain: PointTokenDomainConfig, message: MintRequest): Promise<EIP712Signature>;
93
- declare function verifyMintRequest(domain: PointTokenDomainConfig, message: MintRequest, signature: Hex, expectedMinter: Address): Promise<SignatureVerification>;
93
+ /**
94
+ * Verify a MintForRequest signature. Always recovers the signer and
95
+ * compares against `expectedMinter`. Pass `options.currentTimeSec`
96
+ * (unix seconds) to additionally enforce the request's `deadline` —
97
+ * the on-chain contract enforces `block.timestamp <= deadline`, so
98
+ * a stale-but-cryptographically-valid sig will only revert
99
+ * on-submission unless the caller pre-flights here.
100
+ *
101
+ * Result shape:
102
+ * - `{ isValid: true, recoveredAddress }` — sig matches and (if
103
+ * deadline check requested) deadline has not elapsed.
104
+ * - `{ isValid: false, recoveredAddress, reason: 'INVALID_SIGNER' }`
105
+ * — sig does not recover to `expectedMinter`.
106
+ * - `{ isValid: false, recoveredAddress, reason: 'DEADLINE_PASSED' }`
107
+ * — sig is valid but `deadline < currentTimeSec`.
108
+ *
109
+ * Throws (synchronous Promise rejection):
110
+ * - When `options.currentTimeSec` is provided but not a finite,
111
+ * non-negative number. Misusing the API should fail loudly.
112
+ */
113
+ declare function verifyMintRequest(domain: PointTokenDomainConfig, message: MintRequest, signature: Hex, expectedMinter: Address, options?: SignatureVerifyOptions): Promise<SignatureVerification>;
94
114
 
95
115
  /**
96
116
  * EIP-712 helpers for `BurnRequest` — consumed by the sig-gated burn
@@ -132,45 +152,11 @@ declare function buildBurnRequestTypedData(domain: PointTokenDomainConfig, messa
132
152
  message: BurnRequest;
133
153
  };
134
154
  declare function signBurnRequest(walletClient: WalletClient, domain: PointTokenDomainConfig, message: BurnRequest): Promise<EIP712Signature>;
135
- declare function verifyBurnRequest(domain: PointTokenDomainConfig, message: BurnRequest, signature: Hex, expectedBurner: Address): Promise<SignatureVerification>;
136
-
137
155
  /**
138
- * Build the EIP-712 typed data object for a ReceiverConsent.
139
- * Returns the standard `{ domain, types, primaryType, message }` structure
140
- * that any EIP-712 signer (viem, ethers, Privy, WalletConnect) can consume.
156
+ * Verify a BurnRequest signature. Symmetric with `verifyMintRequest`:
157
+ * always recovers the signer; opt-in deadline check via
158
+ * `options.currentTimeSec`. See that helper for the full contract.
141
159
  */
142
- declare function buildReceiverConsentTypedData(domain: PointTokenDomainConfig, message: ReceiverConsent): {
143
- domain: {
144
- name: string;
145
- version: string;
146
- chainId: number;
147
- verifyingContract: `0x${string}`;
148
- };
149
- types: {
150
- readonly ReceiverConsent: readonly [{
151
- readonly name: "onBehalfOf";
152
- readonly type: "address";
153
- }, {
154
- readonly name: "originalReceiver";
155
- readonly type: "address";
156
- }, {
157
- readonly name: "amount";
158
- readonly type: "uint256";
159
- }, {
160
- readonly name: "nonce";
161
- readonly type: "uint256";
162
- }, {
163
- readonly name: "deadline";
164
- readonly type: "uint256";
165
- }, {
166
- readonly name: "extData";
167
- readonly type: "bytes";
168
- }];
169
- };
170
- primaryType: "ReceiverConsent";
171
- message: ReceiverConsent;
172
- };
173
- declare function signReceiverConsent(walletClient: WalletClient, domain: PointTokenDomainConfig, message: ReceiverConsent): Promise<EIP712Signature>;
174
- declare function verifyReceiverConsent(domain: PointTokenDomainConfig, message: ReceiverConsent, signature: Hex, expectedReceiver: Address): Promise<SignatureVerification>;
160
+ declare function verifyBurnRequest(domain: PointTokenDomainConfig, message: BurnRequest, signature: Hex, expectedBurner: Address, options?: SignatureVerifyOptions): Promise<SignatureVerification>;
175
161
 
176
- export { Eip712DomainMismatchError, assertDomainMatchesContract, buildBurnRequestTypedData, buildDomain, buildMintRequestTypedData, buildReceiverConsentTypedData, signBurnRequest, signMintRequest, signReceiverConsent, verifyBurnRequest, verifyMintRequest, verifyReceiverConsent };
162
+ export { Eip712DomainMismatchError, assertDomainMatchesContract, buildBurnRequestTypedData, buildDomain, buildMintRequestTypedData, signBurnRequest, signMintRequest, verifyBurnRequest, verifyMintRequest };
@@ -1,5 +1,5 @@
1
1
  import { PublicClient, WalletClient, Hex, Address } from 'viem';
2
- import { b as PointTokenDomainConfig, M as MintRequest, E as EIP712Signature, S as SignatureVerification, d as BurnRequest, R as ReceiverConsent } from '../types-DWLZNgcw.js';
2
+ import { b as PointTokenDomainConfig, M as MintRequest, E as EIP712Signature, S as SignatureVerifyOptions, c as SignatureVerification, e as BurnRequest } from '../types-C17pznGz.js';
3
3
 
4
4
  /**
5
5
  * Build the EIP-712 domain struct from a PointToken config. Uses
@@ -49,7 +49,7 @@ declare class Eip712DomainMismatchError extends Error {
49
49
  declare function assertDomainMatchesContract(client: PublicClient, expected: ReturnType<typeof buildDomain>): Promise<void>;
50
50
 
51
51
  /**
52
- * Build the EIP-712 typed data object for a v1.6 MintForRequest.
52
+ * Build the EIP-712 typed data object for a MintForRequest.
53
53
  * Returns the standard `{ domain, types, primaryType, message }` structure
54
54
  * that any EIP-712 signer (viem, ethers, Privy, WalletConnect) can consume.
55
55
  */
@@ -82,7 +82,7 @@ declare function buildMintRequestTypedData(domain: PointTokenDomainConfig, messa
82
82
  message: MintRequest;
83
83
  };
84
84
  /**
85
- * Sign a v1.6 MintForRequest. Caller passes the full 5-field message:
85
+ * Sign a MintForRequest. Caller passes the full 5-field message:
86
86
  * - user = off-chain spender (drives nonce stream)
87
87
  * - receiver = on-chain caller (= msg.sender of `mint()`; wrapper or user)
88
88
  * - amount = PT amount
@@ -90,7 +90,27 @@ declare function buildMintRequestTypedData(domain: PointTokenDomainConfig, messa
90
90
  * - deadline = unix seconds
91
91
  */
92
92
  declare function signMintRequest(walletClient: WalletClient, domain: PointTokenDomainConfig, message: MintRequest): Promise<EIP712Signature>;
93
- declare function verifyMintRequest(domain: PointTokenDomainConfig, message: MintRequest, signature: Hex, expectedMinter: Address): Promise<SignatureVerification>;
93
+ /**
94
+ * Verify a MintForRequest signature. Always recovers the signer and
95
+ * compares against `expectedMinter`. Pass `options.currentTimeSec`
96
+ * (unix seconds) to additionally enforce the request's `deadline` —
97
+ * the on-chain contract enforces `block.timestamp <= deadline`, so
98
+ * a stale-but-cryptographically-valid sig will only revert
99
+ * on-submission unless the caller pre-flights here.
100
+ *
101
+ * Result shape:
102
+ * - `{ isValid: true, recoveredAddress }` — sig matches and (if
103
+ * deadline check requested) deadline has not elapsed.
104
+ * - `{ isValid: false, recoveredAddress, reason: 'INVALID_SIGNER' }`
105
+ * — sig does not recover to `expectedMinter`.
106
+ * - `{ isValid: false, recoveredAddress, reason: 'DEADLINE_PASSED' }`
107
+ * — sig is valid but `deadline < currentTimeSec`.
108
+ *
109
+ * Throws (synchronous Promise rejection):
110
+ * - When `options.currentTimeSec` is provided but not a finite,
111
+ * non-negative number. Misusing the API should fail loudly.
112
+ */
113
+ declare function verifyMintRequest(domain: PointTokenDomainConfig, message: MintRequest, signature: Hex, expectedMinter: Address, options?: SignatureVerifyOptions): Promise<SignatureVerification>;
94
114
 
95
115
  /**
96
116
  * EIP-712 helpers for `BurnRequest` — consumed by the sig-gated burn
@@ -132,45 +152,11 @@ declare function buildBurnRequestTypedData(domain: PointTokenDomainConfig, messa
132
152
  message: BurnRequest;
133
153
  };
134
154
  declare function signBurnRequest(walletClient: WalletClient, domain: PointTokenDomainConfig, message: BurnRequest): Promise<EIP712Signature>;
135
- declare function verifyBurnRequest(domain: PointTokenDomainConfig, message: BurnRequest, signature: Hex, expectedBurner: Address): Promise<SignatureVerification>;
136
-
137
155
  /**
138
- * Build the EIP-712 typed data object for a ReceiverConsent.
139
- * Returns the standard `{ domain, types, primaryType, message }` structure
140
- * that any EIP-712 signer (viem, ethers, Privy, WalletConnect) can consume.
156
+ * Verify a BurnRequest signature. Symmetric with `verifyMintRequest`:
157
+ * always recovers the signer; opt-in deadline check via
158
+ * `options.currentTimeSec`. See that helper for the full contract.
141
159
  */
142
- declare function buildReceiverConsentTypedData(domain: PointTokenDomainConfig, message: ReceiverConsent): {
143
- domain: {
144
- name: string;
145
- version: string;
146
- chainId: number;
147
- verifyingContract: `0x${string}`;
148
- };
149
- types: {
150
- readonly ReceiverConsent: readonly [{
151
- readonly name: "onBehalfOf";
152
- readonly type: "address";
153
- }, {
154
- readonly name: "originalReceiver";
155
- readonly type: "address";
156
- }, {
157
- readonly name: "amount";
158
- readonly type: "uint256";
159
- }, {
160
- readonly name: "nonce";
161
- readonly type: "uint256";
162
- }, {
163
- readonly name: "deadline";
164
- readonly type: "uint256";
165
- }, {
166
- readonly name: "extData";
167
- readonly type: "bytes";
168
- }];
169
- };
170
- primaryType: "ReceiverConsent";
171
- message: ReceiverConsent;
172
- };
173
- declare function signReceiverConsent(walletClient: WalletClient, domain: PointTokenDomainConfig, message: ReceiverConsent): Promise<EIP712Signature>;
174
- declare function verifyReceiverConsent(domain: PointTokenDomainConfig, message: ReceiverConsent, signature: Hex, expectedReceiver: Address): Promise<SignatureVerification>;
160
+ declare function verifyBurnRequest(domain: PointTokenDomainConfig, message: BurnRequest, signature: Hex, expectedBurner: Address, options?: SignatureVerifyOptions): Promise<SignatureVerification>;
175
161
 
176
- export { Eip712DomainMismatchError, assertDomainMatchesContract, buildBurnRequestTypedData, buildDomain, buildMintRequestTypedData, buildReceiverConsentTypedData, signBurnRequest, signMintRequest, signReceiverConsent, verifyBurnRequest, verifyMintRequest, verifyReceiverConsent };
162
+ export { Eip712DomainMismatchError, assertDomainMatchesContract, buildBurnRequestTypedData, buildDomain, buildMintRequestTypedData, signBurnRequest, signMintRequest, verifyBurnRequest, verifyMintRequest };
@@ -4,14 +4,11 @@ import {
4
4
  buildBurnRequestTypedData,
5
5
  buildDomain,
6
6
  buildMintRequestTypedData,
7
- buildReceiverConsentTypedData,
8
7
  signBurnRequest,
9
8
  signMintRequest,
10
- signReceiverConsent,
11
9
  verifyBurnRequest,
12
- verifyMintRequest,
13
- verifyReceiverConsent
14
- } from "../chunk-HJYHGCMT.js";
10
+ verifyMintRequest
11
+ } from "../chunk-UEO4YN6T.js";
15
12
  import "../chunk-UCO5DXD6.js";
16
13
  import "../chunk-DGUM43GV.js";
17
14
  export {
@@ -20,12 +17,9 @@ export {
20
17
  buildBurnRequestTypedData,
21
18
  buildDomain,
22
19
  buildMintRequestTypedData,
23
- buildReceiverConsentTypedData,
24
20
  signBurnRequest,
25
21
  signMintRequest,
26
- signReceiverConsent,
27
22
  verifyBurnRequest,
28
- verifyMintRequest,
29
- verifyReceiverConsent
23
+ verifyMintRequest
30
24
  };
31
25
  //# sourceMappingURL=index.js.map