@rhinestone/sdk 1.0.0-alpha.32 → 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 +1 -12
- package/dist/src/execution/compact.d.ts.map +1 -1
- package/dist/src/execution/compact.js +0 -190
- 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 +23 -24
- package/dist/src/execution/index.d.ts.map +1 -1
- package/dist/src/execution/index.js +38 -24
- 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 +76 -69
- package/dist/src/index.d.ts +28 -17
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +69 -74
- 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 +22 -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;
|
|
@@ -86,16 +94,13 @@ async function sendTransactionAsUserOp(config, chain, callInputs, signers) {
|
|
|
86
94
|
};
|
|
87
95
|
}
|
|
88
96
|
async function sendTransactionAsIntent(config, sourceChains, targetChain, callInputs, gasLimit, tokenRequests, accountAddress, signers, sponsored, settlementLayers, sourceAssets, feeAsset, lockFunds) {
|
|
89
|
-
const
|
|
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,KAAK,KAAK,EAIV,KAAK,uBAAuB,EAC5B,KAAK,GAAG,EAIR,KAAK,YAAY,EAEjB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,EA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,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");
|
|
@@ -31,48 +35,70 @@ const permit2_1 = require("./permit2");
|
|
|
31
35
|
async function prepareTransaction(config, transaction) {
|
|
32
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, lockFunds);
|
|
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;
|
|
@@ -233,7 +244,6 @@ async function prepareTransactionAsUserOp(config, chain, callInputs, signers, ga
|
|
|
233
244
|
callGasLimit: gasLimit,
|
|
234
245
|
});
|
|
235
246
|
return {
|
|
236
|
-
type: 'userop',
|
|
237
247
|
userOp,
|
|
238
248
|
hash: (0, account_abstraction_1.getUserOperationHash)({
|
|
239
249
|
userOperation: userOp,
|
|
@@ -273,12 +283,9 @@ async function prepareTransactionAsIntent(config, sourceChains, targetChain, cal
|
|
|
273
283
|
settlementLayers,
|
|
274
284
|
},
|
|
275
285
|
};
|
|
276
|
-
const orchestrator = getOrchestratorByChain(targetChain.id, config.
|
|
286
|
+
const orchestrator = getOrchestratorByChain(targetChain.id, config.apiKey, config.endpointUrl);
|
|
277
287
|
const intentRoute = await orchestrator.getIntentRoute(metaIntent);
|
|
278
|
-
return
|
|
279
|
-
type: 'intent',
|
|
280
|
-
intentRoute,
|
|
281
|
-
};
|
|
288
|
+
return intentRoute;
|
|
282
289
|
}
|
|
283
290
|
async function signIntent(config, targetChain, intentOp, signers) {
|
|
284
291
|
const validator = getValidator(config, signers);
|
|
@@ -406,7 +413,7 @@ function createSignedIntentOp(intentOp, signature, authorizations) {
|
|
|
406
413
|
}
|
|
407
414
|
async function submitIntentInternal(config, sourceChains, targetChain, intentOp, signature, authorizations) {
|
|
408
415
|
const signedIntentOp = createSignedIntentOp(intentOp, signature, authorizations);
|
|
409
|
-
const orchestrator = getOrchestratorByChain(targetChain.id, config.
|
|
416
|
+
const orchestrator = getOrchestratorByChain(targetChain.id, config.apiKey, config.endpointUrl);
|
|
410
417
|
const intentResults = await orchestrator.submitIntent(signedIntentOp);
|
|
411
418
|
return {
|
|
412
419
|
type: 'intent',
|
|
@@ -417,7 +424,7 @@ async function submitIntentInternal(config, sourceChains, targetChain, intentOp,
|
|
|
417
424
|
}
|
|
418
425
|
async function simulateIntentInternal(config, _sourceChains, targetChain, intentOp, signature, authorizations) {
|
|
419
426
|
const signedIntentOp = createSignedIntentOp(intentOp, signature, authorizations);
|
|
420
|
-
const orchestrator = getOrchestratorByChain(targetChain.id, config.
|
|
427
|
+
const orchestrator = getOrchestratorByChain(targetChain.id, config.apiKey, config.endpointUrl);
|
|
421
428
|
const simulationResults = await orchestrator.simulateIntent(signedIntentOp);
|
|
422
429
|
return simulationResults;
|
|
423
430
|
}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,14 +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 {
|
|
7
|
-
import { depositErc20, depositEther, disableErc20Withdrawal, disableEtherWithdrawal, enableErc20Withdrawal, enableEtherWithdrawal, withdrawErc20, withdrawEther } from './execution/compact';
|
|
4
|
+
import { encodeSmartSessionSignature } from './actions/smart-session';
|
|
5
|
+
import { type TransactionResult, type TransactionStatus, type UserOperationResult } from './execution';
|
|
8
6
|
import { type SessionDetails } from './execution/smart-session';
|
|
9
|
-
import { type
|
|
10
|
-
import {
|
|
11
|
-
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';
|
|
12
10
|
interface RhinestoneAccount {
|
|
13
11
|
config: RhinestoneAccountConfig;
|
|
14
12
|
deploy: (chain: Chain, session?: Session) => Promise<boolean>;
|
|
@@ -23,7 +21,12 @@ interface RhinestoneAccount {
|
|
|
23
21
|
submitTransaction: (signedTransaction: SignedTransactionData, authorizations?: SignedAuthorizationList) => Promise<TransactionResult>;
|
|
24
22
|
simulateTransaction: (signedTransaction: SignedTransactionData, authorizations?: SignedAuthorizationList) => Promise<IntentResult>;
|
|
25
23
|
sendTransaction: (transaction: Transaction) => Promise<TransactionResult>;
|
|
26
|
-
|
|
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>;
|
|
27
30
|
getAddress: () => Address;
|
|
28
31
|
getPortfolio: (onTestnets?: boolean) => Promise<Portfolio>;
|
|
29
32
|
getMaxSpendableAmount: (chain: Chain, tokenAddress: Address, gasUnits: bigint, sponsored?: boolean) => Promise<bigint>;
|
|
@@ -34,13 +37,21 @@ interface RhinestoneAccount {
|
|
|
34
37
|
} | null>;
|
|
35
38
|
getValidators: (chain: Chain) => Promise<Address[]>;
|
|
36
39
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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, };
|
|
46
57
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,KAAK,EACL,uBAAuB,EACvB,GAAG,EACH,eAAe,EACf,uBAAuB,EACvB,SAAS,EACV,MAAM,MAAM,CAAA;AACb,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,KAAK,EACL,uBAAuB,EACvB,GAAG,EACH,eAAe,EACf,uBAAuB,EACvB,SAAS,EACV,MAAM,MAAM,CAAA;AACb,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AASpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAC/D,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAA;AACrE,OAAO,EAKL,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EAEzB,MAAM,aAAa,CAAA;AACpB,OAAO,EAEL,KAAK,cAAc,EACpB,MAAM,2BAA2B,CAAA;AAClC,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,uBAAuB,EAC5B,KAAK,yBAAyB,EAG9B,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAS7B,MAAM,mBAAmB,CAAA;AAK1B,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,QAAQ,EACb,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,SAAS,E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