@trustvc/trustvc 2.14.1 → 2.15.0-beta.2

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 (38) hide show
  1. package/README.md +303 -0
  2. package/dist/cjs/eip7702-functions/deploy/index.js +19 -0
  3. package/dist/cjs/eip7702-functions/deploy/platform-paymaster.js +82 -0
  4. package/dist/cjs/eip7702-functions/deploy/token-registry.js +24 -0
  5. package/dist/cjs/eip7702-functions/index.js +31 -0
  6. package/dist/cjs/eip7702-functions/platform-paymaster-functions/admin.js +54 -0
  7. package/dist/cjs/eip7702-functions/platform-paymaster-functions/index.js +12 -0
  8. package/dist/cjs/eip7702-functions/token-registry-functions-gasless/index.js +33 -0
  9. package/dist/cjs/eip7702-functions/token-registry-functions-gasless/mint.js +32 -0
  10. package/dist/cjs/eip7702-functions/token-registry-functions-gasless/rejectTransfers.js +57 -0
  11. package/dist/cjs/eip7702-functions/token-registry-functions-gasless/returnToken.js +57 -0
  12. package/dist/cjs/eip7702-functions/token-registry-functions-gasless/transfer.js +77 -0
  13. package/dist/cjs/index.js +7 -0
  14. package/dist/esm/eip7702-functions/deploy/index.js +2 -0
  15. package/dist/esm/eip7702-functions/deploy/platform-paymaster.js +80 -0
  16. package/dist/esm/eip7702-functions/deploy/token-registry.js +22 -0
  17. package/dist/esm/eip7702-functions/index.js +4 -0
  18. package/dist/esm/eip7702-functions/platform-paymaster-functions/admin.js +44 -0
  19. package/dist/esm/eip7702-functions/platform-paymaster-functions/index.js +1 -0
  20. package/dist/esm/eip7702-functions/token-registry-functions-gasless/index.js +4 -0
  21. package/dist/esm/eip7702-functions/token-registry-functions-gasless/mint.js +30 -0
  22. package/dist/esm/eip7702-functions/token-registry-functions-gasless/rejectTransfers.js +53 -0
  23. package/dist/esm/eip7702-functions/token-registry-functions-gasless/returnToken.js +53 -0
  24. package/dist/esm/eip7702-functions/token-registry-functions-gasless/transfer.js +72 -0
  25. package/dist/esm/index.js +1 -0
  26. package/dist/types/eip7702-functions/deploy/index.d.ts +5 -0
  27. package/dist/types/eip7702-functions/deploy/platform-paymaster.d.ts +41 -0
  28. package/dist/types/eip7702-functions/deploy/token-registry.d.ts +34 -0
  29. package/dist/types/eip7702-functions/index.d.ts +15 -0
  30. package/dist/types/eip7702-functions/platform-paymaster-functions/admin.d.ts +82 -0
  31. package/dist/types/eip7702-functions/platform-paymaster-functions/index.d.ts +4 -0
  32. package/dist/types/eip7702-functions/token-registry-functions-gasless/index.d.ts +10 -0
  33. package/dist/types/eip7702-functions/token-registry-functions-gasless/mint.d.ts +35 -0
  34. package/dist/types/eip7702-functions/token-registry-functions-gasless/rejectTransfers.d.ts +46 -0
  35. package/dist/types/eip7702-functions/token-registry-functions-gasless/returnToken.d.ts +49 -0
  36. package/dist/types/eip7702-functions/token-registry-functions-gasless/transfer.d.ts +56 -0
  37. package/dist/types/index.d.ts +9 -0
  38. package/package.json +5 -2
package/README.md CHANGED
@@ -28,6 +28,15 @@ TrustVC is a comprehensive wrapper library designed to simplify the signing and
28
28
  - [8. **Document Builder**](#8-document-builder)
29
29
  - [9. **Document Store**](#9-document-store)
30
30
  - [10. **Transaction Cancel**](#10-transaction-cancel)
31
+ - [11. **Gasless Operations (EIP-7702)**](#11-gasless-operations-eip-7702)
32
+ - [Overview](#overview-1)
33
+ - [deployPlatformPaymaster](#deployplatformpaymaster)
34
+ - [deployTokenRegistryGasless](#deploytokenregistrygasless)
35
+ - [mintGasless](#mintgasless)
36
+ - [Transfer Functions](#transfer-functions)
37
+ - [Reject Transfer Functions](#reject-transfer-functions)
38
+ - [Return to Issuer Functions](#return-to-issuer-functions)
39
+ - [Admin Functions](#admin-functions)
31
40
 
32
41
  ## Installation
33
42
 
@@ -1203,3 +1212,297 @@ const replacementHash2 = await cancelTransaction(signer, {
1203
1212
  gasPrice: '25000000000', // 25 gwei in wei
1204
1213
  });
1205
1214
  ```
1215
+
1216
+ ---
1217
+
1218
+ ## 11. **Gasless Operations (EIP-7702)**
1219
+
1220
+ > **Beta:** Gasless transactions are currently in beta. APIs and contract addresses may change before the stable release. Use on testnet only.
1221
+
1222
+ ### Overview
1223
+
1224
+ TrustVC supports gasless trade document operations via **EIP-7702** (smart account delegation) and **ERC-4337** (account abstraction). Users can deploy token registries, mint documents, and perform all title escrow operations without holding ETH — gas is sponsored by a **PlatformPaymaster** deployed per platform.
1225
+
1226
+ **How it works:**
1227
+
1228
+ 1. An EOA signs an EIP-7702 authorization, delegating to the `EIP7702Implementation` contract. Its bytecode becomes `0xef0100 || impl_address` while keeping the same address and private key.
1229
+ 2. The platform deploys a `PlatformPaymaster` clone via `PlatformAccountFactory`.
1230
+ 3. Users submit `UserOperation`s through a bundler (Pimlico). The paymaster validates and sponsors gas for authorized operations.
1231
+
1232
+ All gasless functions accept a `smartAccountClient` built with [permissionless](https://docs.pimlico.io/permissionless) and return `Promise<string>` (transaction hash).
1233
+
1234
+ ```ts
1235
+ import { buildSmartAccountClient } from './your-pimlico-setup';
1236
+
1237
+ const { smartAccountClient } = await buildSmartAccountClient(
1238
+ ownerAddress, // delegated EOA
1239
+ paymasterAddress, // platform's PlatformPaymaster
1240
+ );
1241
+ ```
1242
+
1243
+ ---
1244
+
1245
+ ### deployPlatformPaymaster
1246
+
1247
+ Deploys a new `PlatformPaymaster` clone for your platform via `PlatformAccountFactory`. Accepts a viem `WalletClient` or ethers v5/v6 signer.
1248
+
1249
+ ```ts
1250
+ import { deployPlatformPaymaster } from '@trustvc/trustvc';
1251
+ import { createWalletClient, createPublicClient, http } from 'viem';
1252
+ import { sepolia } from 'viem/chains';
1253
+
1254
+ const { txHash, paymasterAddress } = await deployPlatformPaymaster(
1255
+ walletClient,
1256
+ {
1257
+ platformAddress: '0xYourPlatformOwner...',
1258
+ dailyLimit: 0n, // 0n = unlimited; set in wei to cap per-user daily spend
1259
+ salt: `0x${'ab'.repeat(32)}`, // bytes32 CREATE2 salt — must be unique per platform
1260
+ },
1261
+ publicClient,
1262
+ );
1263
+
1264
+ console.log('Paymaster deployed at:', paymasterAddress);
1265
+ ```
1266
+
1267
+ ---
1268
+
1269
+ ### deployTokenRegistryGasless
1270
+
1271
+ Deploys a new `TradeTrustToken` registry clone through the paymaster. The caller must have at least 1 deployment credit (`setUserWhitelist`). Emits `RegistryDeployed(user, deployed, creditsLeft)`.
1272
+
1273
+ ```ts
1274
+ import { deployTokenRegistryGasless } from '@trustvc/trustvc';
1275
+
1276
+ const txHash = await deployTokenRegistryGasless(
1277
+ 'My Shipping Line', // registry name
1278
+ 'MSL', // registry symbol
1279
+ smartAccountClient,
1280
+ {
1281
+ paymasterAddress: '0xYourPaymaster...',
1282
+ tokenRegistryImplAddress: '0x64bc665056DC8bE4092e569ED13a7F273Be28cD2', // TDocDeployer on Sepolia
1283
+ },
1284
+ );
1285
+ ```
1286
+
1287
+ ---
1288
+
1289
+ ### mintGasless
1290
+
1291
+ Mints a new trade document on an authorized registry. Automatically authorizes the beneficiary, holder, and the new `TitleEscrow` on the paymaster. Emits `TitleEscrowLinked(titleEscrow, registry)`.
1292
+
1293
+ ```ts
1294
+ import { mintGasless } from '@trustvc/trustvc';
1295
+
1296
+ const txHash = await mintGasless(
1297
+ {
1298
+ paymasterAddress: '0xYourPaymaster...',
1299
+ tokenRegistryAddress: '0xYourRegistry...',
1300
+ },
1301
+ smartAccountClient,
1302
+ {
1303
+ beneficiaryAddress: '0xBeneficiary...',
1304
+ holderAddress: '0xHolder...',
1305
+ tokenId: '0xdeadbeef',
1306
+ remarks: 'Initial issuance', // optional — encrypted on-chain with options.id
1307
+ },
1308
+ { id: 'document-uuid' },
1309
+ );
1310
+ ```
1311
+
1312
+ ---
1313
+
1314
+ ### Transfer Functions
1315
+
1316
+ All transfer functions target the `TitleEscrow` contract. Remarks are automatically encrypted with `options.id` before being sent on-chain.
1317
+
1318
+ #### transferHolderGasless
1319
+
1320
+ Transfers the **holder** role. Caller must be the current holder.
1321
+
1322
+ ```ts
1323
+ import { transferHolderGasless } from '@trustvc/trustvc';
1324
+
1325
+ const txHash = await transferHolderGasless(
1326
+ { titleEscrowAddress: '0xTitleEscrow...' },
1327
+ smartAccountClient,
1328
+ { holderAddress: '0xNewHolder...', remarks: 'Transferring to forwarder' },
1329
+ { id: 'document-uuid' },
1330
+ );
1331
+ ```
1332
+
1333
+ #### transferBeneficiaryGasless
1334
+
1335
+ Transfers the **beneficiary** role. Caller must be the current beneficiary.
1336
+
1337
+ ```ts
1338
+ import { transferBeneficiaryGasless } from '@trustvc/trustvc';
1339
+
1340
+ const txHash = await transferBeneficiaryGasless(
1341
+ { titleEscrowAddress: '0xTitleEscrow...' },
1342
+ smartAccountClient,
1343
+ { newBeneficiaryAddress: '0xNewBeneficiary...', remarks: 'Endorsing to buyer' },
1344
+ { id: 'document-uuid' },
1345
+ );
1346
+ ```
1347
+
1348
+ #### transferOwnersGasless
1349
+
1350
+ Transfers both holder and beneficiary in one transaction. Caller must be both.
1351
+
1352
+ ```ts
1353
+ import { transferOwnersGasless } from '@trustvc/trustvc';
1354
+
1355
+ const txHash = await transferOwnersGasless(
1356
+ { titleEscrowAddress: '0xTitleEscrow...' },
1357
+ smartAccountClient,
1358
+ {
1359
+ newBeneficiaryAddress: '0xNewBeneficiary...',
1360
+ newHolderAddress: '0xNewHolder...',
1361
+ remarks: 'Full transfer',
1362
+ },
1363
+ { id: 'document-uuid' },
1364
+ );
1365
+ ```
1366
+
1367
+ #### nominateGasless
1368
+
1369
+ Nominates a new beneficiary without immediately completing the transfer.
1370
+
1371
+ ```ts
1372
+ import { nominateGasless } from '@trustvc/trustvc';
1373
+
1374
+ const txHash = await nominateGasless(
1375
+ { titleEscrowAddress: '0xTitleEscrow...' },
1376
+ smartAccountClient,
1377
+ { newBeneficiaryAddress: '0xNominated...', remarks: 'Nomination' },
1378
+ { id: 'document-uuid' },
1379
+ );
1380
+ ```
1381
+
1382
+ ---
1383
+
1384
+ ### Reject Transfer Functions
1385
+
1386
+ Mirror of Token Registry v5's rejection methods — see [section 7](#b-token-registry-v5) for the on-chain rules.
1387
+
1388
+ ```ts
1389
+ import {
1390
+ rejectTransferHolderGasless,
1391
+ rejectTransferBeneficiaryGasless,
1392
+ rejectTransferOwnersGasless,
1393
+ } from '@trustvc/trustvc';
1394
+
1395
+ // Reject a pending holder transfer (caller = current holder)
1396
+ await rejectTransferHolderGasless(
1397
+ { titleEscrowAddress: '0xTitleEscrow...' },
1398
+ smartAccountClient,
1399
+ { remarks: 'Rejecting transfer' },
1400
+ { id: 'document-uuid' },
1401
+ );
1402
+
1403
+ // Reject a pending beneficiary nomination (caller = current beneficiary)
1404
+ await rejectTransferBeneficiaryGasless(
1405
+ { titleEscrowAddress: '0xTitleEscrow...' },
1406
+ smartAccountClient,
1407
+ { remarks: 'Rejecting nomination' },
1408
+ { id: 'document-uuid' },
1409
+ );
1410
+
1411
+ // Reject a combined transfer (caller = both holder and beneficiary)
1412
+ await rejectTransferOwnersGasless(
1413
+ { titleEscrowAddress: '0xTitleEscrow...' },
1414
+ smartAccountClient,
1415
+ { remarks: 'Rejecting combined transfer' },
1416
+ { id: 'document-uuid' },
1417
+ );
1418
+ ```
1419
+
1420
+ ---
1421
+
1422
+ ### Return to Issuer Functions
1423
+
1424
+ #### returnToIssuerGasless
1425
+
1426
+ Returns the document to the issuer. Caller must be both holder and beneficiary.
1427
+
1428
+ ```ts
1429
+ import { returnToIssuerGasless } from '@trustvc/trustvc';
1430
+
1431
+ await returnToIssuerGasless(
1432
+ { titleEscrowAddress: '0xTitleEscrow...' },
1433
+ smartAccountClient,
1434
+ { remarks: 'Surrendering document' },
1435
+ { id: 'document-uuid' },
1436
+ );
1437
+ ```
1438
+
1439
+ #### rejectReturnedGasless
1440
+
1441
+ Restores the document back to the title escrow (registry admin rejects the return).
1442
+
1443
+ ```ts
1444
+ import { rejectReturnedGasless } from '@trustvc/trustvc';
1445
+
1446
+ await rejectReturnedGasless(
1447
+ { tokenRegistryAddress: '0xYourRegistry...' },
1448
+ smartAccountClient,
1449
+ { tokenId: '0xdeadbeef', remarks: 'Return rejected' },
1450
+ { id: 'document-uuid' },
1451
+ );
1452
+ ```
1453
+
1454
+ #### acceptReturnedGasless
1455
+
1456
+ Burns the document (registry admin accepts the return).
1457
+
1458
+ ```ts
1459
+ import { acceptReturnedGasless } from '@trustvc/trustvc';
1460
+
1461
+ await acceptReturnedGasless(
1462
+ { tokenRegistryAddress: '0xYourRegistry...' },
1463
+ smartAccountClient,
1464
+ { tokenId: '0xdeadbeef', remarks: 'Document accepted and destroyed' },
1465
+ { id: 'document-uuid' },
1466
+ );
1467
+ ```
1468
+
1469
+ ---
1470
+
1471
+ ### Admin Functions
1472
+
1473
+ `onlyOwner` functions for managing the `PlatformPaymaster`. All accept a viem `WalletClient` or ethers v5/v6 signer and return `Promise<string>` (tx hash).
1474
+
1475
+ ```ts
1476
+ import {
1477
+ setUserWhitelist,
1478
+ removeUserFromWhitelist,
1479
+ addRegistry,
1480
+ removeRegistry,
1481
+ addTitleEscrow,
1482
+ removeTitleEscrow,
1483
+ addAuthorizedCaller,
1484
+ removeAuthorizedCaller,
1485
+ setDailyLimit,
1486
+ } from '@trustvc/trustvc';
1487
+
1488
+ // Grant a user 2 registry deployment credits (max 3)
1489
+ await setUserWhitelist(ownerSigner, paymasterAddress, '0xUser...', 2n);
1490
+
1491
+ // Remove a user from the whitelist
1492
+ await removeUserFromWhitelist(ownerSigner, paymasterAddress, '0xUser...');
1493
+
1494
+ // Authorize a registry so the paymaster will sponsor its calls
1495
+ await addRegistry(ownerSigner, paymasterAddress, '0xRegistry...');
1496
+ await removeRegistry(ownerSigner, paymasterAddress, '0xRegistry...');
1497
+
1498
+ // Authorize a title escrow
1499
+ await addTitleEscrow(ownerSigner, paymasterAddress, '0xTitleEscrow...');
1500
+ await removeTitleEscrow(ownerSigner, paymasterAddress, '0xTitleEscrow...');
1501
+
1502
+ // Manage authorized callers (beneficiary / holder addresses for Path A)
1503
+ await addAuthorizedCaller(ownerSigner, paymasterAddress, '0xCaller...');
1504
+ await removeAuthorizedCaller(ownerSigner, paymasterAddress, '0xCaller...');
1505
+
1506
+ // Update the per-user daily gas spend cap (0n = unlimited)
1507
+ await setDailyLimit(ownerSigner, paymasterAddress, 0n);
1508
+ ```
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ var platformPaymaster = require('./platform-paymaster');
4
+ var tokenRegistry = require('./token-registry');
5
+
6
+
7
+
8
+ Object.keys(platformPaymaster).forEach(function (k) {
9
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
10
+ enumerable: true,
11
+ get: function () { return platformPaymaster[k]; }
12
+ });
13
+ });
14
+ Object.keys(tokenRegistry).forEach(function (k) {
15
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
16
+ enumerable: true,
17
+ get: function () { return tokenRegistry[k]; }
18
+ });
19
+ });
@@ -0,0 +1,82 @@
1
+ 'use strict';
2
+
3
+ var viem = require('viem');
4
+ var eip7702 = require('@trustvc/eip7702');
5
+ var ethers = require('../../utils/ethers');
6
+
7
+ var __defProp = Object.defineProperty;
8
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
+ const deployPlatformPaymaster = /* @__PURE__ */ __name(async (signer, options, publicClient) => {
10
+ const { chainId = eip7702.constants.ChainId.Sepolia, dailyLimit = 0n, salt } = options;
11
+ const factoryAddress = options.factoryAddress ?? eip7702.constants.contractAddress.PlatformAccountFactory[chainId];
12
+ if (!factoryAddress) {
13
+ throw new Error(
14
+ `No PlatformAccountFactory address found for chainId ${chainId}. Supply factoryAddress in options.`
15
+ );
16
+ }
17
+ if ("writeContract" in signer) {
18
+ if (!publicClient) throw new Error("publicClient is required when signer is a WalletClient");
19
+ const platformAddress2 = options.platformAddress ?? signer.account?.address;
20
+ const txHash2 = await signer.writeContract({
21
+ address: factoryAddress,
22
+ abi: eip7702.abis.platformAccountFactoryAbi,
23
+ functionName: "deployPlatformPaymaster",
24
+ args: [platformAddress2, dailyLimit, salt],
25
+ chain: signer.chain,
26
+ account: signer.account
27
+ });
28
+ const receipt = await publicClient.waitForTransactionReceipt({ hash: txHash2 });
29
+ const logs2 = viem.parseEventLogs({
30
+ abi: eip7702.abis.platformAccountFactoryAbi,
31
+ logs: receipt.logs,
32
+ eventName: "PlatformOnboarded"
33
+ });
34
+ const paymasterAddress = logs2[0]?.args?.paymaster;
35
+ if (!paymasterAddress)
36
+ throw new Error("Deployment failed \u2014 PlatformOnboarded event not found in transaction logs");
37
+ return { txHash: txHash2, paymasterAddress };
38
+ }
39
+ const ethSigner = signer;
40
+ const platformAddress = options.platformAddress ?? await ethSigner.getAddress();
41
+ const Contract = ethers.getEthersContractFromProvider(ethSigner.provider);
42
+ const contract = new Contract(
43
+ factoryAddress,
44
+ eip7702.abis.platformAccountFactoryAbi,
45
+ ethSigner
46
+ // eslint-disable-line @typescript-eslint/no-explicit-any
47
+ );
48
+ const isV6 = ethers.isV6EthersProvider(ethSigner.provider);
49
+ let txHash;
50
+ let logs;
51
+ if (isV6) {
52
+ const tx = await contract.deployPlatformPaymaster(
53
+ platformAddress,
54
+ dailyLimit,
55
+ salt
56
+ );
57
+ const receipt = await tx.wait();
58
+ txHash = receipt.hash;
59
+ logs = receipt.logs;
60
+ } else {
61
+ const tx = await contract.deployPlatformPaymaster(
62
+ platformAddress,
63
+ dailyLimit,
64
+ salt
65
+ );
66
+ const receipt = await tx.wait();
67
+ txHash = receipt.transactionHash;
68
+ logs = receipt.logs;
69
+ }
70
+ for (const log of logs) {
71
+ try {
72
+ const parsed = contract.interface.parseLog(log);
73
+ if (parsed?.name === "PlatformOnboarded") {
74
+ return { txHash, paymasterAddress: parsed.args.paymaster };
75
+ }
76
+ } catch {
77
+ }
78
+ }
79
+ throw new Error("Deployment failed \u2014 PlatformOnboarded event not found in transaction logs");
80
+ }, "deployPlatformPaymaster");
81
+
82
+ exports.deployPlatformPaymaster = deployPlatformPaymaster;
@@ -0,0 +1,24 @@
1
+ 'use strict';
2
+
3
+ var viem = require('viem');
4
+ var eip7702 = require('@trustvc/eip7702');
5
+
6
+ var __defProp = Object.defineProperty;
7
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
+ const deployTokenRegistryGasless = /* @__PURE__ */ __name(async (registryName, registrySymbol, smartAccountClient, options) => {
9
+ const { paymasterAddress, tokenRegistryImplAddress } = options;
10
+ if (!paymasterAddress) throw new Error("paymasterAddress is required");
11
+ if (!tokenRegistryImplAddress) throw new Error("tokenRegistryImplAddress is required");
12
+ const data = viem.encodeFunctionData({
13
+ abi: eip7702.abis.platformPaymasterAbi,
14
+ functionName: "deployRegistry",
15
+ args: [tokenRegistryImplAddress, registryName, registrySymbol]
16
+ });
17
+ return smartAccountClient.sendTransaction({
18
+ to: paymasterAddress,
19
+ value: 0n,
20
+ data
21
+ });
22
+ }, "deployTokenRegistryGasless");
23
+
24
+ exports.deployTokenRegistryGasless = deployTokenRegistryGasless;
@@ -0,0 +1,31 @@
1
+ 'use strict';
2
+
3
+ var tokenRegistryFunctionsGasless = require('./token-registry-functions-gasless');
4
+ var deploy = require('./deploy');
5
+ var platformPaymasterFunctions = require('./platform-paymaster-functions');
6
+ var eip7702 = require('@trustvc/eip7702');
7
+
8
+
9
+
10
+ Object.defineProperty(exports, "eip7702Abis", {
11
+ enumerable: true,
12
+ get: function () { return eip7702.abis; }
13
+ });
14
+ Object.keys(tokenRegistryFunctionsGasless).forEach(function (k) {
15
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
16
+ enumerable: true,
17
+ get: function () { return tokenRegistryFunctionsGasless[k]; }
18
+ });
19
+ });
20
+ Object.keys(deploy).forEach(function (k) {
21
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
22
+ enumerable: true,
23
+ get: function () { return deploy[k]; }
24
+ });
25
+ });
26
+ Object.keys(platformPaymasterFunctions).forEach(function (k) {
27
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
28
+ enumerable: true,
29
+ get: function () { return platformPaymasterFunctions[k]; }
30
+ });
31
+ });
@@ -0,0 +1,54 @@
1
+ 'use strict';
2
+
3
+ var eip7702 = require('@trustvc/eip7702');
4
+ var ethers = require('../../utils/ethers');
5
+
6
+ var __defProp = Object.defineProperty;
7
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
+ async function sendAdminTx(signer, paymasterAddress, functionName, args) {
9
+ if ("writeContract" in signer) {
10
+ return signer.writeContract({
11
+ address: paymasterAddress,
12
+ abi: eip7702.abis.platformPaymasterAbi,
13
+ functionName,
14
+ args,
15
+ chain: signer.chain,
16
+ account: signer.account
17
+ });
18
+ }
19
+ const ethSigner = signer;
20
+ const Contract = ethers.getEthersContractFromProvider(ethSigner.provider);
21
+ const contract = new Contract(
22
+ paymasterAddress,
23
+ eip7702.abis.platformPaymasterAbi,
24
+ ethSigner
25
+ // eslint-disable-line @typescript-eslint/no-explicit-any
26
+ );
27
+ const isV6 = ethers.isV6EthersProvider(ethSigner.provider);
28
+ const tx = await contract[functionName](...args);
29
+ if (isV6) {
30
+ return tx.hash;
31
+ }
32
+ const receipt = await tx.wait();
33
+ return receipt.transactionHash;
34
+ }
35
+ __name(sendAdminTx, "sendAdminTx");
36
+ const setUserWhitelist = /* @__PURE__ */ __name(async (signer, paymasterAddress, user, credits) => sendAdminTx(signer, paymasterAddress, "setUserWhitelist", [user, credits]), "setUserWhitelist");
37
+ const removeUserFromWhitelist = /* @__PURE__ */ __name(async (signer, paymasterAddress, user) => sendAdminTx(signer, paymasterAddress, "removeUserFromWhitelist", [user]), "removeUserFromWhitelist");
38
+ const addRegistry = /* @__PURE__ */ __name(async (signer, paymasterAddress, registry) => sendAdminTx(signer, paymasterAddress, "addRegistry", [registry]), "addRegistry");
39
+ const removeRegistry = /* @__PURE__ */ __name(async (signer, paymasterAddress, registry) => sendAdminTx(signer, paymasterAddress, "removeRegistry", [registry]), "removeRegistry");
40
+ const addTitleEscrow = /* @__PURE__ */ __name(async (signer, paymasterAddress, titleEscrow) => sendAdminTx(signer, paymasterAddress, "addTitleEscrow", [titleEscrow]), "addTitleEscrow");
41
+ const removeTitleEscrow = /* @__PURE__ */ __name(async (signer, paymasterAddress, titleEscrow) => sendAdminTx(signer, paymasterAddress, "removeTitleEscrow", [titleEscrow]), "removeTitleEscrow");
42
+ const addAuthorizedCaller = /* @__PURE__ */ __name(async (signer, paymasterAddress, caller) => sendAdminTx(signer, paymasterAddress, "addAuthorizedCaller", [caller]), "addAuthorizedCaller");
43
+ const removeAuthorizedCaller = /* @__PURE__ */ __name(async (signer, paymasterAddress, caller) => sendAdminTx(signer, paymasterAddress, "removeAuthorizedCaller", [caller]), "removeAuthorizedCaller");
44
+ const setDailyLimit = /* @__PURE__ */ __name(async (signer, paymasterAddress, dailyLimit) => sendAdminTx(signer, paymasterAddress, "setDailyLimit", [dailyLimit]), "setDailyLimit");
45
+
46
+ exports.addAuthorizedCaller = addAuthorizedCaller;
47
+ exports.addRegistry = addRegistry;
48
+ exports.addTitleEscrow = addTitleEscrow;
49
+ exports.removeAuthorizedCaller = removeAuthorizedCaller;
50
+ exports.removeRegistry = removeRegistry;
51
+ exports.removeTitleEscrow = removeTitleEscrow;
52
+ exports.removeUserFromWhitelist = removeUserFromWhitelist;
53
+ exports.setDailyLimit = setDailyLimit;
54
+ exports.setUserWhitelist = setUserWhitelist;
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ var admin = require('./admin');
4
+
5
+
6
+
7
+ Object.keys(admin).forEach(function (k) {
8
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
9
+ enumerable: true,
10
+ get: function () { return admin[k]; }
11
+ });
12
+ });
@@ -0,0 +1,33 @@
1
+ 'use strict';
2
+
3
+ var mint = require('./mint');
4
+ var rejectTransfers = require('./rejectTransfers');
5
+ var returnToken = require('./returnToken');
6
+ var transfer = require('./transfer');
7
+
8
+
9
+
10
+ Object.keys(mint).forEach(function (k) {
11
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
12
+ enumerable: true,
13
+ get: function () { return mint[k]; }
14
+ });
15
+ });
16
+ Object.keys(rejectTransfers).forEach(function (k) {
17
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
18
+ enumerable: true,
19
+ get: function () { return rejectTransfers[k]; }
20
+ });
21
+ });
22
+ Object.keys(returnToken).forEach(function (k) {
23
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
24
+ enumerable: true,
25
+ get: function () { return returnToken[k]; }
26
+ });
27
+ });
28
+ Object.keys(transfer).forEach(function (k) {
29
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
30
+ enumerable: true,
31
+ get: function () { return transfer[k]; }
32
+ });
33
+ });
@@ -0,0 +1,32 @@
1
+ 'use strict';
2
+
3
+ var viem = require('viem');
4
+ var core = require('../../core');
5
+ var eip7702 = require('@trustvc/eip7702');
6
+
7
+ var __defProp = Object.defineProperty;
8
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
+ const mintGasless = /* @__PURE__ */ __name(async (contractOptions, smartAccountClient, params, options) => {
10
+ const { paymasterAddress, tokenRegistryAddress } = contractOptions;
11
+ const { beneficiaryAddress, holderAddress, tokenId, remarks } = params;
12
+ if (!paymasterAddress) throw new Error("paymasterAddress is required");
13
+ if (!tokenRegistryAddress) throw new Error("tokenRegistryAddress is required");
14
+ const encryptedRemarks = remarks ? `0x${core.encrypt(remarks, options.id)}` : "0x";
15
+ return smartAccountClient.sendTransaction({
16
+ to: paymasterAddress,
17
+ value: 0n,
18
+ data: viem.encodeFunctionData({
19
+ abi: eip7702.abis.platformPaymasterAbi,
20
+ functionName: "mintDocument",
21
+ args: [
22
+ tokenRegistryAddress,
23
+ beneficiaryAddress,
24
+ holderAddress,
25
+ BigInt(tokenId),
26
+ encryptedRemarks
27
+ ]
28
+ })
29
+ });
30
+ }, "mintGasless");
31
+
32
+ exports.mintGasless = mintGasless;
@@ -0,0 +1,57 @@
1
+ 'use strict';
2
+
3
+ var viem = require('viem');
4
+ var core = require('../../core');
5
+ var tokenRegistryV5 = require('../../token-registry-v5');
6
+
7
+ var __defProp = Object.defineProperty;
8
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
+ const rejectTransferHolderGasless = /* @__PURE__ */ __name(async (contractOptions, smartAccountClient, params, options) => {
10
+ const { titleEscrowAddress } = contractOptions;
11
+ const { remarks } = params;
12
+ if (!titleEscrowAddress) throw new Error("titleEscrowAddress is required");
13
+ const encryptedRemarks = remarks ? `0x${core.encrypt(remarks, options.id)}` : "0x";
14
+ return smartAccountClient.sendTransaction({
15
+ to: titleEscrowAddress,
16
+ value: 0n,
17
+ data: viem.encodeFunctionData({
18
+ abi: tokenRegistryV5.v5Contracts.TitleEscrow__factory.abi,
19
+ functionName: "rejectTransferHolder",
20
+ args: [encryptedRemarks]
21
+ })
22
+ });
23
+ }, "rejectTransferHolderGasless");
24
+ const rejectTransferBeneficiaryGasless = /* @__PURE__ */ __name(async (contractOptions, smartAccountClient, params, options) => {
25
+ const { titleEscrowAddress } = contractOptions;
26
+ const { remarks } = params;
27
+ if (!titleEscrowAddress) throw new Error("titleEscrowAddress is required");
28
+ const encryptedRemarks = remarks ? `0x${core.encrypt(remarks, options.id)}` : "0x";
29
+ return smartAccountClient.sendTransaction({
30
+ to: titleEscrowAddress,
31
+ value: 0n,
32
+ data: viem.encodeFunctionData({
33
+ abi: tokenRegistryV5.v5Contracts.TitleEscrow__factory.abi,
34
+ functionName: "rejectTransferBeneficiary",
35
+ args: [encryptedRemarks]
36
+ })
37
+ });
38
+ }, "rejectTransferBeneficiaryGasless");
39
+ const rejectTransferOwnersGasless = /* @__PURE__ */ __name(async (contractOptions, smartAccountClient, params, options) => {
40
+ const { titleEscrowAddress } = contractOptions;
41
+ const { remarks } = params;
42
+ if (!titleEscrowAddress) throw new Error("titleEscrowAddress is required");
43
+ const encryptedRemarks = remarks ? `0x${core.encrypt(remarks, options.id)}` : "0x";
44
+ return smartAccountClient.sendTransaction({
45
+ to: titleEscrowAddress,
46
+ value: 0n,
47
+ data: viem.encodeFunctionData({
48
+ abi: tokenRegistryV5.v5Contracts.TitleEscrow__factory.abi,
49
+ functionName: "rejectTransferOwners",
50
+ args: [encryptedRemarks]
51
+ })
52
+ });
53
+ }, "rejectTransferOwnersGasless");
54
+
55
+ exports.rejectTransferBeneficiaryGasless = rejectTransferBeneficiaryGasless;
56
+ exports.rejectTransferHolderGasless = rejectTransferHolderGasless;
57
+ exports.rejectTransferOwnersGasless = rejectTransferOwnersGasless;