@pafi-dev/issuer 0.3.0-beta.2 → 0.3.0-beta.3

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/dist/index.cjs CHANGED
@@ -786,10 +786,20 @@ var RelayService = class {
786
786
  * - paymaster sponsorship (PAFI Backend)
787
787
  * - user signature (Privy)
788
788
  */
789
+ /**
790
+ * Build an unsigned UserOp for Scenario 1 (Mint) — direct
791
+ * `PointToken.mint(amount)` flow (v1.4 post-Relayer-removal).
792
+ *
793
+ * `msg.sender` inside the batch = user EOA via EIP-7702 delegation.
794
+ * `PointToken.mint` checks the caller is on its `minters` allowlist
795
+ * (gg56 BE pre-validates this off-chain to avoid wasted gas).
796
+ *
797
+ * Optional PT fee transfer is appended after the mint when
798
+ * `feeAmount > 0` — this is application-level fee recovery (no
799
+ * Relayer doing it for us). The user must end up with `amount - fee`
800
+ * net PT after the batch executes.
801
+ */
789
802
  prepareMint(params) {
790
- if (!params.relayerAddress) {
791
- throw new RelayError("ENCODE_FAILED", "prepareMint: relayerAddress required");
792
- }
793
803
  if (!params.batchExecutorAddress) {
794
804
  throw new RelayError(
795
805
  "ENCODE_FAILED",
@@ -799,36 +809,50 @@ var RelayService = class {
799
809
  if (!params.userAddress) {
800
810
  throw new RelayError("ENCODE_FAILED", "prepareMint: userAddress required");
801
811
  }
812
+ if (!params.pointTokenAddress) {
813
+ throw new RelayError(
814
+ "ENCODE_FAILED",
815
+ "prepareMint: pointTokenAddress required"
816
+ );
817
+ }
818
+ if (params.amount <= 0n) {
819
+ throw new RelayError("ENCODE_FAILED", "prepareMint: amount must be positive");
820
+ }
802
821
  let mintCallData;
803
822
  try {
804
823
  mintCallData = (0, import_viem5.encodeFunctionData)({
805
- abi: import_core3.RELAYER_V2_ABI,
824
+ abi: import_core3.POINT_TOKEN_V2_ABI,
806
825
  functionName: "mint",
807
- args: [params.mintRequest, params.userSignature, params.issuerSignature]
826
+ args: [params.amount]
808
827
  });
809
828
  } catch (err) {
810
829
  throw new RelayError(
811
830
  "ENCODE_FAILED",
812
- `prepareMint: failed to encode Relayer.mint: ${errorMessage(err)}`,
831
+ `prepareMint: failed to encode PointToken.mint: ${errorMessage(err)}`,
813
832
  err
814
833
  );
815
834
  }
816
835
  const operations = [
817
836
  {
818
- target: params.relayerAddress,
837
+ target: params.pointTokenAddress,
819
838
  value: 0n,
820
839
  data: mintCallData
821
840
  }
822
841
  ];
823
- if (params.mintRequest.feeAmount > 0n) {
842
+ if (params.feeAmount && params.feeAmount > 0n) {
843
+ if (!params.feeRecipient) {
844
+ throw new RelayError(
845
+ "ENCODE_FAILED",
846
+ "prepareMint: feeRecipient required when feeAmount > 0"
847
+ );
848
+ }
824
849
  operations.push({
825
850
  target: params.pointTokenAddress,
826
851
  value: 0n,
827
852
  data: (0, import_viem5.encodeFunctionData)({
828
- abi: import_core3.POINT_TOKEN_V2_ABI,
829
- functionName: "balanceOf",
830
- // placeholder — real impl uses transfer
831
- args: [params.mintRequest.feeRecipient]
853
+ abi: import_viem5.erc20Abi,
854
+ functionName: "transfer",
855
+ args: [params.feeRecipient, params.feeAmount]
832
856
  })
833
857
  });
834
858
  }
@@ -837,7 +861,7 @@ var RelayService = class {
837
861
  nonce: params.aaNonce,
838
862
  operations,
839
863
  gasLimits: {
840
- callGasLimit: params.callGasLimit ?? 500000n,
864
+ callGasLimit: params.callGasLimit ?? 300000n,
841
865
  verificationGasLimit: params.verificationGasLimit ?? 150000n,
842
866
  preVerificationGas: params.preVerificationGas ?? 50000n
843
867
  }