@rhinestone/sdk 1.0.0-alpha.31 → 1.0.0-alpha.33
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/index.d.ts +18 -18
- package/dist/src/accounts/index.d.ts.map +1 -1
- package/dist/src/accounts/index.js +12 -8
- package/dist/src/accounts/index.test.js +0 -2
- package/dist/src/accounts/kernel.test.js +0 -6
- package/dist/src/accounts/nexus.test.js +0 -6
- package/dist/src/accounts/safe.test.js +0 -6
- package/dist/src/accounts/signing/common.d.ts +3 -3
- package/dist/src/accounts/signing/common.d.ts.map +1 -1
- package/dist/src/accounts/signing/common.js +10 -8
- 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 +3 -3
- 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 +2 -2
- package/dist/src/accounts/utils.d.ts.map +1 -1
- 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 +5 -176
- package/dist/src/actions/index.d.ts.map +1 -1
- package/dist/src/actions/index.js +10 -563
- 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 +2 -7
- package/dist/src/execution/compact.d.ts.map +1 -1
- package/dist/src/execution/compact.js +1 -100
- package/dist/src/execution/error.d.ts +2 -16
- package/dist/src/execution/error.d.ts.map +1 -1
- package/dist/src/execution/error.js +4 -22
- package/dist/src/execution/index.d.ts +24 -24
- package/dist/src/execution/index.d.ts.map +1 -1
- package/dist/src/execution/index.js +39 -25
- 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/utils.d.ts +33 -29
- package/dist/src/execution/utils.d.ts.map +1 -1
- package/dist/src/execution/utils.js +81 -72
- package/dist/src/index.d.ts +28 -16
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +69 -65
- package/dist/src/modules/index.d.ts +2 -2
- package/dist/src/modules/index.d.ts.map +1 -1
- package/dist/src/modules/index.js +1 -1
- package/dist/src/modules/index.test.js +0 -4
- package/dist/src/modules/validators/smart-sessions.test.js +0 -3
- package/dist/src/orchestrator/types.d.ts +1 -6
- package/dist/src/orchestrator/types.d.ts.map +1 -1
- package/dist/src/types.d.ts +23 -4
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +36 -1
- 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
|
@@ -1,8 +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
5
|
exports.sendTransactionInternal = sendTransactionInternal;
|
|
6
|
+
exports.sendUserOperation = sendUserOperation;
|
|
7
|
+
exports.sendUserOperationInternal = sendUserOperationInternal;
|
|
6
8
|
exports.waitForExecution = waitForExecution;
|
|
7
9
|
exports.getMaxSpendableAmount = getMaxSpendableAmount;
|
|
8
10
|
exports.getPortfolio = getPortfolio;
|
|
@@ -18,9 +20,7 @@ Object.defineProperty(exports, "IntentFailedError", { enumerable: true, get: fun
|
|
|
18
20
|
Object.defineProperty(exports, "isExecutionError", { enumerable: true, get: function () { return error_1.isExecutionError; } });
|
|
19
21
|
Object.defineProperty(exports, "OrderPathRequiredForIntentsError", { enumerable: true, get: function () { return error_1.OrderPathRequiredForIntentsError; } });
|
|
20
22
|
Object.defineProperty(exports, "SessionChainRequiredError", { enumerable: true, get: function () { return error_1.SessionChainRequiredError; } });
|
|
21
|
-
Object.defineProperty(exports, "
|
|
22
|
-
Object.defineProperty(exports, "SourceChainsNotAvailableForUserOpFlowError", { enumerable: true, get: function () { return error_1.SourceChainsNotAvailableForUserOpFlowError; } });
|
|
23
|
-
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; } });
|
|
24
24
|
const smart_session_1 = require("./smart-session");
|
|
25
25
|
const utils_2 = require("./utils");
|
|
26
26
|
const POLLING_INTERVAL = 500;
|
|
@@ -30,6 +30,10 @@ async function sendTransaction(config, transaction) {
|
|
|
30
30
|
: transaction.sourceChains || [];
|
|
31
31
|
const targetChain = 'chain' in transaction ? transaction.chain : transaction.targetChain;
|
|
32
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();
|
|
36
|
+
}
|
|
33
37
|
return await sendTransactionInternal(config, sourceChains, targetChain, calls, {
|
|
34
38
|
gasLimit,
|
|
35
39
|
initialTokenRequests: tokenRequests,
|
|
@@ -40,25 +44,29 @@ async function sendTransaction(config, transaction) {
|
|
|
40
44
|
feeAsset,
|
|
41
45
|
});
|
|
42
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);
|
|
53
|
+
}
|
|
54
|
+
// Smart sessions require a UserOp flow
|
|
55
|
+
return await sendUserOperationInternal(config, transaction.chain, resolvedCalls, transaction.signers);
|
|
56
|
+
}
|
|
43
57
|
async function sendTransactionInternal(config, sourceChains, targetChain, callInputs, options) {
|
|
44
58
|
const accountAddress = (0, accounts_1.getAddress)(config);
|
|
59
|
+
const resolvedCalls = await (0, utils_2.resolveCallInputs)(callInputs, config, targetChain, accountAddress);
|
|
45
60
|
const tokenRequests = (0, utils_2.getTokenRequests)(sourceChains, targetChain, options.initialTokenRequests, options.settlementLayers);
|
|
46
|
-
const sendAsUserOp = options.
|
|
47
|
-
options.signers?.type === 'guardians' ||
|
|
48
|
-
options.signers?.type === 'session';
|
|
61
|
+
const sendAsUserOp = options.signers?.type === 'guardians' || options.signers?.type === 'session';
|
|
49
62
|
if (sendAsUserOp) {
|
|
50
|
-
|
|
51
|
-
if (withSession) {
|
|
52
|
-
await (0, smart_session_1.enableSmartSession)(targetChain, config, withSession);
|
|
53
|
-
}
|
|
54
|
-
// Smart sessions require a UserOp flow
|
|
55
|
-
return await sendTransactionAsUserOp(config, targetChain, callInputs, options.signers);
|
|
63
|
+
throw new error_1.SignerNotSupportedError();
|
|
56
64
|
}
|
|
57
65
|
else {
|
|
58
|
-
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);
|
|
59
67
|
}
|
|
60
68
|
}
|
|
61
|
-
async function
|
|
69
|
+
async function sendUserOperationInternal(config, chain, callInputs, signers) {
|
|
62
70
|
// Make sure the account is deployed
|
|
63
71
|
await (0, accounts_1.deploy)(config, chain);
|
|
64
72
|
const withSession = signers?.type === 'session' ? signers.session : null;
|
|
@@ -85,17 +93,14 @@ async function sendTransactionAsUserOp(config, chain, callInputs, signers) {
|
|
|
85
93
|
chain: chain.id,
|
|
86
94
|
};
|
|
87
95
|
}
|
|
88
|
-
async function sendTransactionAsIntent(config, sourceChains, targetChain, callInputs, gasLimit, tokenRequests, accountAddress, signers, sponsored, settlementLayers, sourceAssets, feeAsset) {
|
|
89
|
-
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);
|
|
90
98
|
if (!intentRoute) {
|
|
91
99
|
throw new error_1.OrderPathRequiredForIntentsError();
|
|
92
100
|
}
|
|
93
101
|
const signature = await (0, utils_2.signIntent)(config, targetChain, intentRoute.intentOp, signers);
|
|
94
102
|
const authorizations = config.eoa
|
|
95
|
-
? await (0, utils_2.signAuthorizationsInternal)(config,
|
|
96
|
-
type: 'intent',
|
|
97
|
-
intentRoute,
|
|
98
|
-
})
|
|
103
|
+
? await (0, utils_2.signAuthorizationsInternal)(config, intentRoute)
|
|
99
104
|
: [];
|
|
100
105
|
return await (0, utils_2.submitIntentInternal)(config, sourceChains, targetChain, intentRoute.intentOp, signature, authorizations);
|
|
101
106
|
}
|
|
@@ -112,14 +117,23 @@ async function waitForExecution(config, result, acceptsPreconfirmations) {
|
|
|
112
117
|
case 'intent': {
|
|
113
118
|
let intentStatus = null;
|
|
114
119
|
while (intentStatus === null || !validStatuses.has(intentStatus.status)) {
|
|
115
|
-
const orchestrator = (0, utils_2.getOrchestratorByChain)(result.targetChain, config.
|
|
120
|
+
const orchestrator = (0, utils_2.getOrchestratorByChain)(result.targetChain, config.apiKey, config.endpointUrl);
|
|
116
121
|
intentStatus = await orchestrator.getIntentOpStatus(result.id);
|
|
117
122
|
await new Promise((resolve) => setTimeout(resolve, POLLING_INTERVAL));
|
|
118
123
|
}
|
|
119
124
|
if (intentStatus.status === orchestrator_1.INTENT_STATUS_FAILED) {
|
|
120
125
|
throw new error_1.IntentFailedError();
|
|
121
126
|
}
|
|
122
|
-
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
|
+
};
|
|
123
137
|
}
|
|
124
138
|
case 'userop': {
|
|
125
139
|
const targetChain = (0, registry_1.getChainById)(result.chain);
|
|
@@ -137,12 +151,12 @@ async function waitForExecution(config, result, acceptsPreconfirmations) {
|
|
|
137
151
|
}
|
|
138
152
|
async function getMaxSpendableAmount(config, chain, tokenAddress, gasUnits, sponsored = false) {
|
|
139
153
|
const address = (0, accounts_1.getAddress)(config);
|
|
140
|
-
const orchestrator = (0, utils_2.getOrchestratorByChain)(chain.id, config.
|
|
154
|
+
const orchestrator = (0, utils_2.getOrchestratorByChain)(chain.id, config.apiKey, config.endpointUrl);
|
|
141
155
|
return orchestrator.getMaxTokenAmount(address, chain.id, tokenAddress, gasUnits, sponsored);
|
|
142
156
|
}
|
|
143
157
|
async function getPortfolio(config, onTestnets) {
|
|
144
158
|
const address = (0, accounts_1.getAddress)(config);
|
|
145
159
|
const chainId = onTestnets ? chains_1.sepolia.id : chains_1.mainnet.id;
|
|
146
|
-
const orchestrator = (0, utils_2.getOrchestratorByChain)(chainId, config.
|
|
160
|
+
const orchestrator = (0, utils_2.getOrchestratorByChain)(chainId, config.apiKey, config.endpointUrl);
|
|
147
161
|
return orchestrator.getPortfolio(address);
|
|
148
162
|
}
|
|
@@ -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"}
|
|
@@ -2,49 +2,53 @@ import { type Address, type Chain, type HashTypedDataParameters, type Hex, type
|
|
|
2
2
|
import { type UserOperation } from 'viem/account-abstraction';
|
|
3
3
|
import { type IntentOp, type IntentRoute } from '../orchestrator';
|
|
4
4
|
import type { SettlementLayer } from '../orchestrator/types';
|
|
5
|
-
import type { Call, CallInput,
|
|
6
|
-
|
|
5
|
+
import type { Call, CalldataInput, CallInput, RhinestoneConfig, SignerSet, SourceAssetInput, TokenRequest, TokenSymbol, Transaction, UserOperationTransaction } from '../types';
|
|
6
|
+
interface UserOperationResult {
|
|
7
7
|
type: 'userop';
|
|
8
8
|
hash: Hex;
|
|
9
9
|
chain: number;
|
|
10
|
-
}
|
|
10
|
+
}
|
|
11
|
+
interface TransactionResult {
|
|
11
12
|
type: 'intent';
|
|
12
13
|
id: bigint;
|
|
13
14
|
sourceChains?: number[];
|
|
14
15
|
targetChain: number;
|
|
15
|
-
};
|
|
16
|
-
interface IntentData {
|
|
17
|
-
type: 'intent';
|
|
18
|
-
intentRoute: IntentRoute;
|
|
19
|
-
}
|
|
20
|
-
interface UserOpData {
|
|
21
|
-
type: 'userop';
|
|
22
|
-
hash: Hex;
|
|
23
|
-
userOp: UserOperation;
|
|
24
16
|
}
|
|
25
17
|
interface PreparedTransactionData {
|
|
26
|
-
|
|
18
|
+
intentRoute: IntentRoute;
|
|
27
19
|
transaction: Transaction;
|
|
28
20
|
}
|
|
21
|
+
interface PreparedUserOperationData {
|
|
22
|
+
userOperation: UserOperation;
|
|
23
|
+
hash: Hex;
|
|
24
|
+
transaction: UserOperationTransaction;
|
|
25
|
+
}
|
|
29
26
|
interface SignedTransactionData extends PreparedTransactionData {
|
|
30
27
|
signature: Hex;
|
|
31
28
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
declare function
|
|
36
|
-
declare function
|
|
37
|
-
declare function
|
|
38
|
-
declare function
|
|
39
|
-
declare function
|
|
29
|
+
interface SignedUserOperationData extends PreparedUserOperationData {
|
|
30
|
+
signature: Hex;
|
|
31
|
+
}
|
|
32
|
+
declare function prepareTransaction(config: RhinestoneConfig, transaction: Transaction): Promise<PreparedTransactionData>;
|
|
33
|
+
declare function prepareUserOperation(config: RhinestoneConfig, transaction: UserOperationTransaction): Promise<PreparedUserOperationData>;
|
|
34
|
+
declare function resolveCallInputs(inputs: CallInput[], config: RhinestoneConfig, chain: Chain, accountAddress: Address): Promise<CalldataInput[]>;
|
|
35
|
+
declare function signTransaction(config: RhinestoneConfig, preparedTransaction: PreparedTransactionData): Promise<SignedTransactionData>;
|
|
36
|
+
declare function signUserOperation(config: RhinestoneConfig, preparedUserOperation: PreparedUserOperationData): Promise<SignedUserOperationData>;
|
|
37
|
+
declare function signAuthorizations(config: RhinestoneConfig, preparedTransaction: PreparedTransactionData): Promise<SignedAuthorization[]>;
|
|
38
|
+
declare function signMessage(config: RhinestoneConfig, message: SignableMessage, chain: Chain, signers: SignerSet | undefined): Promise<`0x${string}`>;
|
|
39
|
+
declare function signTypedData<typedData extends TypedData | Record<string, unknown> = TypedData, primaryType extends keyof typedData | 'EIP712Domain' = keyof typedData>(config: RhinestoneConfig, parameters: HashTypedDataParameters<typedData, primaryType>, chain: Chain, signers: SignerSet | undefined): Promise<`0x${string}`>;
|
|
40
|
+
declare function signAuthorizationsInternal(config: RhinestoneConfig, data: IntentRoute | UserOperation): Promise<SignedAuthorization[]>;
|
|
41
|
+
declare function submitTransaction(config: RhinestoneConfig, signedTransaction: SignedTransactionData, authorizations: SignedAuthorizationList): Promise<TransactionResult>;
|
|
42
|
+
declare function submitUserOperation(config: RhinestoneConfig, signedUserOperation: SignedUserOperationData): Promise<UserOperationResult>;
|
|
43
|
+
declare function simulateTransaction(config: RhinestoneConfig, signedTransaction: SignedTransactionData, authorizations: SignedAuthorizationList): Promise<import("../orchestrator").IntentResult>;
|
|
40
44
|
declare function getTokenRequests(sourceChains: Chain[], targetChain: Chain, initialTokenRequests: TokenRequest[] | undefined, settlementLayers: SettlementLayer[] | undefined): TokenRequest[];
|
|
41
|
-
declare function prepareTransactionAsIntent(config:
|
|
42
|
-
declare function signIntent(config:
|
|
45
|
+
declare function prepareTransactionAsIntent(config: RhinestoneConfig, sourceChains: Chain[] | undefined, targetChain: Chain, callInputs: CalldataInput[], gasLimit: bigint | undefined, tokenRequests: TokenRequest[], accountAddress: Address, isSponsored: boolean, eip7702InitSignature: Hex | undefined, settlementLayers: SettlementLayer[] | undefined, sourceAssets: SourceAssetInput | undefined, feeAsset: Address | TokenSymbol | undefined, lockFunds?: boolean): Promise<IntentRoute>;
|
|
46
|
+
declare function signIntent(config: RhinestoneConfig, targetChain: Chain, intentOp: IntentOp, signers?: SignerSet): Promise<`0x${string}`>;
|
|
43
47
|
declare function getOrchestratorByChain(chainId: number, apiKey: string | undefined, orchestratorUrl?: string): import("../orchestrator").Orchestrator;
|
|
44
|
-
declare function submitIntentInternal(config:
|
|
45
|
-
declare function simulateIntentInternal(config:
|
|
46
|
-
declare function getValidatorAccount(config:
|
|
47
|
-
declare function parseCalls(calls:
|
|
48
|
-
export { prepareTransaction, signTransaction, signAuthorizations, signAuthorizationsInternal, signMessage, signTypedData, submitTransaction, simulateTransaction, getOrchestratorByChain, signIntent, prepareTransactionAsIntent, submitIntentInternal, simulateIntentInternal, getValidatorAccount, parseCalls, getTokenRequests, };
|
|
49
|
-
export type {
|
|
48
|
+
declare function submitIntentInternal(config: RhinestoneConfig, sourceChains: Chain[] | undefined, targetChain: Chain, intentOp: IntentOp, signature: Hex, authorizations: SignedAuthorizationList): Promise<TransactionResult>;
|
|
49
|
+
declare function simulateIntentInternal(config: RhinestoneConfig, _sourceChains: Chain[] | undefined, targetChain: Chain, intentOp: IntentOp, signature: Hex, authorizations: SignedAuthorizationList): Promise<import("../orchestrator").IntentResult>;
|
|
50
|
+
declare function getValidatorAccount(config: RhinestoneConfig, signers: SignerSet | undefined, publicClient: PublicClient, chain: Chain): Promise<import("viem/account-abstraction").SmartAccount<import("viem/account-abstraction").SmartAccountImplementation<import("viem").Abi, "0.7">> | null>;
|
|
51
|
+
declare function parseCalls(calls: CalldataInput[], chainId: number): Call[];
|
|
52
|
+
export { prepareTransaction, signTransaction, signAuthorizations, signAuthorizationsInternal, signMessage, signTypedData, submitTransaction, simulateTransaction, prepareUserOperation, signUserOperation, submitUserOperation, getOrchestratorByChain, signIntent, prepareTransactionAsIntent, submitIntentInternal, simulateIntentInternal, getValidatorAccount, parseCalls, getTokenRequests, resolveCallInputs, };
|
|
53
|
+
export type { IntentRoute, TransactionResult, PreparedTransactionData, PreparedUserOperationData, SignedTransactionData, SignedUserOperationData, UserOperationResult, };
|
|
50
54
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../execution/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,KAAK,EAIV,KAAK,uBAAuB,EAC5B,KAAK,GAAG,EAIR,KAAK,YAAY,EAEjB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,EAC5B,KAAK,SAAS,EAGf,MAAM,MAAM,CAAA;AACb,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,0BAA0B,CAAA;AA0BjC,OAAO,EAGL,KAAK,QAAQ,EACb,KAAK,WAAW,EAEjB,MAAM,iBAAiB,CAAA;AAWxB,OAAO,KAAK,EAEV,eAAe,EAGhB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,KAAK,EACV,IAAI,EACJ,SAAS,EACT,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../execution/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,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AE,gBAAgB,EACxB,YAAY,EAAE,KAAK,EAAE,GAAG,SAAS,EACjC,WAAW,EAAE,KAAK,EAClB,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,GAAG,EACd,cAAc,EAAE,uBAAuB,8BAmBxC;AAED,iBAAe,sBAAsB,CACnC,MAAM,EAAE,gBAAgB,EACxB,aAAa,EAAE,KAAK,EAAE,GAAG,SAAS,EAClC,WAAW,EAAE,KAAK,EAClB,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,GAAG,EACd,cAAc,EAAE,uBAAuB,mDAcxC;AAED,iBAAe,mBAAmB,CAChC,MAAM,EAAE,gBAAgB,EACxB,OAAO,EAAE,SAAS,GAAG,SAAS,EAC9B,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,KAAK,6JA6Bb;AAmDD,iBAAS,UAAU,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,EAAE,CAMnE;AAmGD,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EAClB,0BAA0B,EAC1B,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,mBAAmB,EACnB,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,sBAAsB,EACtB,UAAU,EACV,0BAA0B,EAC1B,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,UAAU,EACV,gBAAgB,EAChB,iBAAiB,GAClB,CAAA;AACD,YAAY,EACV,WAAW,EACX,iBAAiB,EACjB,uBAAuB,EACvB,yBAAyB,EACzB,qBAAqB,EACrB,uBAAuB,EACvB,mBAAmB,GACpB,CAAA"}
|
|
@@ -8,6 +8,9 @@ exports.signMessage = signMessage;
|
|
|
8
8
|
exports.signTypedData = signTypedData;
|
|
9
9
|
exports.submitTransaction = submitTransaction;
|
|
10
10
|
exports.simulateTransaction = simulateTransaction;
|
|
11
|
+
exports.prepareUserOperation = prepareUserOperation;
|
|
12
|
+
exports.signUserOperation = signUserOperation;
|
|
13
|
+
exports.submitUserOperation = submitUserOperation;
|
|
11
14
|
exports.getOrchestratorByChain = getOrchestratorByChain;
|
|
12
15
|
exports.signIntent = signIntent;
|
|
13
16
|
exports.prepareTransactionAsIntent = prepareTransactionAsIntent;
|
|
@@ -16,6 +19,7 @@ exports.simulateIntentInternal = simulateIntentInternal;
|
|
|
16
19
|
exports.getValidatorAccount = getValidatorAccount;
|
|
17
20
|
exports.parseCalls = parseCalls;
|
|
18
21
|
exports.getTokenRequests = getTokenRequests;
|
|
22
|
+
exports.resolveCallInputs = resolveCallInputs;
|
|
19
23
|
const viem_1 = require("viem");
|
|
20
24
|
const account_abstraction_1 = require("viem/account-abstraction");
|
|
21
25
|
const accounts_1 = require("../accounts");
|
|
@@ -29,50 +33,72 @@ const compact_1 = require("./compact");
|
|
|
29
33
|
const error_1 = require("./error");
|
|
30
34
|
const permit2_1 = require("./permit2");
|
|
31
35
|
async function prepareTransaction(config, transaction) {
|
|
32
|
-
const { sourceChains, targetChain, tokenRequests, signers, sponsored, eip7702InitSignature, settlementLayers, sourceAssets, feeAsset, } = getTransactionParams(transaction);
|
|
36
|
+
const { sourceChains, targetChain, tokenRequests, signers, sponsored, eip7702InitSignature, settlementLayers, sourceAssets, feeAsset, lockFunds, } = getTransactionParams(transaction);
|
|
33
37
|
const accountAddress = (0, accounts_1.getAddress)(config);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (sourceChains && sourceChains.length > 0) {
|
|
38
|
-
throw new error_1.SourceChainsNotAvailableForUserOpFlowError();
|
|
39
|
-
}
|
|
40
|
-
// Smart sessions require a UserOp flow
|
|
41
|
-
data = await prepareTransactionAsUserOp(config, targetChain, transaction.calls, signers, transaction.gasLimit);
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
data = await prepareTransactionAsIntent(config, sourceChains, targetChain, transaction.calls, transaction.gasLimit, tokenRequests, accountAddress, sponsored ?? false, eip7702InitSignature, settlementLayers, sourceAssets, feeAsset);
|
|
38
|
+
const isUserOpSigner = signers?.type === 'guardians' || signers?.type === 'session';
|
|
39
|
+
if (isUserOpSigner) {
|
|
40
|
+
throw new error_1.SignerNotSupportedError();
|
|
45
41
|
}
|
|
42
|
+
const intentRoute = await prepareTransactionAsIntent(config, sourceChains, targetChain, await resolveCallInputs(transaction.calls, config, targetChain, accountAddress), transaction.gasLimit, tokenRequests, accountAddress, sponsored ?? false, eip7702InitSignature, settlementLayers, sourceAssets, feeAsset, lockFunds);
|
|
46
43
|
return {
|
|
47
|
-
|
|
44
|
+
intentRoute,
|
|
48
45
|
transaction,
|
|
49
46
|
};
|
|
50
47
|
}
|
|
51
|
-
async function
|
|
52
|
-
const
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
48
|
+
async function prepareUserOperation(config, transaction) {
|
|
49
|
+
const chain = transaction.chain;
|
|
50
|
+
const signers = transaction.signers;
|
|
51
|
+
const accountAddress = (0, accounts_1.getAddress)(config);
|
|
52
|
+
const data = await prepareTransactionAsUserOp(config, chain, await resolveCallInputs(transaction.calls, config, chain, accountAddress), signers, transaction.gasLimit);
|
|
53
|
+
return {
|
|
54
|
+
userOperation: data.userOp,
|
|
55
|
+
hash: data.hash,
|
|
56
|
+
transaction,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
async function resolveCallInputs(inputs, config, chain, accountAddress) {
|
|
60
|
+
const resolved = [];
|
|
61
|
+
for (const intent of inputs) {
|
|
62
|
+
if ('resolve' in intent) {
|
|
63
|
+
const result = await intent.resolve({ config, chain, accountAddress });
|
|
64
|
+
if (Array.isArray(result)) {
|
|
65
|
+
resolved.push(...result);
|
|
66
|
+
}
|
|
67
|
+
else if (result) {
|
|
68
|
+
resolved.push(result);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
resolved.push(intent);
|
|
61
73
|
}
|
|
62
|
-
// Smart sessions require a UserOp flow
|
|
63
|
-
signature = await signUserOp(config, chain, signers, userOp);
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
signature = await signIntent(config, targetChain, data.intentRoute.intentOp, signers);
|
|
67
74
|
}
|
|
75
|
+
return resolved;
|
|
76
|
+
}
|
|
77
|
+
async function signTransaction(config, preparedTransaction) {
|
|
78
|
+
const { targetChain, signers } = getTransactionParams(preparedTransaction.transaction);
|
|
79
|
+
const intentRoute = preparedTransaction.intentRoute;
|
|
80
|
+
const signature = await signIntent(config, targetChain, intentRoute.intentOp, signers);
|
|
68
81
|
return {
|
|
69
|
-
|
|
82
|
+
intentRoute,
|
|
70
83
|
transaction: preparedTransaction.transaction,
|
|
71
84
|
signature,
|
|
72
85
|
};
|
|
73
86
|
}
|
|
87
|
+
async function signUserOperation(config, preparedUserOperation) {
|
|
88
|
+
const chain = preparedUserOperation.transaction.chain;
|
|
89
|
+
const userOp = preparedUserOperation.userOperation;
|
|
90
|
+
const signers = preparedUserOperation.transaction.signers;
|
|
91
|
+
// Smart sessions require a UserOp flow
|
|
92
|
+
const signature = await signUserOp(config, chain, signers, userOp);
|
|
93
|
+
return {
|
|
94
|
+
userOperation: preparedUserOperation.userOperation,
|
|
95
|
+
hash: preparedUserOperation.hash,
|
|
96
|
+
transaction: preparedUserOperation.transaction,
|
|
97
|
+
signature,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
74
100
|
async function signAuthorizations(config, preparedTransaction) {
|
|
75
|
-
return await signAuthorizationsInternal(config, preparedTransaction.
|
|
101
|
+
return await signAuthorizationsInternal(config, preparedTransaction.intentRoute);
|
|
76
102
|
}
|
|
77
103
|
async function signMessage(config, message, chain, signers) {
|
|
78
104
|
const validator = getValidator(config, signers);
|
|
@@ -107,9 +133,8 @@ async function signAuthorizationsInternal(config, data) {
|
|
|
107
133
|
throw new Error('EIP-7702 initialization is required for EOA accounts');
|
|
108
134
|
}
|
|
109
135
|
const accountAddress = (0, accounts_1.getAddress)(config);
|
|
110
|
-
const requiredDelegations =
|
|
111
|
-
? data.
|
|
112
|
-
{}
|
|
136
|
+
const requiredDelegations = 'intentOp' in data
|
|
137
|
+
? data.intentOp.signedMetadata.account.requiredDelegations || {}
|
|
113
138
|
: {};
|
|
114
139
|
const authorizations = [];
|
|
115
140
|
for (const chainId in requiredDelegations) {
|
|
@@ -136,40 +161,26 @@ async function signAuthorizationsInternal(config, data) {
|
|
|
136
161
|
return authorizations;
|
|
137
162
|
}
|
|
138
163
|
async function submitTransaction(config, signedTransaction, authorizations) {
|
|
139
|
-
const {
|
|
164
|
+
const { intentRoute, transaction, signature } = signedTransaction;
|
|
140
165
|
const { sourceChains, targetChain } = getTransactionParams(transaction);
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
else {
|
|
152
|
-
const intentOp = data.intentRoute.intentOp;
|
|
153
|
-
if (!intentOp) {
|
|
154
|
-
throw new error_1.OrderPathRequiredForIntentsError();
|
|
155
|
-
}
|
|
156
|
-
return await submitIntent(config, sourceChains, targetChain, intentOp, signature, authorizations);
|
|
157
|
-
}
|
|
166
|
+
const intentOp = intentRoute.intentOp;
|
|
167
|
+
return await submitIntent(config, sourceChains, targetChain, intentOp, signature, authorizations);
|
|
168
|
+
}
|
|
169
|
+
async function submitUserOperation(config, signedUserOperation) {
|
|
170
|
+
const chain = signedUserOperation.transaction.chain;
|
|
171
|
+
const userOp = signedUserOperation.userOperation;
|
|
172
|
+
const signature = signedUserOperation.signature;
|
|
173
|
+
// Smart sessions require a UserOp flow
|
|
174
|
+
return await submitUserOp(config, chain, userOp, signature);
|
|
158
175
|
}
|
|
159
176
|
async function simulateTransaction(config, signedTransaction, authorizations) {
|
|
160
|
-
const {
|
|
177
|
+
const { intentRoute, transaction, signature } = signedTransaction;
|
|
161
178
|
const { sourceChains, targetChain } = getTransactionParams(transaction);
|
|
162
|
-
const
|
|
163
|
-
if (
|
|
164
|
-
throw new error_1.
|
|
165
|
-
}
|
|
166
|
-
else {
|
|
167
|
-
const intentOp = data.intentRoute.intentOp;
|
|
168
|
-
if (!intentOp) {
|
|
169
|
-
throw new error_1.OrderPathRequiredForIntentsError();
|
|
170
|
-
}
|
|
171
|
-
return await simulateIntent(config, sourceChains, targetChain, intentOp, signature, authorizations);
|
|
179
|
+
const intentOp = intentRoute.intentOp;
|
|
180
|
+
if (!intentOp) {
|
|
181
|
+
throw new error_1.OrderPathRequiredForIntentsError();
|
|
172
182
|
}
|
|
183
|
+
return await simulateIntent(config, sourceChains, targetChain, intentOp, signature, authorizations);
|
|
173
184
|
}
|
|
174
185
|
function getTransactionParams(transaction) {
|
|
175
186
|
const sourceChains = 'chain' in transaction ? [transaction.chain] : transaction.sourceChains;
|
|
@@ -182,6 +193,7 @@ function getTransactionParams(transaction) {
|
|
|
182
193
|
const settlementLayers = transaction.settlementLayers;
|
|
183
194
|
const sourceAssets = transaction.sourceAssets;
|
|
184
195
|
const feeAsset = transaction.feeAsset;
|
|
196
|
+
const lockFunds = transaction.lockFunds;
|
|
185
197
|
const tokenRequests = getTokenRequests(sourceChains || [], targetChain, initialTokenRequests, settlementLayers);
|
|
186
198
|
return {
|
|
187
199
|
sourceChains,
|
|
@@ -194,6 +206,7 @@ function getTransactionParams(transaction) {
|
|
|
194
206
|
settlementLayers,
|
|
195
207
|
sourceAssets,
|
|
196
208
|
feeAsset,
|
|
209
|
+
lockFunds,
|
|
197
210
|
};
|
|
198
211
|
}
|
|
199
212
|
function getTokenRequests(sourceChains, targetChain, initialTokenRequests, settlementLayers) {
|
|
@@ -231,7 +244,6 @@ async function prepareTransactionAsUserOp(config, chain, callInputs, signers, ga
|
|
|
231
244
|
callGasLimit: gasLimit,
|
|
232
245
|
});
|
|
233
246
|
return {
|
|
234
|
-
type: 'userop',
|
|
235
247
|
userOp,
|
|
236
248
|
hash: (0, account_abstraction_1.getUserOperationHash)({
|
|
237
249
|
userOperation: userOp,
|
|
@@ -241,7 +253,7 @@ async function prepareTransactionAsUserOp(config, chain, callInputs, signers, ga
|
|
|
241
253
|
}),
|
|
242
254
|
};
|
|
243
255
|
}
|
|
244
|
-
async function prepareTransactionAsIntent(config, sourceChains, targetChain, callInputs, gasLimit, tokenRequests, accountAddress, isSponsored, eip7702InitSignature, settlementLayers, sourceAssets, feeAsset) {
|
|
256
|
+
async function prepareTransactionAsIntent(config, sourceChains, targetChain, callInputs, gasLimit, tokenRequests, accountAddress, isSponsored, eip7702InitSignature, settlementLayers, sourceAssets, feeAsset, lockFunds) {
|
|
245
257
|
const calls = parseCalls(callInputs, targetChain.id);
|
|
246
258
|
const accountAccessList = createAccountAccessList(sourceChains, sourceAssets);
|
|
247
259
|
const { setupOps, delegations } = await getSetupOperationsAndDelegations(config, targetChain, accountAddress, eip7702InitSignature);
|
|
@@ -261,7 +273,7 @@ async function prepareTransactionAsIntent(config, sourceChains, targetChain, cal
|
|
|
261
273
|
destinationGasUnits: gasLimit,
|
|
262
274
|
accountAccessList,
|
|
263
275
|
options: {
|
|
264
|
-
topupCompact: false,
|
|
276
|
+
topupCompact: lockFunds ?? false,
|
|
265
277
|
feeToken: feeAsset,
|
|
266
278
|
sponsorSettings: {
|
|
267
279
|
gasSponsored: isSponsored,
|
|
@@ -271,12 +283,9 @@ async function prepareTransactionAsIntent(config, sourceChains, targetChain, cal
|
|
|
271
283
|
settlementLayers,
|
|
272
284
|
},
|
|
273
285
|
};
|
|
274
|
-
const orchestrator = getOrchestratorByChain(targetChain.id, config.
|
|
286
|
+
const orchestrator = getOrchestratorByChain(targetChain.id, config.apiKey, config.endpointUrl);
|
|
275
287
|
const intentRoute = await orchestrator.getIntentRoute(metaIntent);
|
|
276
|
-
return
|
|
277
|
-
type: 'intent',
|
|
278
|
-
intentRoute,
|
|
279
|
-
};
|
|
288
|
+
return intentRoute;
|
|
280
289
|
}
|
|
281
290
|
async function signIntent(config, targetChain, intentOp, signers) {
|
|
282
291
|
const validator = getValidator(config, signers);
|
|
@@ -404,7 +413,7 @@ function createSignedIntentOp(intentOp, signature, authorizations) {
|
|
|
404
413
|
}
|
|
405
414
|
async function submitIntentInternal(config, sourceChains, targetChain, intentOp, signature, authorizations) {
|
|
406
415
|
const signedIntentOp = createSignedIntentOp(intentOp, signature, authorizations);
|
|
407
|
-
const orchestrator = getOrchestratorByChain(targetChain.id, config.
|
|
416
|
+
const orchestrator = getOrchestratorByChain(targetChain.id, config.apiKey, config.endpointUrl);
|
|
408
417
|
const intentResults = await orchestrator.submitIntent(signedIntentOp);
|
|
409
418
|
return {
|
|
410
419
|
type: 'intent',
|
|
@@ -415,7 +424,7 @@ async function submitIntentInternal(config, sourceChains, targetChain, intentOp,
|
|
|
415
424
|
}
|
|
416
425
|
async function simulateIntentInternal(config, _sourceChains, targetChain, intentOp, signature, authorizations) {
|
|
417
426
|
const signedIntentOp = createSignedIntentOp(intentOp, signature, authorizations);
|
|
418
|
-
const orchestrator = getOrchestratorByChain(targetChain.id, config.
|
|
427
|
+
const orchestrator = getOrchestratorByChain(targetChain.id, config.apiKey, config.endpointUrl);
|
|
419
428
|
const simulationResults = await orchestrator.simulateIntent(signedIntentOp);
|
|
420
429
|
return simulationResults;
|
|
421
430
|
}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import type { Address, Chain, HashTypedDataParameters, Hex, SignableMessage, SignedAuthorizationList, TypedData } from 'viem';
|
|
2
2
|
import type { UserOperationReceipt } from 'viem/account-abstraction';
|
|
3
|
-
import { AccountConfigurationNotSupportedError, AccountError, Eip7702AccountMustHaveEoaError, Eip7702NotSupportedForAccountError, ExistingEip7702AccountsNotSupportedError, FactoryArgsNotAvailableError, isAccountError, SigningNotSupportedForAccountError, SmartSessionsNotEnabledError, WalletClientNoConnectedAccountError } from './accounts';
|
|
4
3
|
import { walletClientToAccount } from './accounts/walletClient';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { encodeSmartSessionSignature } from './actions/smart-session';
|
|
5
|
+
import { type TransactionResult, type TransactionStatus, type UserOperationResult } from './execution';
|
|
7
6
|
import { type SessionDetails } from './execution/smart-session';
|
|
8
|
-
import { type
|
|
9
|
-
import {
|
|
10
|
-
import type { AccountProviderConfig, AccountType, BundlerConfig, Call, CallInput, MultiFactorValidatorConfig, OwnableValidatorConfig, OwnerSet, PaymasterConfig, Policy, ProviderConfig, Recovery, RhinestoneAccountConfig, Session, SignerSet, TokenRequest, TokenSymbol, Transaction, UniversalActionPolicyParamCondition, WebauthnValidatorConfig } from './types';
|
|
7
|
+
import { type IntentRoute, type PreparedTransactionData, type PreparedUserOperationData, type SignedTransactionData, type SignedUserOperationData } from './execution/utils';
|
|
8
|
+
import { getSupportedTokens, getTokenAddress, type IntentCost, type IntentInput, type IntentOp, type IntentOpStatus, type IntentResult, type Portfolio, type SettlementSystem, type SignedIntentOp } from './orchestrator';
|
|
9
|
+
import type { AccountProviderConfig, AccountType, BundlerConfig, Call, CallInput, MultiFactorValidatorConfig, OwnableValidatorConfig, OwnerSet, PaymasterConfig, Policy, ProviderConfig, Recovery, RhinestoneAccountConfig, Session, SignerSet, TokenRequest, TokenSymbol, Transaction, UniversalActionPolicyParamCondition, UserOperationTransaction, WebauthnValidatorConfig } from './types';
|
|
11
10
|
interface RhinestoneAccount {
|
|
12
11
|
config: RhinestoneAccountConfig;
|
|
13
12
|
deploy: (chain: Chain, session?: Session) => Promise<boolean>;
|
|
@@ -22,7 +21,12 @@ interface RhinestoneAccount {
|
|
|
22
21
|
submitTransaction: (signedTransaction: SignedTransactionData, authorizations?: SignedAuthorizationList) => Promise<TransactionResult>;
|
|
23
22
|
simulateTransaction: (signedTransaction: SignedTransactionData, authorizations?: SignedAuthorizationList) => Promise<IntentResult>;
|
|
24
23
|
sendTransaction: (transaction: Transaction) => Promise<TransactionResult>;
|
|
25
|
-
|
|
24
|
+
prepareUserOperation: (transaction: UserOperationTransaction) => Promise<PreparedUserOperationData>;
|
|
25
|
+
signUserOperation: (preparedUserOperation: PreparedUserOperationData) => Promise<SignedUserOperationData>;
|
|
26
|
+
submitUserOperation: (signedUserOperation: SignedUserOperationData) => Promise<UserOperationResult>;
|
|
27
|
+
sendUserOperation: (transaction: UserOperationTransaction) => Promise<UserOperationResult>;
|
|
28
|
+
waitForExecution(result: TransactionResult, acceptsPreconfirmations?: boolean): Promise<TransactionStatus>;
|
|
29
|
+
waitForExecution(result: UserOperationResult, acceptsPreconfirmations?: boolean): Promise<UserOperationReceipt>;
|
|
26
30
|
getAddress: () => Address;
|
|
27
31
|
getPortfolio: (onTestnets?: boolean) => Promise<Portfolio>;
|
|
28
32
|
getMaxSpendableAmount: (chain: Chain, tokenAddress: Address, gasUnits: bigint, sponsored?: boolean) => Promise<bigint>;
|
|
@@ -33,13 +37,21 @@ interface RhinestoneAccount {
|
|
|
33
37
|
} | null>;
|
|
34
38
|
getValidators: (chain: Chain) => Promise<Address[]>;
|
|
35
39
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
declare class RhinestoneSDK {
|
|
41
|
+
private apiKey?;
|
|
42
|
+
private endpointUrl?;
|
|
43
|
+
private provider?;
|
|
44
|
+
private bundler?;
|
|
45
|
+
private paymaster?;
|
|
46
|
+
constructor(options?: {
|
|
47
|
+
apiKey?: string;
|
|
48
|
+
endpointUrl?: string;
|
|
49
|
+
provider?: ProviderConfig;
|
|
50
|
+
bundler?: BundlerConfig;
|
|
51
|
+
paymaster?: PaymasterConfig;
|
|
52
|
+
});
|
|
53
|
+
createAccount(config: RhinestoneAccountConfig): Promise<RhinestoneAccount>;
|
|
54
|
+
}
|
|
55
|
+
export { RhinestoneSDK, walletClientToAccount, encodeSmartSessionSignature, getSupportedTokens, getTokenAddress, };
|
|
56
|
+
export type { RhinestoneAccount, AccountType, RhinestoneAccountConfig, AccountProviderConfig, ProviderConfig, BundlerConfig, PaymasterConfig, Transaction, TokenSymbol, CallInput, Call, TokenRequest, OwnerSet, OwnableValidatorConfig, WebauthnValidatorConfig, MultiFactorValidatorConfig, SignerSet, Session, Recovery, Policy, UniversalActionPolicyParamCondition, PreparedTransactionData, SignedTransactionData, TransactionResult, PreparedUserOperationData, SignedUserOperationData, UserOperationResult, IntentCost, IntentInput, IntentOp, IntentOpStatus, IntentRoute, SettlementSystem, SignedIntentOp, Portfolio, };
|
|
45
57
|
//# sourceMappingURL=index.d.ts.map
|