@charterlabs/rhinestone-sdk 0.2.7-dev.3 → 0.2.7-dev.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/accounts/error.d.ts +38 -3
- package/dist/src/accounts/error.d.ts.map +1 -1
- package/dist/src/accounts/error.js +55 -7
- package/dist/src/accounts/index.d.ts +28 -20
- package/dist/src/accounts/index.d.ts.map +1 -1
- package/dist/src/accounts/index.js +196 -21
- package/dist/src/accounts/index.test.js +2 -4
- package/dist/src/accounts/json-rpc/index.d.ts +5 -0
- package/dist/src/accounts/json-rpc/index.d.ts.map +1 -0
- package/dist/src/accounts/json-rpc/index.js +16 -0
- package/dist/src/accounts/json-rpc/providers.d.ts +4 -0
- package/dist/src/accounts/json-rpc/providers.d.ts.map +1 -0
- package/dist/src/accounts/json-rpc/providers.js +52 -0
- package/dist/src/accounts/kernel.d.ts +1 -1
- package/dist/src/accounts/kernel.d.ts.map +1 -1
- package/dist/src/accounts/kernel.js +29 -1
- package/dist/src/accounts/kernel.test.js +35 -8
- package/dist/src/accounts/nexus.d.ts +4 -3
- package/dist/src/accounts/nexus.d.ts.map +1 -1
- package/dist/src/accounts/nexus.js +82 -14
- package/dist/src/accounts/nexus.test.js +33 -6
- package/dist/src/accounts/safe.d.ts.map +1 -1
- package/dist/src/accounts/safe.js +85 -53
- package/dist/src/accounts/safe.test.js +33 -6
- package/dist/src/accounts/signing/common.d.ts +4 -4
- package/dist/src/accounts/signing/common.d.ts.map +1 -1
- package/dist/src/accounts/signing/common.js +21 -9
- package/dist/src/accounts/signing/message.d.ts +1 -1
- package/dist/src/accounts/signing/message.d.ts.map +1 -1
- package/dist/src/accounts/signing/message.js +6 -6
- package/dist/src/accounts/signing/passkeys.d.ts +8 -1
- package/dist/src/accounts/signing/passkeys.d.ts.map +1 -1
- package/dist/src/accounts/signing/passkeys.js +35 -0
- package/dist/src/accounts/signing/passkeys.test.js +15 -0
- package/dist/src/accounts/signing/typedData.d.ts.map +1 -1
- package/dist/src/accounts/signing/typedData.js +2 -2
- package/dist/src/accounts/startale.test.js +0 -4
- package/dist/src/accounts/utils.d.ts +4 -4
- package/dist/src/accounts/utils.d.ts.map +1 -1
- package/dist/src/accounts/utils.js +3 -40
- package/dist/src/accounts/walletClient.d.ts +7 -0
- package/dist/src/accounts/walletClient.d.ts.map +1 -0
- package/dist/src/accounts/walletClient.js +38 -0
- package/dist/src/actions/compact.d.ts +13 -0
- package/dist/src/actions/compact.d.ts.map +1 -0
- package/dist/src/actions/compact.js +210 -0
- package/dist/src/actions/ecdsa.d.ts +35 -0
- package/dist/src/actions/ecdsa.d.ts.map +1 -0
- package/dist/src/actions/ecdsa.js +114 -0
- package/dist/src/actions/ecdsa.test.d.ts +2 -0
- package/dist/src/actions/ecdsa.test.d.ts.map +1 -0
- package/dist/src/actions/ecdsa.test.js +99 -0
- package/dist/src/actions/index.d.ts +23 -166
- package/dist/src/actions/index.d.ts.map +1 -1
- package/dist/src/actions/index.js +25 -544
- package/dist/src/actions/mfa.d.ts +37 -0
- package/dist/src/actions/mfa.d.ts.map +1 -0
- package/dist/src/actions/mfa.js +133 -0
- package/dist/src/actions/passkeys.d.ts +37 -0
- package/dist/src/actions/passkeys.d.ts.map +1 -0
- package/dist/src/actions/passkeys.js +129 -0
- package/dist/src/actions/passkeys.test.d.ts +2 -0
- package/dist/src/actions/passkeys.test.d.ts.map +1 -0
- package/dist/src/actions/passkeys.test.js +54 -0
- package/dist/src/actions/recovery.d.ts +33 -0
- package/dist/src/actions/recovery.d.ts.map +1 -0
- package/dist/src/actions/recovery.js +193 -0
- package/dist/src/actions/recovery.test.d.ts +2 -0
- package/dist/src/actions/recovery.test.d.ts.map +1 -0
- package/dist/src/actions/recovery.test.js +168 -0
- package/dist/src/errors/index.d.ts +5 -0
- package/dist/src/errors/index.d.ts.map +1 -0
- package/dist/src/errors/index.js +35 -0
- package/dist/src/execution/compact.d.ts +24 -8
- package/dist/src/execution/compact.d.ts.map +1 -1
- package/dist/src/execution/compact.js +29 -103
- package/dist/src/execution/error.d.ts +2 -9
- package/dist/src/execution/error.d.ts.map +1 -1
- package/dist/src/execution/error.js +4 -13
- package/dist/src/execution/index.d.ts +33 -22
- package/dist/src/execution/index.d.ts.map +1 -1
- package/dist/src/execution/index.js +57 -41
- package/dist/src/execution/permit2.d.ts +148 -0
- package/dist/src/execution/permit2.d.ts.map +1 -0
- package/dist/src/execution/permit2.js +282 -0
- package/dist/src/execution/smart-session.d.ts +3 -3
- package/dist/src/execution/smart-session.d.ts.map +1 -1
- package/dist/src/execution/types.d.ts +35 -0
- package/dist/src/execution/types.d.ts.map +1 -0
- package/dist/src/execution/types.js +2 -0
- package/dist/src/execution/utils.d.ts +36 -28
- package/dist/src/execution/utils.d.ts.map +1 -1
- package/dist/src/execution/utils.js +245 -91
- package/dist/src/index.d.ts +37 -19
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +130 -66
- package/dist/src/modules/common.d.ts +10 -4
- package/dist/src/modules/common.d.ts.map +1 -1
- package/dist/src/modules/common.js +22 -1
- package/dist/src/modules/index.d.ts +3 -2
- package/dist/src/modules/index.d.ts.map +1 -1
- package/dist/src/modules/index.js +16 -13
- package/dist/src/modules/index.test.js +8 -11
- package/dist/src/modules/read.d.ts.map +1 -1
- package/dist/src/modules/read.js +4 -0
- package/dist/src/modules/validators/core.d.ts +5 -3
- package/dist/src/modules/validators/core.d.ts.map +1 -1
- package/dist/src/modules/validators/core.js +29 -10
- package/dist/src/modules/validators/core.test.js +4 -4
- package/dist/src/modules/validators/smart-sessions.test.js +0 -3
- package/dist/src/modules/validators/webauthn-contract.d.ts.map +1 -1
- package/dist/src/orchestrator/client.d.ts +2 -1
- package/dist/src/orchestrator/client.d.ts.map +1 -1
- package/dist/src/orchestrator/client.js +36 -14
- package/dist/src/orchestrator/consts.d.ts +1 -2
- package/dist/src/orchestrator/consts.d.ts.map +1 -1
- package/dist/src/orchestrator/consts.js +1 -3
- package/dist/src/orchestrator/registry.d.ts +3 -25
- package/dist/src/orchestrator/registry.d.ts.map +1 -1
- package/dist/src/orchestrator/registry.js +82 -46
- package/dist/src/orchestrator/registry.test.js +7 -7
- package/dist/src/orchestrator/types.d.ts +35 -31
- package/dist/src/orchestrator/types.d.ts.map +1 -1
- package/dist/src/types.d.ts +64 -9
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +73 -2
- package/dist/src/actions/index.test.d.ts +0 -2
- package/dist/src/actions/index.test.d.ts.map +0 -1
- package/dist/src/actions/index.test.js +0 -302
- package/dist/src/orchestrator/registry.json +0 -365
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.SignerNotSupportedError = exports.SessionChainRequiredError = exports.OrderPathRequiredForIntentsError = exports.IntentFailedError = exports.ExecutionError = exports.isExecutionError = void 0;
|
|
4
4
|
exports.sendTransaction = sendTransaction;
|
|
5
|
+
exports.sendTransactionInternal = sendTransactionInternal;
|
|
6
|
+
exports.sendUserOperation = sendUserOperation;
|
|
7
|
+
exports.sendUserOperationInternal = sendUserOperationInternal;
|
|
5
8
|
exports.waitForExecution = waitForExecution;
|
|
6
9
|
exports.getMaxSpendableAmount = getMaxSpendableAmount;
|
|
7
10
|
exports.getPortfolio = getPortfolio;
|
|
@@ -17,46 +20,53 @@ Object.defineProperty(exports, "IntentFailedError", { enumerable: true, get: fun
|
|
|
17
20
|
Object.defineProperty(exports, "isExecutionError", { enumerable: true, get: function () { return error_1.isExecutionError; } });
|
|
18
21
|
Object.defineProperty(exports, "OrderPathRequiredForIntentsError", { enumerable: true, get: function () { return error_1.OrderPathRequiredForIntentsError; } });
|
|
19
22
|
Object.defineProperty(exports, "SessionChainRequiredError", { enumerable: true, get: function () { return error_1.SessionChainRequiredError; } });
|
|
20
|
-
Object.defineProperty(exports, "
|
|
21
|
-
Object.defineProperty(exports, "UserOperationRequiredForSmartSessionsError", { enumerable: true, get: function () { return error_1.UserOperationRequiredForSmartSessionsError; } });
|
|
23
|
+
Object.defineProperty(exports, "SignerNotSupportedError", { enumerable: true, get: function () { return error_1.SignerNotSupportedError; } });
|
|
22
24
|
const smart_session_1 = require("./smart-session");
|
|
23
25
|
const utils_2 = require("./utils");
|
|
24
26
|
const POLLING_INTERVAL = 500;
|
|
25
27
|
async function sendTransaction(config, transaction) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
const sourceChains = 'chain' in transaction
|
|
29
|
+
? [transaction.chain]
|
|
30
|
+
: transaction.sourceChains || [];
|
|
31
|
+
const targetChain = 'chain' in transaction ? transaction.chain : transaction.targetChain;
|
|
32
|
+
const { calls, gasLimit, tokenRequests, signers, sponsored, settlementLayers, sourceAssets, feeAsset, } = transaction;
|
|
33
|
+
const isUserOpSigner = signers?.type === 'guardians' || signers?.type === 'session';
|
|
34
|
+
if (isUserOpSigner) {
|
|
35
|
+
throw new error_1.SignerNotSupportedError();
|
|
29
36
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
37
|
+
return await sendTransactionInternal(config, sourceChains, targetChain, calls, {
|
|
38
|
+
gasLimit,
|
|
39
|
+
initialTokenRequests: tokenRequests,
|
|
40
|
+
signers,
|
|
41
|
+
sponsored,
|
|
42
|
+
settlementLayers,
|
|
43
|
+
sourceAssets,
|
|
44
|
+
feeAsset,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
async function sendUserOperation(config, transaction) {
|
|
48
|
+
const accountAddress = (0, accounts_1.getAddress)(config);
|
|
49
|
+
const resolvedCalls = await (0, utils_2.resolveCallInputs)(transaction.calls, config, transaction.chain, accountAddress);
|
|
50
|
+
const userOpSigner = transaction.signers?.type === 'session' ? transaction.signers.session : null;
|
|
51
|
+
if (userOpSigner) {
|
|
52
|
+
await (0, smart_session_1.enableSmartSession)(transaction.chain, config, userOpSigner);
|
|
33
53
|
}
|
|
54
|
+
// Smart sessions require a UserOp flow
|
|
55
|
+
return await sendUserOperationInternal(config, transaction.chain, resolvedCalls, transaction.signers);
|
|
34
56
|
}
|
|
35
|
-
async function sendTransactionInternal(config, sourceChains, targetChain, callInputs,
|
|
57
|
+
async function sendTransactionInternal(config, sourceChains, targetChain, callInputs, options) {
|
|
36
58
|
const accountAddress = (0, accounts_1.getAddress)(config);
|
|
37
|
-
|
|
38
|
-
const tokenRequests =
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
amount: 1n,
|
|
43
|
-
},
|
|
44
|
-
]
|
|
45
|
-
: initialTokenRequests;
|
|
46
|
-
const asUserOp = signers?.type === 'guardians' || signers?.type === 'session';
|
|
47
|
-
if (asUserOp) {
|
|
48
|
-
const withSession = signers?.type === 'session' ? signers.session : null;
|
|
49
|
-
if (withSession) {
|
|
50
|
-
await (0, smart_session_1.enableSmartSession)(targetChain, config, withSession);
|
|
51
|
-
}
|
|
52
|
-
// Smart sessions require a UserOp flow
|
|
53
|
-
return await sendTransactionAsUserOp(config, targetChain, callInputs, signers);
|
|
59
|
+
const resolvedCalls = await (0, utils_2.resolveCallInputs)(callInputs, config, targetChain, accountAddress);
|
|
60
|
+
const tokenRequests = (0, utils_2.getTokenRequests)(sourceChains, targetChain, options.initialTokenRequests, options.settlementLayers);
|
|
61
|
+
const sendAsUserOp = options.signers?.type === 'guardians' || options.signers?.type === 'session';
|
|
62
|
+
if (sendAsUserOp) {
|
|
63
|
+
throw new error_1.SignerNotSupportedError();
|
|
54
64
|
}
|
|
55
65
|
else {
|
|
56
|
-
return await sendTransactionAsIntent(config, sourceChains, targetChain,
|
|
66
|
+
return await sendTransactionAsIntent(config, sourceChains, targetChain, resolvedCalls, options.gasLimit, tokenRequests, accountAddress, options.signers, options.sponsored, options.settlementLayers, options.sourceAssets, options.feeAsset, options.lockFunds);
|
|
57
67
|
}
|
|
58
68
|
}
|
|
59
|
-
async function
|
|
69
|
+
async function sendUserOperationInternal(config, chain, callInputs, signers) {
|
|
60
70
|
// Make sure the account is deployed
|
|
61
71
|
await (0, accounts_1.deploy)(config, chain);
|
|
62
72
|
const withSession = signers?.type === 'session' ? signers.session : null;
|
|
@@ -83,17 +93,14 @@ async function sendTransactionAsUserOp(config, chain, callInputs, signers) {
|
|
|
83
93
|
chain: chain.id,
|
|
84
94
|
};
|
|
85
95
|
}
|
|
86
|
-
async function sendTransactionAsIntent(config, sourceChains, targetChain, callInputs, gasLimit, tokenRequests, accountAddress, signers, sponsored) {
|
|
87
|
-
const
|
|
96
|
+
async function sendTransactionAsIntent(config, sourceChains, targetChain, callInputs, gasLimit, tokenRequests, accountAddress, signers, sponsored, settlementLayers, sourceAssets, feeAsset, lockFunds) {
|
|
97
|
+
const intentRoute = await (0, utils_2.prepareTransactionAsIntent)(config, sourceChains, targetChain, callInputs, gasLimit, tokenRequests, accountAddress, sponsored ?? false, undefined, settlementLayers, sourceAssets, feeAsset, lockFunds);
|
|
88
98
|
if (!intentRoute) {
|
|
89
99
|
throw new error_1.OrderPathRequiredForIntentsError();
|
|
90
100
|
}
|
|
91
101
|
const signature = await (0, utils_2.signIntent)(config, targetChain, intentRoute.intentOp, signers);
|
|
92
102
|
const authorizations = config.eoa
|
|
93
|
-
? await (0, utils_2.signAuthorizationsInternal)(config,
|
|
94
|
-
type: 'intent',
|
|
95
|
-
intentRoute,
|
|
96
|
-
})
|
|
103
|
+
? await (0, utils_2.signAuthorizationsInternal)(config, intentRoute)
|
|
97
104
|
: [];
|
|
98
105
|
return await (0, utils_2.submitIntentInternal)(config, sourceChains, targetChain, intentRoute.intentOp, signature, authorizations);
|
|
99
106
|
}
|
|
@@ -110,14 +117,23 @@ async function waitForExecution(config, result, acceptsPreconfirmations) {
|
|
|
110
117
|
case 'intent': {
|
|
111
118
|
let intentStatus = null;
|
|
112
119
|
while (intentStatus === null || !validStatuses.has(intentStatus.status)) {
|
|
113
|
-
const orchestrator = (0, utils_2.getOrchestratorByChain)(result.targetChain, config.
|
|
120
|
+
const orchestrator = (0, utils_2.getOrchestratorByChain)(result.targetChain, config.apiKey, config.endpointUrl);
|
|
114
121
|
intentStatus = await orchestrator.getIntentOpStatus(result.id);
|
|
115
122
|
await new Promise((resolve) => setTimeout(resolve, POLLING_INTERVAL));
|
|
116
123
|
}
|
|
117
124
|
if (intentStatus.status === orchestrator_1.INTENT_STATUS_FAILED) {
|
|
118
125
|
throw new error_1.IntentFailedError();
|
|
119
126
|
}
|
|
120
|
-
return
|
|
127
|
+
return {
|
|
128
|
+
fill: {
|
|
129
|
+
hash: intentStatus.fillTransactionHash,
|
|
130
|
+
chainId: result.targetChain,
|
|
131
|
+
},
|
|
132
|
+
claims: intentStatus.claims.map((claim) => ({
|
|
133
|
+
hash: claim.claimTransactionHash,
|
|
134
|
+
chainId: claim.chainId,
|
|
135
|
+
})),
|
|
136
|
+
};
|
|
121
137
|
}
|
|
122
138
|
case 'userop': {
|
|
123
139
|
const targetChain = (0, registry_1.getChainById)(result.chain);
|
|
@@ -136,14 +152,14 @@ async function waitForExecution(config, result, acceptsPreconfirmations) {
|
|
|
136
152
|
}
|
|
137
153
|
}
|
|
138
154
|
}
|
|
139
|
-
async function getMaxSpendableAmount(config, chain, tokenAddress, gasUnits) {
|
|
155
|
+
async function getMaxSpendableAmount(config, chain, tokenAddress, gasUnits, sponsored = false) {
|
|
140
156
|
const address = (0, accounts_1.getAddress)(config);
|
|
141
|
-
const orchestrator = (0, utils_2.getOrchestratorByChain)(chain.id, config.
|
|
142
|
-
return orchestrator.getMaxTokenAmount(address, chain.id, tokenAddress, gasUnits);
|
|
157
|
+
const orchestrator = (0, utils_2.getOrchestratorByChain)(chain.id, config.apiKey, config.endpointUrl);
|
|
158
|
+
return orchestrator.getMaxTokenAmount(address, chain.id, tokenAddress, gasUnits, sponsored);
|
|
143
159
|
}
|
|
144
160
|
async function getPortfolio(config, onTestnets) {
|
|
145
161
|
const address = (0, accounts_1.getAddress)(config);
|
|
146
162
|
const chainId = onTestnets ? chains_1.sepolia.id : chains_1.mainnet.id;
|
|
147
|
-
const orchestrator = (0, utils_2.getOrchestratorByChain)(chainId, config.
|
|
163
|
+
const orchestrator = (0, utils_2.getOrchestratorByChain)(chainId, config.apiKey, config.endpointUrl);
|
|
148
164
|
return orchestrator.getPortfolio(address);
|
|
149
165
|
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { type Address, type Chain } from 'viem';
|
|
2
|
+
import type { IntentOp } from '../orchestrator/types';
|
|
3
|
+
import type { RhinestoneConfig } from '../types';
|
|
4
|
+
import type { BatchPermit2Result, MultiChainPermit2Config, MultiChainPermit2Result, TokenPermissions } from './types';
|
|
5
|
+
declare function getTypedData(intentOp: IntentOp): {
|
|
6
|
+
readonly domain: {
|
|
7
|
+
readonly name: "Permit2";
|
|
8
|
+
readonly chainId: number;
|
|
9
|
+
readonly verifyingContract: "0x000000000022D473030F116dDEE9F6B43aC78BA3";
|
|
10
|
+
};
|
|
11
|
+
readonly types: {
|
|
12
|
+
readonly TokenPermissions: readonly [{
|
|
13
|
+
readonly name: "token";
|
|
14
|
+
readonly type: "address";
|
|
15
|
+
}, {
|
|
16
|
+
readonly name: "amount";
|
|
17
|
+
readonly type: "uint256";
|
|
18
|
+
}];
|
|
19
|
+
readonly Token: readonly [{
|
|
20
|
+
readonly name: "token";
|
|
21
|
+
readonly type: "address";
|
|
22
|
+
}, {
|
|
23
|
+
readonly name: "amount";
|
|
24
|
+
readonly type: "uint256";
|
|
25
|
+
}];
|
|
26
|
+
readonly Target: readonly [{
|
|
27
|
+
readonly name: "recipient";
|
|
28
|
+
readonly type: "address";
|
|
29
|
+
}, {
|
|
30
|
+
readonly name: "tokenOut";
|
|
31
|
+
readonly type: "Token[]";
|
|
32
|
+
}, {
|
|
33
|
+
readonly name: "targetChain";
|
|
34
|
+
readonly type: "uint256";
|
|
35
|
+
}, {
|
|
36
|
+
readonly name: "fillExpiry";
|
|
37
|
+
readonly type: "uint256";
|
|
38
|
+
}];
|
|
39
|
+
readonly Op: readonly [{
|
|
40
|
+
readonly name: "to";
|
|
41
|
+
readonly type: "address";
|
|
42
|
+
}, {
|
|
43
|
+
readonly name: "value";
|
|
44
|
+
readonly type: "uint256";
|
|
45
|
+
}, {
|
|
46
|
+
readonly name: "data";
|
|
47
|
+
readonly type: "bytes";
|
|
48
|
+
}];
|
|
49
|
+
readonly Mandate: readonly [{
|
|
50
|
+
readonly name: "target";
|
|
51
|
+
readonly type: "Target";
|
|
52
|
+
}, {
|
|
53
|
+
readonly name: "v";
|
|
54
|
+
readonly type: "uint8";
|
|
55
|
+
}, {
|
|
56
|
+
readonly name: "minGas";
|
|
57
|
+
readonly type: "uint128";
|
|
58
|
+
}, {
|
|
59
|
+
readonly name: "originOps";
|
|
60
|
+
readonly type: "Op[]";
|
|
61
|
+
}, {
|
|
62
|
+
readonly name: "destOps";
|
|
63
|
+
readonly type: "Op[]";
|
|
64
|
+
}, {
|
|
65
|
+
readonly name: "q";
|
|
66
|
+
readonly type: "bytes32";
|
|
67
|
+
}];
|
|
68
|
+
readonly PermitBatchWitnessTransferFrom: readonly [{
|
|
69
|
+
readonly name: "permitted";
|
|
70
|
+
readonly type: "TokenPermissions[]";
|
|
71
|
+
}, {
|
|
72
|
+
readonly name: "spender";
|
|
73
|
+
readonly type: "address";
|
|
74
|
+
}, {
|
|
75
|
+
readonly name: "nonce";
|
|
76
|
+
readonly type: "uint256";
|
|
77
|
+
}, {
|
|
78
|
+
readonly name: "deadline";
|
|
79
|
+
readonly type: "uint256";
|
|
80
|
+
}, {
|
|
81
|
+
readonly name: "mandate";
|
|
82
|
+
readonly type: "Mandate";
|
|
83
|
+
}];
|
|
84
|
+
};
|
|
85
|
+
readonly primaryType: "PermitBatchWitnessTransferFrom";
|
|
86
|
+
readonly message: {
|
|
87
|
+
readonly permitted: TokenPermissions[];
|
|
88
|
+
readonly spender: `0x${string}`;
|
|
89
|
+
readonly nonce: bigint;
|
|
90
|
+
readonly deadline: bigint;
|
|
91
|
+
readonly mandate: {
|
|
92
|
+
readonly target: {
|
|
93
|
+
readonly recipient: `0x${string}`;
|
|
94
|
+
readonly tokenOut: {
|
|
95
|
+
token: `0x${string}`;
|
|
96
|
+
amount: bigint;
|
|
97
|
+
}[];
|
|
98
|
+
readonly targetChain: bigint;
|
|
99
|
+
readonly fillExpiry: bigint;
|
|
100
|
+
};
|
|
101
|
+
readonly v: number;
|
|
102
|
+
readonly minGas: bigint;
|
|
103
|
+
readonly originOps: {
|
|
104
|
+
to: `0x${string}`;
|
|
105
|
+
value: bigint;
|
|
106
|
+
data: `0x${string}`;
|
|
107
|
+
}[];
|
|
108
|
+
readonly destOps: {
|
|
109
|
+
to: `0x${string}`;
|
|
110
|
+
value: bigint;
|
|
111
|
+
data: `0x${string}`;
|
|
112
|
+
}[];
|
|
113
|
+
readonly q: `0x${string}`;
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
declare function checkERC20AllowanceDirect(owner: Address, spender: Address, tokenAddress: Address, publicClient: any): Promise<bigint>;
|
|
118
|
+
declare function checkERC20Allowance(tokenAddress: Address, chain: Chain, config: RhinestoneConfig): Promise<bigint>;
|
|
119
|
+
/**
|
|
120
|
+
* Get the Permit2 contract address
|
|
121
|
+
* @returns The Permit2 contract address
|
|
122
|
+
*/
|
|
123
|
+
declare function getPermit2Address(): Address;
|
|
124
|
+
/**
|
|
125
|
+
* Signs permit2 calls across multiple chains using batch approach.
|
|
126
|
+
* Collects all signatures first, then returns them all at once.
|
|
127
|
+
*
|
|
128
|
+
* This approach is efficient for backend signers but may be memory-intensive
|
|
129
|
+
* for frontend applications with many chains.
|
|
130
|
+
*
|
|
131
|
+
* @param configs - Array of permit2 signing configurations for different chains
|
|
132
|
+
* @returns Promise<BatchPermit2Result> - All signatures collected
|
|
133
|
+
*/
|
|
134
|
+
declare function signPermit2Batch(configs: MultiChainPermit2Config[]): Promise<BatchPermit2Result>;
|
|
135
|
+
/**
|
|
136
|
+
* Signs permit2 calls across multiple chains sequentially.
|
|
137
|
+
* Signs one by one, useful for frontend applications to avoid memory issues.
|
|
138
|
+
*
|
|
139
|
+
* This approach is more memory-efficient for frontend applications but slower
|
|
140
|
+
* due to sequential processing.
|
|
141
|
+
*
|
|
142
|
+
* @param configs - Array of permit2 signing configurations for different chains
|
|
143
|
+
* @param onProgress - Optional callback for progress updates
|
|
144
|
+
* @returns Promise<BatchPermit2Result> - All signatures collected
|
|
145
|
+
*/
|
|
146
|
+
declare function signPermit2Sequential(configs: MultiChainPermit2Config[], onProgress?: (completed: number, total: number, current: MultiChainPermit2Result) => void): Promise<BatchPermit2Result>;
|
|
147
|
+
export { getTypedData, checkERC20Allowance, checkERC20AllowanceDirect, getPermit2Address, signPermit2Batch, signPermit2Sequential, type MultiChainPermit2Config, type MultiChainPermit2Result, type BatchPermit2Result, };
|
|
148
|
+
//# sourceMappingURL=permit2.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permit2.d.ts","sourceRoot":"","sources":["../../../execution/permit2.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,KAAK,EAIX,MAAM,MAAM,CAAA;AAEb,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAChD,OAAO,KAAK,EACV,kBAAkB,EAClB,uBAAuB,EACvB,uBAAuB,EACvB,gBAAgB,EACjB,MAAM,SAAS,CAAA;AAQhB,iBAAS,YAAY,CAAC,QAAQ,EAAE,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8FvC;AAED,iBAAe,yBAAyB,CACtC,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,OAAO,EACrB,YAAY,EAAE,GAAG,GAChB,OAAO,CAAC,MAAM,CAAC,CAyBjB;AAED,iBAAe,mBAAmB,CAChC,YAAY,EAAE,OAAO,EACrB,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAAC,MAAM,CAAC,CAuBjB;AAED;;;GAGG;AACH,iBAAS,iBAAiB,IAAI,OAAO,CAEpC;AAED;;;;;;;;;GASG;AACH,iBAAe,gBAAgB,CAC7B,OAAO,EAAE,uBAAuB,EAAE,GACjC,OAAO,CAAC,kBAAkB,CAAC,CAiE7B;AAED;;;;;;;;;;GAUG;AACH,iBAAe,qBAAqB,CAClC,OAAO,EAAE,uBAAuB,EAAE,EAClC,UAAU,CAAC,EAAE,CACX,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,uBAAuB,KAC7B,IAAI,GACR,OAAO,CAAC,kBAAkB,CAAC,CAsD7B;AAED,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,yBAAyB,EACzB,iBAAiB,EAEjB,gBAAgB,EAChB,qBAAqB,EAErB,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,GACxB,CAAA"}
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getTypedData = getTypedData;
|
|
4
|
+
exports.checkERC20Allowance = checkERC20Allowance;
|
|
5
|
+
exports.checkERC20AllowanceDirect = checkERC20AllowanceDirect;
|
|
6
|
+
exports.getPermit2Address = getPermit2Address;
|
|
7
|
+
exports.signPermit2Batch = signPermit2Batch;
|
|
8
|
+
exports.signPermit2Sequential = signPermit2Sequential;
|
|
9
|
+
const viem_1 = require("viem");
|
|
10
|
+
const utils_1 = require("../accounts/utils");
|
|
11
|
+
const PERMIT2_ADDRESS = '0x000000000022D473030F116dDEE9F6B43aC78BA3';
|
|
12
|
+
function toToken(id) {
|
|
13
|
+
return `0x${(id & ((1n << 160n) - 1n)).toString(16).padStart(40, '0')}`;
|
|
14
|
+
}
|
|
15
|
+
function getTypedData(intentOp) {
|
|
16
|
+
const element = intentOp.elements[0];
|
|
17
|
+
const tokens = element.idsAndAmounts.map(([id, amount]) => [
|
|
18
|
+
BigInt(id),
|
|
19
|
+
BigInt(amount),
|
|
20
|
+
]);
|
|
21
|
+
const tokenPermissions = tokens.reduce((permissions, [id, amountIn]) => {
|
|
22
|
+
const token = toToken(BigInt(id));
|
|
23
|
+
const amount = BigInt(amountIn);
|
|
24
|
+
const permission = { token, amount };
|
|
25
|
+
permissions.push(permission);
|
|
26
|
+
return permissions;
|
|
27
|
+
}, []);
|
|
28
|
+
const spender = element.arbiter;
|
|
29
|
+
const mandate = element.mandate;
|
|
30
|
+
const typedData = {
|
|
31
|
+
domain: {
|
|
32
|
+
name: 'Permit2',
|
|
33
|
+
chainId: Number(intentOp.elements[0].chainId),
|
|
34
|
+
verifyingContract: PERMIT2_ADDRESS,
|
|
35
|
+
},
|
|
36
|
+
types: {
|
|
37
|
+
TokenPermissions: [
|
|
38
|
+
{ name: 'token', type: 'address' },
|
|
39
|
+
{ name: 'amount', type: 'uint256' },
|
|
40
|
+
],
|
|
41
|
+
Token: [
|
|
42
|
+
{ name: 'token', type: 'address' },
|
|
43
|
+
{ name: 'amount', type: 'uint256' },
|
|
44
|
+
],
|
|
45
|
+
Target: [
|
|
46
|
+
{ name: 'recipient', type: 'address' },
|
|
47
|
+
{ name: 'tokenOut', type: 'Token[]' },
|
|
48
|
+
{ name: 'targetChain', type: 'uint256' },
|
|
49
|
+
{ name: 'fillExpiry', type: 'uint256' },
|
|
50
|
+
],
|
|
51
|
+
Op: [
|
|
52
|
+
{ name: 'to', type: 'address' },
|
|
53
|
+
{ name: 'value', type: 'uint256' },
|
|
54
|
+
{ name: 'data', type: 'bytes' },
|
|
55
|
+
],
|
|
56
|
+
Mandate: [
|
|
57
|
+
{ name: 'target', type: 'Target' },
|
|
58
|
+
{ name: 'v', type: 'uint8' },
|
|
59
|
+
{ name: 'minGas', type: 'uint128' },
|
|
60
|
+
{ name: 'originOps', type: 'Op[]' },
|
|
61
|
+
{ name: 'destOps', type: 'Op[]' },
|
|
62
|
+
{ name: 'q', type: 'bytes32' },
|
|
63
|
+
],
|
|
64
|
+
PermitBatchWitnessTransferFrom: [
|
|
65
|
+
{ name: 'permitted', type: 'TokenPermissions[]' },
|
|
66
|
+
{ name: 'spender', type: 'address' },
|
|
67
|
+
{ name: 'nonce', type: 'uint256' },
|
|
68
|
+
{ name: 'deadline', type: 'uint256' },
|
|
69
|
+
{ name: 'mandate', type: 'Mandate' },
|
|
70
|
+
],
|
|
71
|
+
},
|
|
72
|
+
primaryType: 'PermitBatchWitnessTransferFrom',
|
|
73
|
+
message: {
|
|
74
|
+
permitted: tokenPermissions,
|
|
75
|
+
spender: spender,
|
|
76
|
+
nonce: BigInt(intentOp.nonce),
|
|
77
|
+
deadline: BigInt(intentOp.expires),
|
|
78
|
+
mandate: {
|
|
79
|
+
target: {
|
|
80
|
+
recipient: mandate.recipient,
|
|
81
|
+
tokenOut: mandate.tokenOut.map((token) => ({
|
|
82
|
+
token: toToken(BigInt(token[0])),
|
|
83
|
+
amount: BigInt(token[1]),
|
|
84
|
+
})),
|
|
85
|
+
targetChain: BigInt(mandate.destinationChainId),
|
|
86
|
+
fillExpiry: BigInt(mandate.fillDeadline),
|
|
87
|
+
},
|
|
88
|
+
v: mandate.v || 0,
|
|
89
|
+
minGas: BigInt(mandate.minGas || '0'),
|
|
90
|
+
originOps: mandate.preClaimOps.map((op) => ({
|
|
91
|
+
to: op.to,
|
|
92
|
+
value: BigInt(op.value),
|
|
93
|
+
data: op.data,
|
|
94
|
+
})),
|
|
95
|
+
destOps: mandate.destinationOps.map((op) => ({
|
|
96
|
+
to: op.to,
|
|
97
|
+
value: BigInt(op.value),
|
|
98
|
+
data: op.data,
|
|
99
|
+
})),
|
|
100
|
+
q: (0, viem_1.keccak256)(mandate.qualifier.encodedVal),
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
return typedData;
|
|
105
|
+
}
|
|
106
|
+
async function checkERC20AllowanceDirect(owner, spender, tokenAddress, publicClient) {
|
|
107
|
+
try {
|
|
108
|
+
const allowance = await publicClient.readContract({
|
|
109
|
+
address: tokenAddress,
|
|
110
|
+
abi: [
|
|
111
|
+
{
|
|
112
|
+
name: 'allowance',
|
|
113
|
+
type: 'function',
|
|
114
|
+
stateMutability: 'view',
|
|
115
|
+
inputs: [
|
|
116
|
+
{ name: 'owner', type: 'address' },
|
|
117
|
+
{ name: 'spender', type: 'address' },
|
|
118
|
+
],
|
|
119
|
+
outputs: [{ name: '', type: 'uint256' }],
|
|
120
|
+
},
|
|
121
|
+
],
|
|
122
|
+
functionName: 'allowance',
|
|
123
|
+
args: [owner, spender],
|
|
124
|
+
});
|
|
125
|
+
return BigInt(allowance.toString());
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
console.error('Error checking ERC20 allowance:', error);
|
|
129
|
+
throw new Error('Failed to check ERC20 allowance');
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
async function checkERC20Allowance(tokenAddress, chain, config) {
|
|
133
|
+
try {
|
|
134
|
+
const publicClient = (0, viem_1.createPublicClient)({
|
|
135
|
+
chain,
|
|
136
|
+
transport: (0, utils_1.createTransport)(chain, config.provider),
|
|
137
|
+
});
|
|
138
|
+
// Get the account owner from the config
|
|
139
|
+
const owner = config.eoa?.address;
|
|
140
|
+
if (!owner) {
|
|
141
|
+
throw new Error('No EOA address found in account config');
|
|
142
|
+
}
|
|
143
|
+
return await checkERC20AllowanceDirect(owner, PERMIT2_ADDRESS, tokenAddress, publicClient);
|
|
144
|
+
}
|
|
145
|
+
catch (error) {
|
|
146
|
+
console.error('Error checking ERC20 allowance:', error);
|
|
147
|
+
throw new Error('Failed to check ERC20 allowance');
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Get the Permit2 contract address
|
|
152
|
+
* @returns The Permit2 contract address
|
|
153
|
+
*/
|
|
154
|
+
function getPermit2Address() {
|
|
155
|
+
return PERMIT2_ADDRESS;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Signs permit2 calls across multiple chains using batch approach.
|
|
159
|
+
* Collects all signatures first, then returns them all at once.
|
|
160
|
+
*
|
|
161
|
+
* This approach is efficient for backend signers but may be memory-intensive
|
|
162
|
+
* for frontend applications with many chains.
|
|
163
|
+
*
|
|
164
|
+
* @param configs - Array of permit2 signing configurations for different chains
|
|
165
|
+
* @returns Promise<BatchPermit2Result> - All signatures collected
|
|
166
|
+
*/
|
|
167
|
+
async function signPermit2Batch(configs) {
|
|
168
|
+
const results = [];
|
|
169
|
+
let successfulSignatures = 0;
|
|
170
|
+
let failedSignatures = 0;
|
|
171
|
+
// Process all signing operations in parallel
|
|
172
|
+
const signingPromises = configs.map(async (config) => {
|
|
173
|
+
try {
|
|
174
|
+
// Get typed data for this chain
|
|
175
|
+
const typedData = getTypedData(config.intentOp);
|
|
176
|
+
// Sign with EOA account
|
|
177
|
+
if (!config.eoaAccount.signTypedData) {
|
|
178
|
+
throw new Error('EOA account does not support typed data signing');
|
|
179
|
+
}
|
|
180
|
+
const signature = await config.eoaAccount.signTypedData(typedData);
|
|
181
|
+
const result = {
|
|
182
|
+
chainId: config.chain.id,
|
|
183
|
+
signature,
|
|
184
|
+
success: true,
|
|
185
|
+
};
|
|
186
|
+
successfulSignatures++;
|
|
187
|
+
return result;
|
|
188
|
+
}
|
|
189
|
+
catch (error) {
|
|
190
|
+
const result = {
|
|
191
|
+
chainId: config.chain.id,
|
|
192
|
+
signature: '0x',
|
|
193
|
+
success: false,
|
|
194
|
+
error: error instanceof Error ? error : new Error(String(error)),
|
|
195
|
+
};
|
|
196
|
+
failedSignatures++;
|
|
197
|
+
return result;
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
// Wait for all signing operations to complete
|
|
201
|
+
const signingResults = await Promise.allSettled(signingPromises);
|
|
202
|
+
// Process results
|
|
203
|
+
for (const result of signingResults) {
|
|
204
|
+
if (result.status === 'fulfilled') {
|
|
205
|
+
results.push(result.value);
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
// This shouldn't happen since we catch errors in the promise
|
|
209
|
+
failedSignatures++;
|
|
210
|
+
results.push({
|
|
211
|
+
chainId: 0,
|
|
212
|
+
signature: '0x',
|
|
213
|
+
success: false,
|
|
214
|
+
error: result.reason,
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return {
|
|
219
|
+
results,
|
|
220
|
+
totalChains: configs.length,
|
|
221
|
+
successfulSignatures,
|
|
222
|
+
failedSignatures,
|
|
223
|
+
allSuccessful: failedSignatures === 0,
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Signs permit2 calls across multiple chains sequentially.
|
|
228
|
+
* Signs one by one, useful for frontend applications to avoid memory issues.
|
|
229
|
+
*
|
|
230
|
+
* This approach is more memory-efficient for frontend applications but slower
|
|
231
|
+
* due to sequential processing.
|
|
232
|
+
*
|
|
233
|
+
* @param configs - Array of permit2 signing configurations for different chains
|
|
234
|
+
* @param onProgress - Optional callback for progress updates
|
|
235
|
+
* @returns Promise<BatchPermit2Result> - All signatures collected
|
|
236
|
+
*/
|
|
237
|
+
async function signPermit2Sequential(configs, onProgress) {
|
|
238
|
+
const results = [];
|
|
239
|
+
let successfulSignatures = 0;
|
|
240
|
+
let failedSignatures = 0;
|
|
241
|
+
// Process signing operations sequentially
|
|
242
|
+
for (let i = 0; i < configs.length; i++) {
|
|
243
|
+
const config = configs[i];
|
|
244
|
+
try {
|
|
245
|
+
// Get typed data for this chain
|
|
246
|
+
const typedData = getTypedData(config.intentOp);
|
|
247
|
+
// Sign with EOA account
|
|
248
|
+
if (!config.eoaAccount.signTypedData) {
|
|
249
|
+
throw new Error('EOA account does not support typed data signing');
|
|
250
|
+
}
|
|
251
|
+
const signature = await config.eoaAccount.signTypedData(typedData);
|
|
252
|
+
const result = {
|
|
253
|
+
chainId: config.chain.id,
|
|
254
|
+
signature,
|
|
255
|
+
success: true,
|
|
256
|
+
};
|
|
257
|
+
results.push(result);
|
|
258
|
+
successfulSignatures++;
|
|
259
|
+
// Call progress callback if provided
|
|
260
|
+
onProgress?.(i + 1, configs.length, result);
|
|
261
|
+
}
|
|
262
|
+
catch (error) {
|
|
263
|
+
const result = {
|
|
264
|
+
chainId: config.chain.id,
|
|
265
|
+
signature: '0x',
|
|
266
|
+
success: false,
|
|
267
|
+
error: error instanceof Error ? error : new Error(String(error)),
|
|
268
|
+
};
|
|
269
|
+
results.push(result);
|
|
270
|
+
failedSignatures++;
|
|
271
|
+
// Call progress callback if provided
|
|
272
|
+
onProgress?.(i + 1, configs.length, result);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
return {
|
|
276
|
+
results,
|
|
277
|
+
totalChains: configs.length,
|
|
278
|
+
successfulSignatures,
|
|
279
|
+
failedSignatures,
|
|
280
|
+
allSuccessful: failedSignatures === 0,
|
|
281
|
+
};
|
|
282
|
+
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { type Chain, type Hex } from 'viem';
|
|
2
2
|
import { type ChainDigest, type EnableSessionData, type SmartSessionModeType } from '../modules/validators/smart-sessions';
|
|
3
|
-
import type {
|
|
3
|
+
import type { RhinestoneConfig, Session } from '../types';
|
|
4
4
|
interface SessionDetails {
|
|
5
5
|
permissionEnableHash: Hex;
|
|
6
6
|
mode: SmartSessionModeType;
|
|
7
7
|
hashesAndChainIds: ChainDigest[];
|
|
8
8
|
enableSessionData: EnableSessionData;
|
|
9
9
|
}
|
|
10
|
-
declare function getSessionDetails(config:
|
|
10
|
+
declare function getSessionDetails(config: RhinestoneConfig, sessions: Session[], sessionIndex: number, signature?: Hex): Promise<SessionDetails>;
|
|
11
11
|
declare function getMultichainDigest(chainDigests: ChainDigest[]): Hex;
|
|
12
|
-
declare function enableSmartSession(chain: Chain, config:
|
|
12
|
+
declare function enableSmartSession(chain: Chain, config: RhinestoneConfig, session: Session): Promise<void>;
|
|
13
13
|
export { enableSmartSession, getSessionDetails, getMultichainDigest };
|
|
14
14
|
export type { SessionDetails };
|
|
15
15
|
//# sourceMappingURL=smart-session.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smart-session.d.ts","sourceRoot":"","sources":["../../../execution/smart-session.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,KAAK,EAIV,KAAK,GAAG,EAGT,MAAM,MAAM,CAAA;AAmBb,OAAO,EACL,KAAK,WAAW,EAEhB,KAAK,iBAAiB,EAGtB,KAAK,oBAAoB,EAC1B,MAAM,sCAAsC,CAAA;AAC7C,OAAO,KAAK,EAGV,
|
|
1
|
+
{"version":3,"file":"smart-session.d.ts","sourceRoot":"","sources":["../../../execution/smart-session.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,KAAK,EAIV,KAAK,GAAG,EAGT,MAAM,MAAM,CAAA;AAmBb,OAAO,EACL,KAAK,WAAW,EAEhB,KAAK,iBAAiB,EAGtB,KAAK,oBAAoB,EAC1B,MAAM,sCAAsC,CAAA;AAC7C,OAAO,KAAK,EAGV,gBAAgB,EAChB,OAAO,EACR,MAAM,UAAU,CAAA;AAGjB,UAAU,cAAc;IACtB,oBAAoB,EAAE,GAAG,CAAA;IACzB,IAAI,EAAE,oBAAoB,CAAA;IAC1B,iBAAiB,EAAE,WAAW,EAAE,CAAA;IAChC,iBAAiB,EAAE,iBAAiB,CAAA;CACrC;AAED,iBAAe,iBAAiB,CAC9B,MAAM,EAAE,gBAAgB,EACxB,QAAQ,EAAE,OAAO,EAAE,EACnB,YAAY,EAAE,MAAM,EACpB,SAAS,CAAC,EAAE,GAAG,GACd,OAAO,CAAC,cAAc,CAAC,CA4BzB;AAgGD,iBAAS,mBAAmB,CAAC,YAAY,EAAE,WAAW,EAAE,GAAG,GAAG,CAgC7D;AAiLD,iBAAe,kBAAkB,CAC/B,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,gBAAgB,EACxB,OAAO,EAAE,OAAO,iBA+BjB;AAED,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,CAAA;AACrE,YAAY,EAAE,cAAc,EAAE,CAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Account, Address, Chain, Hex } from 'viem';
|
|
2
|
+
import type { IntentOp } from '../orchestrator/types';
|
|
3
|
+
interface TokenPermissions {
|
|
4
|
+
token: Address;
|
|
5
|
+
amount: bigint;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Multi-chain permit2 signing configuration
|
|
9
|
+
*/
|
|
10
|
+
interface MultiChainPermit2Config {
|
|
11
|
+
chain: Chain;
|
|
12
|
+
intentOp: IntentOp;
|
|
13
|
+
eoaAccount: Account;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Result of a multi-chain permit2 signing operation
|
|
17
|
+
*/
|
|
18
|
+
interface MultiChainPermit2Result {
|
|
19
|
+
chainId: number;
|
|
20
|
+
signature: Hex;
|
|
21
|
+
success: boolean;
|
|
22
|
+
error?: Error;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Batch permit2 signing result
|
|
26
|
+
*/
|
|
27
|
+
interface BatchPermit2Result {
|
|
28
|
+
results: MultiChainPermit2Result[];
|
|
29
|
+
totalChains: number;
|
|
30
|
+
successfulSignatures: number;
|
|
31
|
+
failedSignatures: number;
|
|
32
|
+
allSuccessful: boolean;
|
|
33
|
+
}
|
|
34
|
+
export type { TokenPermissions, MultiChainPermit2Config, MultiChainPermit2Result, BatchPermit2Result, };
|
|
35
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../execution/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AACxD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAErD,UAAU,gBAAgB;IACxB,KAAK,EAAE,OAAO,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;CACf;AAED;;GAEG;AACH,UAAU,uBAAuB;IAC/B,KAAK,EAAE,KAAK,CAAA;IACZ,QAAQ,EAAE,QAAQ,CAAA;IAClB,UAAU,EAAE,OAAO,CAAA;CACpB;AAED;;GAEG;AACH,UAAU,uBAAuB;IAC/B,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,GAAG,CAAA;IACd,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,CAAC,EAAE,KAAK,CAAA;CACd;AAED;;GAEG;AACH,UAAU,kBAAkB;IAC1B,OAAO,EAAE,uBAAuB,EAAE,CAAA;IAClC,WAAW,EAAE,MAAM,CAAA;IACnB,oBAAoB,EAAE,MAAM,CAAA;IAC5B,gBAAgB,EAAE,MAAM,CAAA;IACxB,aAAa,EAAE,OAAO,CAAA;CACvB;AAED,YAAY,EACV,gBAAgB,EAChB,uBAAuB,EACvB,uBAAuB,EACvB,kBAAkB,GACnB,CAAA"}
|