@trustvc/trustvc 2.14.0 → 2.15.0-beta.1

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 (39) hide show
  1. package/dist/cjs/eip7702-functions/deploy/index.js +19 -0
  2. package/dist/cjs/eip7702-functions/deploy/platform-paymaster.js +82 -0
  3. package/dist/cjs/eip7702-functions/deploy/token-registry.js +24 -0
  4. package/dist/cjs/eip7702-functions/index.js +26 -0
  5. package/dist/cjs/eip7702-functions/platform-paymaster-functions/admin.js +54 -0
  6. package/dist/cjs/eip7702-functions/platform-paymaster-functions/index.js +12 -0
  7. package/dist/cjs/eip7702-functions/token-registry-functions-gasless/index.js +33 -0
  8. package/dist/cjs/eip7702-functions/token-registry-functions-gasless/mint.js +32 -0
  9. package/dist/cjs/eip7702-functions/token-registry-functions-gasless/rejectTransfers.js +57 -0
  10. package/dist/cjs/eip7702-functions/token-registry-functions-gasless/returnToken.js +57 -0
  11. package/dist/cjs/eip7702-functions/token-registry-functions-gasless/transfer.js +77 -0
  12. package/dist/cjs/index.js +7 -0
  13. package/dist/cjs/utils/supportedChains/index.js +1 -1
  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 +3 -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/esm/utils/supportedChains/index.js +1 -1
  27. package/dist/types/eip7702-functions/deploy/index.d.ts +5 -0
  28. package/dist/types/eip7702-functions/deploy/platform-paymaster.d.ts +41 -0
  29. package/dist/types/eip7702-functions/deploy/token-registry.d.ts +34 -0
  30. package/dist/types/eip7702-functions/index.d.ts +14 -0
  31. package/dist/types/eip7702-functions/platform-paymaster-functions/admin.d.ts +82 -0
  32. package/dist/types/eip7702-functions/platform-paymaster-functions/index.d.ts +4 -0
  33. package/dist/types/eip7702-functions/token-registry-functions-gasless/index.d.ts +10 -0
  34. package/dist/types/eip7702-functions/token-registry-functions-gasless/mint.d.ts +35 -0
  35. package/dist/types/eip7702-functions/token-registry-functions-gasless/rejectTransfers.d.ts +46 -0
  36. package/dist/types/eip7702-functions/token-registry-functions-gasless/returnToken.d.ts +49 -0
  37. package/dist/types/eip7702-functions/token-registry-functions-gasless/transfer.d.ts +56 -0
  38. package/dist/types/index.d.ts +8 -0
  39. package/package.json +5 -2
@@ -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,26 @@
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
+
7
+
8
+
9
+ Object.keys(tokenRegistryFunctionsGasless).forEach(function (k) {
10
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
11
+ enumerable: true,
12
+ get: function () { return tokenRegistryFunctionsGasless[k]; }
13
+ });
14
+ });
15
+ Object.keys(deploy).forEach(function (k) {
16
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
17
+ enumerable: true,
18
+ get: function () { return deploy[k]; }
19
+ });
20
+ });
21
+ Object.keys(platformPaymasterFunctions).forEach(function (k) {
22
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
23
+ enumerable: true,
24
+ get: function () { return platformPaymasterFunctions[k]; }
25
+ });
26
+ });
@@ -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;
@@ -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,
@@ -64,7 +64,7 @@ const SUPPORTED_CHAINS = {
64
64
  currency: "POL",
65
65
  iconImage: icons.iconPolygon,
66
66
  explorerUrl: "https://amoy.polygonscan.com",
67
- explorerApiUrl: `https://api-amoy.polygonscan.com/api?apikey=${process.env.POLYGONSCAN_API_KEY}`,
67
+ explorerApiUrl: `https://api.etherscan.io/v2/api?apikey=${process.env.POLYGONSCAN_API_KEY}&chainid=80002`,
68
68
  rpcUrl: `https://polygon-amoy.infura.io/v3/${process.env.INFURA_API_KEY}`,
69
69
  gasStation: gasStation.gasStation("https://gasstation.polygon.technology/amoy"),
70
70
  nativeCurrency: {
@@ -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,3 @@
1
+ export * from './token-registry-functions-gasless';
2
+ export * from './deploy';
3
+ export * from './platform-paymaster-functions';