@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
@@ -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 returnToIssuerGasless = /* @__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: "returnToIssuer",
20
+ args: [encryptedRemarks]
21
+ })
22
+ });
23
+ }, "returnToIssuerGasless");
24
+ const rejectReturnedGasless = /* @__PURE__ */ __name(async (contractOptions, smartAccountClient, params, options) => {
25
+ const { tokenRegistryAddress } = contractOptions;
26
+ const { tokenId, remarks } = params;
27
+ if (!tokenRegistryAddress) throw new Error("tokenRegistryAddress is required");
28
+ const encryptedRemarks = remarks ? `0x${core.encrypt(remarks, options.id)}` : "0x";
29
+ return smartAccountClient.sendTransaction({
30
+ to: tokenRegistryAddress,
31
+ value: 0n,
32
+ data: viem.encodeFunctionData({
33
+ abi: tokenRegistryV5.v5Contracts.TradeTrustToken__factory.abi,
34
+ functionName: "restore",
35
+ args: [BigInt(tokenId), encryptedRemarks]
36
+ })
37
+ });
38
+ }, "rejectReturnedGasless");
39
+ const acceptReturnedGasless = /* @__PURE__ */ __name(async (contractOptions, smartAccountClient, params, options) => {
40
+ const { tokenRegistryAddress } = contractOptions;
41
+ const { tokenId, remarks } = params;
42
+ if (!tokenRegistryAddress) throw new Error("tokenRegistryAddress is required");
43
+ const encryptedRemarks = remarks ? `0x${core.encrypt(remarks, options.id)}` : "0x";
44
+ return smartAccountClient.sendTransaction({
45
+ to: tokenRegistryAddress,
46
+ value: 0n,
47
+ data: viem.encodeFunctionData({
48
+ abi: tokenRegistryV5.v5Contracts.TradeTrustToken__factory.abi,
49
+ functionName: "burn",
50
+ args: [BigInt(tokenId), encryptedRemarks]
51
+ })
52
+ });
53
+ }, "acceptReturnedGasless");
54
+
55
+ exports.acceptReturnedGasless = acceptReturnedGasless;
56
+ exports.rejectReturnedGasless = rejectReturnedGasless;
57
+ exports.returnToIssuerGasless = returnToIssuerGasless;
@@ -0,0 +1,77 @@
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 transferHolderGasless = /* @__PURE__ */ __name(async (contractOptions, smartAccountClient, params, options) => {
10
+ const { titleEscrowAddress } = contractOptions;
11
+ const { holderAddress, 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: "transferHolder",
20
+ args: [holderAddress, encryptedRemarks]
21
+ })
22
+ });
23
+ }, "transferHolderGasless");
24
+ const transferBeneficiaryGasless = /* @__PURE__ */ __name(async (contractOptions, smartAccountClient, params, options) => {
25
+ const { titleEscrowAddress } = contractOptions;
26
+ const { newBeneficiaryAddress, 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: "transferBeneficiary",
35
+ args: [newBeneficiaryAddress, encryptedRemarks]
36
+ })
37
+ });
38
+ }, "transferBeneficiaryGasless");
39
+ const transferOwnersGasless = /* @__PURE__ */ __name(async (contractOptions, smartAccountClient, params, options) => {
40
+ const { titleEscrowAddress } = contractOptions;
41
+ const { newBeneficiaryAddress, newHolderAddress, 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: "transferOwners",
50
+ args: [
51
+ newBeneficiaryAddress,
52
+ newHolderAddress,
53
+ encryptedRemarks
54
+ ]
55
+ })
56
+ });
57
+ }, "transferOwnersGasless");
58
+ const nominateGasless = /* @__PURE__ */ __name(async (contractOptions, smartAccountClient, params, options) => {
59
+ const { titleEscrowAddress } = contractOptions;
60
+ const { newBeneficiaryAddress, remarks } = params;
61
+ if (!titleEscrowAddress) throw new Error("titleEscrowAddress is required");
62
+ const encryptedRemarks = remarks ? `0x${core.encrypt(remarks, options.id)}` : "0x";
63
+ return smartAccountClient.sendTransaction({
64
+ to: titleEscrowAddress,
65
+ value: 0n,
66
+ data: viem.encodeFunctionData({
67
+ abi: tokenRegistryV5.v5Contracts.TitleEscrow__factory.abi,
68
+ functionName: "nominate",
69
+ args: [newBeneficiaryAddress, encryptedRemarks]
70
+ })
71
+ });
72
+ }, "nominateGasless");
73
+
74
+ exports.nominateGasless = nominateGasless;
75
+ exports.transferBeneficiaryGasless = transferBeneficiaryGasless;
76
+ exports.transferHolderGasless = transferHolderGasless;
77
+ exports.transferOwnersGasless = transferOwnersGasless;
package/dist/cjs/index.js CHANGED
@@ -5,6 +5,7 @@ var tokenRegistryV5 = require('./token-registry-v5');
5
5
  var documentStore = require('./document-store');
6
6
  var transaction = require('./transaction');
7
7
  var tokenRegistryFunctions = require('./token-registry-functions');
8
+ var eip7702Functions = require('./eip7702-functions');
8
9
  var core = require('./core');
9
10
  var openAttestation = require('./open-attestation');
10
11
  var verify = require('./verify');
@@ -135,6 +136,12 @@ Object.keys(tokenRegistryFunctions).forEach(function (k) {
135
136
  get: function () { return tokenRegistryFunctions[k]; }
136
137
  });
137
138
  });
139
+ Object.keys(eip7702Functions).forEach(function (k) {
140
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
141
+ enumerable: true,
142
+ get: function () { return eip7702Functions[k]; }
143
+ });
144
+ });
138
145
  Object.keys(core).forEach(function (k) {
139
146
  if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
140
147
  enumerable: true,
@@ -0,0 +1,2 @@
1
+ export * from './platform-paymaster';
2
+ export * from './token-registry';
@@ -0,0 +1,80 @@
1
+ import { parseEventLogs } from 'viem';
2
+ import { constants, abis } from '@trustvc/eip7702';
3
+ import { getEthersContractFromProvider, isV6EthersProvider } from '../../utils/ethers';
4
+
5
+ var __defProp = Object.defineProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ const deployPlatformPaymaster = /* @__PURE__ */ __name(async (signer, options, publicClient) => {
8
+ const { chainId = constants.ChainId.Sepolia, dailyLimit = 0n, salt } = options;
9
+ const factoryAddress = options.factoryAddress ?? constants.contractAddress.PlatformAccountFactory[chainId];
10
+ if (!factoryAddress) {
11
+ throw new Error(
12
+ `No PlatformAccountFactory address found for chainId ${chainId}. Supply factoryAddress in options.`
13
+ );
14
+ }
15
+ if ("writeContract" in signer) {
16
+ if (!publicClient) throw new Error("publicClient is required when signer is a WalletClient");
17
+ const platformAddress2 = options.platformAddress ?? signer.account?.address;
18
+ const txHash2 = await signer.writeContract({
19
+ address: factoryAddress,
20
+ abi: abis.platformAccountFactoryAbi,
21
+ functionName: "deployPlatformPaymaster",
22
+ args: [platformAddress2, dailyLimit, salt],
23
+ chain: signer.chain,
24
+ account: signer.account
25
+ });
26
+ const receipt = await publicClient.waitForTransactionReceipt({ hash: txHash2 });
27
+ const logs2 = parseEventLogs({
28
+ abi: abis.platformAccountFactoryAbi,
29
+ logs: receipt.logs,
30
+ eventName: "PlatformOnboarded"
31
+ });
32
+ const paymasterAddress = logs2[0]?.args?.paymaster;
33
+ if (!paymasterAddress)
34
+ throw new Error("Deployment failed \u2014 PlatformOnboarded event not found in transaction logs");
35
+ return { txHash: txHash2, paymasterAddress };
36
+ }
37
+ const ethSigner = signer;
38
+ const platformAddress = options.platformAddress ?? await ethSigner.getAddress();
39
+ const Contract = getEthersContractFromProvider(ethSigner.provider);
40
+ const contract = new Contract(
41
+ factoryAddress,
42
+ abis.platformAccountFactoryAbi,
43
+ ethSigner
44
+ // eslint-disable-line @typescript-eslint/no-explicit-any
45
+ );
46
+ const isV6 = isV6EthersProvider(ethSigner.provider);
47
+ let txHash;
48
+ let logs;
49
+ if (isV6) {
50
+ const tx = await contract.deployPlatformPaymaster(
51
+ platformAddress,
52
+ dailyLimit,
53
+ salt
54
+ );
55
+ const receipt = await tx.wait();
56
+ txHash = receipt.hash;
57
+ logs = receipt.logs;
58
+ } else {
59
+ const tx = await contract.deployPlatformPaymaster(
60
+ platformAddress,
61
+ dailyLimit,
62
+ salt
63
+ );
64
+ const receipt = await tx.wait();
65
+ txHash = receipt.transactionHash;
66
+ logs = receipt.logs;
67
+ }
68
+ for (const log of logs) {
69
+ try {
70
+ const parsed = contract.interface.parseLog(log);
71
+ if (parsed?.name === "PlatformOnboarded") {
72
+ return { txHash, paymasterAddress: parsed.args.paymaster };
73
+ }
74
+ } catch {
75
+ }
76
+ }
77
+ throw new Error("Deployment failed \u2014 PlatformOnboarded event not found in transaction logs");
78
+ }, "deployPlatformPaymaster");
79
+
80
+ export { deployPlatformPaymaster };
@@ -0,0 +1,22 @@
1
+ import { encodeFunctionData } from 'viem';
2
+ import { abis } from '@trustvc/eip7702';
3
+
4
+ var __defProp = Object.defineProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ const deployTokenRegistryGasless = /* @__PURE__ */ __name(async (registryName, registrySymbol, smartAccountClient, options) => {
7
+ const { paymasterAddress, tokenRegistryImplAddress } = options;
8
+ if (!paymasterAddress) throw new Error("paymasterAddress is required");
9
+ if (!tokenRegistryImplAddress) throw new Error("tokenRegistryImplAddress is required");
10
+ const data = encodeFunctionData({
11
+ abi: abis.platformPaymasterAbi,
12
+ functionName: "deployRegistry",
13
+ args: [tokenRegistryImplAddress, registryName, registrySymbol]
14
+ });
15
+ return smartAccountClient.sendTransaction({
16
+ to: paymasterAddress,
17
+ value: 0n,
18
+ data
19
+ });
20
+ }, "deployTokenRegistryGasless");
21
+
22
+ export { deployTokenRegistryGasless };
@@ -0,0 +1,4 @@
1
+ export * from './token-registry-functions-gasless';
2
+ export * from './deploy';
3
+ export * from './platform-paymaster-functions';
4
+ export { abis as eip7702Abis } from '@trustvc/eip7702';
@@ -0,0 +1,44 @@
1
+ import { abis } from '@trustvc/eip7702';
2
+ import { getEthersContractFromProvider, isV6EthersProvider } from '../../utils/ethers';
3
+
4
+ var __defProp = Object.defineProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ async function sendAdminTx(signer, paymasterAddress, functionName, args) {
7
+ if ("writeContract" in signer) {
8
+ return signer.writeContract({
9
+ address: paymasterAddress,
10
+ abi: abis.platformPaymasterAbi,
11
+ functionName,
12
+ args,
13
+ chain: signer.chain,
14
+ account: signer.account
15
+ });
16
+ }
17
+ const ethSigner = signer;
18
+ const Contract = getEthersContractFromProvider(ethSigner.provider);
19
+ const contract = new Contract(
20
+ paymasterAddress,
21
+ abis.platformPaymasterAbi,
22
+ ethSigner
23
+ // eslint-disable-line @typescript-eslint/no-explicit-any
24
+ );
25
+ const isV6 = isV6EthersProvider(ethSigner.provider);
26
+ const tx = await contract[functionName](...args);
27
+ if (isV6) {
28
+ return tx.hash;
29
+ }
30
+ const receipt = await tx.wait();
31
+ return receipt.transactionHash;
32
+ }
33
+ __name(sendAdminTx, "sendAdminTx");
34
+ const setUserWhitelist = /* @__PURE__ */ __name(async (signer, paymasterAddress, user, credits) => sendAdminTx(signer, paymasterAddress, "setUserWhitelist", [user, credits]), "setUserWhitelist");
35
+ const removeUserFromWhitelist = /* @__PURE__ */ __name(async (signer, paymasterAddress, user) => sendAdminTx(signer, paymasterAddress, "removeUserFromWhitelist", [user]), "removeUserFromWhitelist");
36
+ const addRegistry = /* @__PURE__ */ __name(async (signer, paymasterAddress, registry) => sendAdminTx(signer, paymasterAddress, "addRegistry", [registry]), "addRegistry");
37
+ const removeRegistry = /* @__PURE__ */ __name(async (signer, paymasterAddress, registry) => sendAdminTx(signer, paymasterAddress, "removeRegistry", [registry]), "removeRegistry");
38
+ const addTitleEscrow = /* @__PURE__ */ __name(async (signer, paymasterAddress, titleEscrow) => sendAdminTx(signer, paymasterAddress, "addTitleEscrow", [titleEscrow]), "addTitleEscrow");
39
+ const removeTitleEscrow = /* @__PURE__ */ __name(async (signer, paymasterAddress, titleEscrow) => sendAdminTx(signer, paymasterAddress, "removeTitleEscrow", [titleEscrow]), "removeTitleEscrow");
40
+ const addAuthorizedCaller = /* @__PURE__ */ __name(async (signer, paymasterAddress, caller) => sendAdminTx(signer, paymasterAddress, "addAuthorizedCaller", [caller]), "addAuthorizedCaller");
41
+ const removeAuthorizedCaller = /* @__PURE__ */ __name(async (signer, paymasterAddress, caller) => sendAdminTx(signer, paymasterAddress, "removeAuthorizedCaller", [caller]), "removeAuthorizedCaller");
42
+ const setDailyLimit = /* @__PURE__ */ __name(async (signer, paymasterAddress, dailyLimit) => sendAdminTx(signer, paymasterAddress, "setDailyLimit", [dailyLimit]), "setDailyLimit");
43
+
44
+ export { addAuthorizedCaller, addRegistry, addTitleEscrow, removeAuthorizedCaller, removeRegistry, removeTitleEscrow, removeUserFromWhitelist, setDailyLimit, setUserWhitelist };
@@ -0,0 +1 @@
1
+ export * from './admin';
@@ -0,0 +1,4 @@
1
+ export * from './mint';
2
+ export * from './rejectTransfers';
3
+ export * from './returnToken';
4
+ export * from './transfer';
@@ -0,0 +1,30 @@
1
+ import { encodeFunctionData } from 'viem';
2
+ import { encrypt } from '../../core';
3
+ import { abis } from '@trustvc/eip7702';
4
+
5
+ var __defProp = Object.defineProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ const mintGasless = /* @__PURE__ */ __name(async (contractOptions, smartAccountClient, params, options) => {
8
+ const { paymasterAddress, tokenRegistryAddress } = contractOptions;
9
+ const { beneficiaryAddress, holderAddress, tokenId, remarks } = params;
10
+ if (!paymasterAddress) throw new Error("paymasterAddress is required");
11
+ if (!tokenRegistryAddress) throw new Error("tokenRegistryAddress is required");
12
+ const encryptedRemarks = remarks ? `0x${encrypt(remarks, options.id)}` : "0x";
13
+ return smartAccountClient.sendTransaction({
14
+ to: paymasterAddress,
15
+ value: 0n,
16
+ data: encodeFunctionData({
17
+ abi: abis.platformPaymasterAbi,
18
+ functionName: "mintDocument",
19
+ args: [
20
+ tokenRegistryAddress,
21
+ beneficiaryAddress,
22
+ holderAddress,
23
+ BigInt(tokenId),
24
+ encryptedRemarks
25
+ ]
26
+ })
27
+ });
28
+ }, "mintGasless");
29
+
30
+ export { mintGasless };
@@ -0,0 +1,53 @@
1
+ import { encodeFunctionData } from 'viem';
2
+ import { encrypt } from '../../core';
3
+ import { v5Contracts } from '../../token-registry-v5';
4
+
5
+ var __defProp = Object.defineProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ const rejectTransferHolderGasless = /* @__PURE__ */ __name(async (contractOptions, smartAccountClient, params, options) => {
8
+ const { titleEscrowAddress } = contractOptions;
9
+ const { remarks } = params;
10
+ if (!titleEscrowAddress) throw new Error("titleEscrowAddress is required");
11
+ const encryptedRemarks = remarks ? `0x${encrypt(remarks, options.id)}` : "0x";
12
+ return smartAccountClient.sendTransaction({
13
+ to: titleEscrowAddress,
14
+ value: 0n,
15
+ data: encodeFunctionData({
16
+ abi: v5Contracts.TitleEscrow__factory.abi,
17
+ functionName: "rejectTransferHolder",
18
+ args: [encryptedRemarks]
19
+ })
20
+ });
21
+ }, "rejectTransferHolderGasless");
22
+ const rejectTransferBeneficiaryGasless = /* @__PURE__ */ __name(async (contractOptions, smartAccountClient, params, options) => {
23
+ const { titleEscrowAddress } = contractOptions;
24
+ const { remarks } = params;
25
+ if (!titleEscrowAddress) throw new Error("titleEscrowAddress is required");
26
+ const encryptedRemarks = remarks ? `0x${encrypt(remarks, options.id)}` : "0x";
27
+ return smartAccountClient.sendTransaction({
28
+ to: titleEscrowAddress,
29
+ value: 0n,
30
+ data: encodeFunctionData({
31
+ abi: v5Contracts.TitleEscrow__factory.abi,
32
+ functionName: "rejectTransferBeneficiary",
33
+ args: [encryptedRemarks]
34
+ })
35
+ });
36
+ }, "rejectTransferBeneficiaryGasless");
37
+ const rejectTransferOwnersGasless = /* @__PURE__ */ __name(async (contractOptions, smartAccountClient, params, options) => {
38
+ const { titleEscrowAddress } = contractOptions;
39
+ const { remarks } = params;
40
+ if (!titleEscrowAddress) throw new Error("titleEscrowAddress is required");
41
+ const encryptedRemarks = remarks ? `0x${encrypt(remarks, options.id)}` : "0x";
42
+ return smartAccountClient.sendTransaction({
43
+ to: titleEscrowAddress,
44
+ value: 0n,
45
+ data: encodeFunctionData({
46
+ abi: v5Contracts.TitleEscrow__factory.abi,
47
+ functionName: "rejectTransferOwners",
48
+ args: [encryptedRemarks]
49
+ })
50
+ });
51
+ }, "rejectTransferOwnersGasless");
52
+
53
+ export { rejectTransferBeneficiaryGasless, rejectTransferHolderGasless, rejectTransferOwnersGasless };
@@ -0,0 +1,53 @@
1
+ import { encodeFunctionData } from 'viem';
2
+ import { encrypt } from '../../core';
3
+ import { v5Contracts } from '../../token-registry-v5';
4
+
5
+ var __defProp = Object.defineProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ const returnToIssuerGasless = /* @__PURE__ */ __name(async (contractOptions, smartAccountClient, params, options) => {
8
+ const { titleEscrowAddress } = contractOptions;
9
+ const { remarks } = params;
10
+ if (!titleEscrowAddress) throw new Error("titleEscrowAddress is required");
11
+ const encryptedRemarks = remarks ? `0x${encrypt(remarks, options.id)}` : "0x";
12
+ return smartAccountClient.sendTransaction({
13
+ to: titleEscrowAddress,
14
+ value: 0n,
15
+ data: encodeFunctionData({
16
+ abi: v5Contracts.TitleEscrow__factory.abi,
17
+ functionName: "returnToIssuer",
18
+ args: [encryptedRemarks]
19
+ })
20
+ });
21
+ }, "returnToIssuerGasless");
22
+ const rejectReturnedGasless = /* @__PURE__ */ __name(async (contractOptions, smartAccountClient, params, options) => {
23
+ const { tokenRegistryAddress } = contractOptions;
24
+ const { tokenId, remarks } = params;
25
+ if (!tokenRegistryAddress) throw new Error("tokenRegistryAddress is required");
26
+ const encryptedRemarks = remarks ? `0x${encrypt(remarks, options.id)}` : "0x";
27
+ return smartAccountClient.sendTransaction({
28
+ to: tokenRegistryAddress,
29
+ value: 0n,
30
+ data: encodeFunctionData({
31
+ abi: v5Contracts.TradeTrustToken__factory.abi,
32
+ functionName: "restore",
33
+ args: [BigInt(tokenId), encryptedRemarks]
34
+ })
35
+ });
36
+ }, "rejectReturnedGasless");
37
+ const acceptReturnedGasless = /* @__PURE__ */ __name(async (contractOptions, smartAccountClient, params, options) => {
38
+ const { tokenRegistryAddress } = contractOptions;
39
+ const { tokenId, remarks } = params;
40
+ if (!tokenRegistryAddress) throw new Error("tokenRegistryAddress is required");
41
+ const encryptedRemarks = remarks ? `0x${encrypt(remarks, options.id)}` : "0x";
42
+ return smartAccountClient.sendTransaction({
43
+ to: tokenRegistryAddress,
44
+ value: 0n,
45
+ data: encodeFunctionData({
46
+ abi: v5Contracts.TradeTrustToken__factory.abi,
47
+ functionName: "burn",
48
+ args: [BigInt(tokenId), encryptedRemarks]
49
+ })
50
+ });
51
+ }, "acceptReturnedGasless");
52
+
53
+ export { acceptReturnedGasless, rejectReturnedGasless, returnToIssuerGasless };
@@ -0,0 +1,72 @@
1
+ import { encodeFunctionData } from 'viem';
2
+ import { encrypt } from '../../core';
3
+ import { v5Contracts } from '../../token-registry-v5';
4
+
5
+ var __defProp = Object.defineProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ const transferHolderGasless = /* @__PURE__ */ __name(async (contractOptions, smartAccountClient, params, options) => {
8
+ const { titleEscrowAddress } = contractOptions;
9
+ const { holderAddress, remarks } = params;
10
+ if (!titleEscrowAddress) throw new Error("titleEscrowAddress is required");
11
+ const encryptedRemarks = remarks ? `0x${encrypt(remarks, options.id)}` : "0x";
12
+ return smartAccountClient.sendTransaction({
13
+ to: titleEscrowAddress,
14
+ value: 0n,
15
+ data: encodeFunctionData({
16
+ abi: v5Contracts.TitleEscrow__factory.abi,
17
+ functionName: "transferHolder",
18
+ args: [holderAddress, encryptedRemarks]
19
+ })
20
+ });
21
+ }, "transferHolderGasless");
22
+ const transferBeneficiaryGasless = /* @__PURE__ */ __name(async (contractOptions, smartAccountClient, params, options) => {
23
+ const { titleEscrowAddress } = contractOptions;
24
+ const { newBeneficiaryAddress, remarks } = params;
25
+ if (!titleEscrowAddress) throw new Error("titleEscrowAddress is required");
26
+ const encryptedRemarks = remarks ? `0x${encrypt(remarks, options.id)}` : "0x";
27
+ return smartAccountClient.sendTransaction({
28
+ to: titleEscrowAddress,
29
+ value: 0n,
30
+ data: encodeFunctionData({
31
+ abi: v5Contracts.TitleEscrow__factory.abi,
32
+ functionName: "transferBeneficiary",
33
+ args: [newBeneficiaryAddress, encryptedRemarks]
34
+ })
35
+ });
36
+ }, "transferBeneficiaryGasless");
37
+ const transferOwnersGasless = /* @__PURE__ */ __name(async (contractOptions, smartAccountClient, params, options) => {
38
+ const { titleEscrowAddress } = contractOptions;
39
+ const { newBeneficiaryAddress, newHolderAddress, remarks } = params;
40
+ if (!titleEscrowAddress) throw new Error("titleEscrowAddress is required");
41
+ const encryptedRemarks = remarks ? `0x${encrypt(remarks, options.id)}` : "0x";
42
+ return smartAccountClient.sendTransaction({
43
+ to: titleEscrowAddress,
44
+ value: 0n,
45
+ data: encodeFunctionData({
46
+ abi: v5Contracts.TitleEscrow__factory.abi,
47
+ functionName: "transferOwners",
48
+ args: [
49
+ newBeneficiaryAddress,
50
+ newHolderAddress,
51
+ encryptedRemarks
52
+ ]
53
+ })
54
+ });
55
+ }, "transferOwnersGasless");
56
+ const nominateGasless = /* @__PURE__ */ __name(async (contractOptions, smartAccountClient, params, options) => {
57
+ const { titleEscrowAddress } = contractOptions;
58
+ const { newBeneficiaryAddress, remarks } = params;
59
+ if (!titleEscrowAddress) throw new Error("titleEscrowAddress is required");
60
+ const encryptedRemarks = remarks ? `0x${encrypt(remarks, options.id)}` : "0x";
61
+ return smartAccountClient.sendTransaction({
62
+ to: titleEscrowAddress,
63
+ value: 0n,
64
+ data: encodeFunctionData({
65
+ abi: v5Contracts.TitleEscrow__factory.abi,
66
+ functionName: "nominate",
67
+ args: [newBeneficiaryAddress, encryptedRemarks]
68
+ })
69
+ });
70
+ }, "nominateGasless");
71
+
72
+ export { nominateGasless, transferBeneficiaryGasless, transferHolderGasless, transferOwnersGasless };
package/dist/esm/index.js CHANGED
@@ -4,6 +4,7 @@ export { DocumentStore__factory, TransferableDocumentStore__factory, deployDocum
4
4
  export * from './transaction';
5
5
  export { cancelTransaction } from './transaction';
6
6
  export * from './token-registry-functions';
7
+ export * from './eip7702-functions';
7
8
  export * from './core';
8
9
  export * from './open-attestation';
9
10
  export * from './verify';
@@ -0,0 +1,5 @@
1
+ export { DeployPlatformPaymasterOptions, DeployPlatformPaymasterResult, deployPlatformPaymaster } from './platform-paymaster.js';
2
+ export { DeployTokenRegistryGaslessOptions, deployTokenRegistryGasless } from './token-registry.js';
3
+ import 'viem';
4
+ import 'ethersV6';
5
+ import 'ethers';
@@ -0,0 +1,41 @@
1
+ import { WalletClient, PublicClient } from 'viem';
2
+ import { Signer as Signer$1 } from 'ethersV6';
3
+ import { Signer } from 'ethers';
4
+
5
+ /**
6
+ * Options for deploying a PlatformPaymaster clone.
7
+ */
8
+ interface DeployPlatformPaymasterOptions {
9
+ chainId?: number;
10
+ factoryAddress?: `0x${string}`;
11
+ platformAddress?: `0x${string}`;
12
+ dailyLimit?: bigint;
13
+ salt: `0x${string}`;
14
+ }
15
+ /**
16
+ * Result returned after a successful paymaster deployment.
17
+ */
18
+ interface DeployPlatformPaymasterResult {
19
+ txHash: `0x${string}`;
20
+ paymasterAddress: `0x${string}`;
21
+ }
22
+ /**
23
+ * Deploys a PlatformPaymaster clone via the PlatformAccountFactory contract.
24
+ *
25
+ * Supports both viem WalletClient and ethers v5/v6 signers. Each paymaster is a cheap
26
+ * minimal-proxy clone sharing the implementation's logic but with its own state
27
+ * (owner, daily limit, registry whitelist). The deployed address is deterministic
28
+ * based on the salt.
29
+ *
30
+ * Prerequisites: `PlatformAccountFactory` must already be deployed on the target chain.
31
+ * @param {SignerV5 | SignerV6 | WalletClient} signer - Ethers signer (v5 or v6) or viem WalletClient connected to the deployer account.
32
+ * @param {DeployPlatformPaymasterOptions} options - Deployment options including `salt` (required), optional `chainId`, `factoryAddress`, `platformAddress`, and `dailyLimit`.
33
+ * @param {PublicClient} [publicClient] - viem PublicClient required when `signer` is a WalletClient.
34
+ * @throws {Error} If no factory address is available for the given chain.
35
+ * @throws {Error} If `signer` is a WalletClient but no `publicClient` is provided.
36
+ * @throws {Error} If the transaction succeeds but no paymaster address is found in the logs.
37
+ * @returns {Promise<DeployPlatformPaymasterResult>} Transaction hash and the deployed paymaster address.
38
+ */
39
+ declare const deployPlatformPaymaster: (signer: Signer | Signer$1 | WalletClient, options: DeployPlatformPaymasterOptions, publicClient?: PublicClient) => Promise<DeployPlatformPaymasterResult>;
40
+
41
+ export { type DeployPlatformPaymasterOptions, type DeployPlatformPaymasterResult, deployPlatformPaymaster };
@@ -0,0 +1,34 @@
1
+ interface GaslessSmartAccountClient {
2
+ sendTransaction(args: {
3
+ to: `0x${string}`;
4
+ value: bigint;
5
+ data: `0x${string}`;
6
+ }): Promise<string>;
7
+ }
8
+ /**
9
+ * Configuration options for gasless Token Registry deployment.
10
+ */
11
+ interface DeployTokenRegistryGaslessOptions {
12
+ paymasterAddress: `0x${string}`;
13
+ tokenRegistryImplAddress: `0x${string}`;
14
+ }
15
+ /**
16
+ * Deploys a new Token Registry contract gaslessly via EIP-7702 + Pimlico.
17
+ * Gas is sponsored by the PlatformPaymaster — no ETH required from the caller.
18
+ *
19
+ * Calls `deployRegistry(implementation, name, symbol)` on the PlatformPaymaster, which:
20
+ * 1. Verifies the caller is whitelisted (`userWhitelist[sender] > 0`)
21
+ * 2. Clones the implementation via TDocDeployer internally
22
+ * 3. Emits `RegistryDeployed(user, deployed, creditsLeft)`
23
+ *
24
+ * Prerequisites: caller must be whitelisted on the PlatformPaymaster before calling this.
25
+ * @param {string} registryName - The name of the token registry (e.g., "My Token Registry").
26
+ * @param {string} registrySymbol - The symbol of the token registry (e.g., "MTR").
27
+ * @param {GaslessSmartAccountClient} smartAccountClient - Pre-built EIP-7702 smart account client (caller must be whitelisted on the paymaster).
28
+ * @param {DeployTokenRegistryGaslessOptions} options - Requires `paymasterAddress` and `tokenRegistryImplAddress`.
29
+ * @throws {Error} If `paymasterAddress` or `tokenRegistryImplAddress` is missing.
30
+ * @returns {Promise<string>} The transaction hash of the submitted UserOp.
31
+ */
32
+ declare const deployTokenRegistryGasless: (registryName: string, registrySymbol: string, smartAccountClient: GaslessSmartAccountClient, options: DeployTokenRegistryGaslessOptions) => Promise<string>;
33
+
34
+ export { type DeployTokenRegistryGaslessOptions, deployTokenRegistryGasless };
@@ -0,0 +1,15 @@
1
+ export { MintGaslessOptions, mintGasless } from './token-registry-functions-gasless/mint.js';
2
+ export { rejectTransferBeneficiaryGasless, rejectTransferHolderGasless, rejectTransferOwnersGasless } from './token-registry-functions-gasless/rejectTransfers.js';
3
+ export { acceptReturnedGasless, rejectReturnedGasless, returnToIssuerGasless } from './token-registry-functions-gasless/returnToken.js';
4
+ export { nominateGasless, transferBeneficiaryGasless, transferHolderGasless, transferOwnersGasless } from './token-registry-functions-gasless/transfer.js';
5
+ export { DeployPlatformPaymasterOptions, DeployPlatformPaymasterResult, deployPlatformPaymaster } from './deploy/platform-paymaster.js';
6
+ export { DeployTokenRegistryGaslessOptions, deployTokenRegistryGasless } from './deploy/token-registry.js';
7
+ export { addAuthorizedCaller, addRegistry, addTitleEscrow, removeAuthorizedCaller, removeRegistry, removeTitleEscrow, removeUserFromWhitelist, setDailyLimit, setUserWhitelist } from './platform-paymaster-functions/admin.js';
8
+ export { abis as eip7702Abis } from '@trustvc/eip7702';
9
+ import '../token-registry-functions/types.js';
10
+ import '../utils/supportedChains/index.js';
11
+ import '../utils/gasStation/index.js';
12
+ import 'ethers';
13
+ import '../utils/network/index.js';
14
+ import 'ethersV6';
15
+ import 'viem';