@rhinestone/sdk 1.0.0-alpha.4 → 1.0.0-alpha.6
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 +2 -2
- package/dist/src/accounts/index.d.ts.map +1 -1
- package/dist/src/accounts/index.js +118 -13
- package/dist/src/accounts/safe.d.ts.map +1 -1
- package/dist/src/accounts/safe.js +4 -0
- package/dist/src/actions/index.d.ts +14 -3
- package/dist/src/actions/index.d.ts.map +1 -1
- package/dist/src/actions/index.js +99 -8
- 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 +2 -3
- package/dist/src/execution/index.d.ts.map +1 -1
- package/dist/src/execution/index.js +23 -70
- package/dist/src/execution/smart-session.js +1 -1
- package/dist/src/execution/utils.d.ts +4 -5
- package/dist/src/execution/utils.d.ts.map +1 -1
- package/dist/src/execution/utils.js +29 -73
- package/dist/src/index.d.ts +3 -4
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +7 -7
- package/dist/src/modules/validators/core.d.ts +5 -6
- package/dist/src/modules/validators/core.d.ts.map +1 -1
- package/dist/src/modules/validators/core.js +81 -6
- package/dist/src/orchestrator/client.d.ts +1 -0
- package/dist/src/orchestrator/client.d.ts.map +1 -1
- package/dist/src/orchestrator/client.js +66 -55
- package/dist/src/orchestrator/consts.d.ts +3 -3
- package/dist/src/orchestrator/consts.d.ts.map +1 -1
- package/dist/src/orchestrator/consts.js +4 -4
- package/dist/src/types.d.ts +20 -4
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,26 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SessionChainRequiredError = exports.OrderPathRequiredForIntentsError = exports.UserOperationRequiredForSmartSessionsError = exports.
|
|
3
|
+
exports.SessionChainRequiredError = exports.OrderPathRequiredForIntentsError = exports.UserOperationRequiredForSmartSessionsError = exports.SourceChainsNotAvailableForUserOpFlowError = exports.ExecutionError = exports.IntentFailedError = exports.isExecutionError = void 0;
|
|
4
4
|
exports.sendTransaction = sendTransaction;
|
|
5
5
|
exports.waitForExecution = waitForExecution;
|
|
6
6
|
exports.getMaxSpendableAmount = getMaxSpendableAmount;
|
|
7
7
|
exports.getPortfolio = getPortfolio;
|
|
8
|
-
exports.deposit = deposit;
|
|
9
8
|
const viem_1 = require("viem");
|
|
10
9
|
const chains_1 = require("viem/chains");
|
|
11
10
|
const accounts_1 = require("../accounts");
|
|
12
11
|
const utils_1 = require("../accounts/utils");
|
|
13
12
|
const orchestrator_1 = require("../orchestrator");
|
|
14
13
|
const registry_1 = require("../orchestrator/registry");
|
|
15
|
-
const compact_1 = require("./compact");
|
|
16
14
|
const error_1 = require("./error");
|
|
17
15
|
Object.defineProperty(exports, "ExecutionError", { enumerable: true, get: function () { return error_1.ExecutionError; } });
|
|
18
16
|
Object.defineProperty(exports, "IntentFailedError", { enumerable: true, get: function () { return error_1.IntentFailedError; } });
|
|
19
17
|
Object.defineProperty(exports, "isExecutionError", { enumerable: true, get: function () { return error_1.isExecutionError; } });
|
|
20
18
|
Object.defineProperty(exports, "OrderPathRequiredForIntentsError", { enumerable: true, get: function () { return error_1.OrderPathRequiredForIntentsError; } });
|
|
21
19
|
Object.defineProperty(exports, "SessionChainRequiredError", { enumerable: true, get: function () { return error_1.SessionChainRequiredError; } });
|
|
22
|
-
Object.defineProperty(exports, "
|
|
23
|
-
Object.defineProperty(exports, "SourceTargetChainMismatchError", { enumerable: true, get: function () { return error_1.SourceTargetChainMismatchError; } });
|
|
20
|
+
Object.defineProperty(exports, "SourceChainsNotAvailableForUserOpFlowError", { enumerable: true, get: function () { return error_1.SourceChainsNotAvailableForUserOpFlowError; } });
|
|
24
21
|
Object.defineProperty(exports, "UserOperationRequiredForSmartSessionsError", { enumerable: true, get: function () { return error_1.UserOperationRequiredForSmartSessionsError; } });
|
|
25
22
|
const smart_session_1 = require("./smart-session");
|
|
26
23
|
const utils_2 = require("./utils");
|
|
@@ -28,14 +25,14 @@ const POLLING_INTERVAL = 500;
|
|
|
28
25
|
async function sendTransaction(config, transaction) {
|
|
29
26
|
if ('chain' in transaction) {
|
|
30
27
|
// Same-chain transaction
|
|
31
|
-
return await sendTransactionInternal(config, transaction.chain, transaction.chain, transaction.calls, transaction.gasLimit, transaction.tokenRequests, transaction.signers);
|
|
28
|
+
return await sendTransactionInternal(config, [transaction.chain], transaction.chain, transaction.calls, transaction.gasLimit, transaction.tokenRequests, transaction.signers);
|
|
32
29
|
}
|
|
33
30
|
else {
|
|
34
31
|
// Cross-chain transaction
|
|
35
|
-
return await sendTransactionInternal(config, transaction.
|
|
32
|
+
return await sendTransactionInternal(config, transaction.sourceChains || [], transaction.targetChain, transaction.calls, transaction.gasLimit, transaction.tokenRequests, transaction.signers);
|
|
36
33
|
}
|
|
37
34
|
}
|
|
38
|
-
async function sendTransactionInternal(config,
|
|
35
|
+
async function sendTransactionInternal(config, sourceChains, targetChain, callInputs, gasLimit, initialTokenRequests, signers) {
|
|
39
36
|
const accountAddress = (0, accounts_1.getAddress)(config);
|
|
40
37
|
// Across requires passing some value to repay the solvers
|
|
41
38
|
const tokenRequests = !initialTokenRequests || initialTokenRequests.length === 0
|
|
@@ -47,38 +44,36 @@ async function sendTransactionInternal(config, sourceChain, targetChain, callInp
|
|
|
47
44
|
]
|
|
48
45
|
: initialTokenRequests;
|
|
49
46
|
const asUserOp = signers?.type === 'guardians' || signers?.type === 'session';
|
|
47
|
+
// const asUserOp = true
|
|
50
48
|
if (asUserOp) {
|
|
51
|
-
if (!sourceChain) {
|
|
52
|
-
throw new error_1.SourceChainRequiredForSmartSessionsError();
|
|
53
|
-
}
|
|
54
49
|
const withSession = signers?.type === 'session' ? signers.session : null;
|
|
55
50
|
if (withSession) {
|
|
56
|
-
await (0, smart_session_1.enableSmartSession)(
|
|
51
|
+
await (0, smart_session_1.enableSmartSession)(targetChain, config, withSession);
|
|
57
52
|
}
|
|
58
53
|
// Smart sessions require a UserOp flow
|
|
59
|
-
return await sendTransactionAsUserOp(config,
|
|
54
|
+
return await sendTransactionAsUserOp(config, targetChain, callInputs, signers);
|
|
60
55
|
}
|
|
61
56
|
else {
|
|
62
|
-
return await sendTransactionAsIntent(config,
|
|
57
|
+
return await sendTransactionAsIntent(config, sourceChains, targetChain, callInputs, gasLimit, tokenRequests, accountAddress, signers);
|
|
63
58
|
}
|
|
64
59
|
}
|
|
65
|
-
async function sendTransactionAsUserOp(config,
|
|
60
|
+
async function sendTransactionAsUserOp(config, chain, callInputs, signers) {
|
|
66
61
|
// Make sure the account is deployed
|
|
67
|
-
await (0, accounts_1.deploy)(config,
|
|
62
|
+
await (0, accounts_1.deploy)(config, chain);
|
|
68
63
|
const withSession = signers?.type === 'session' ? signers.session : null;
|
|
69
64
|
const publicClient = (0, viem_1.createPublicClient)({
|
|
70
|
-
chain
|
|
71
|
-
transport: (0, utils_1.createTransport)(
|
|
65
|
+
chain,
|
|
66
|
+
transport: (0, utils_1.createTransport)(chain, config.provider),
|
|
72
67
|
});
|
|
73
|
-
const validatorAccount = await (0, utils_2.getValidatorAccount)(config, signers, publicClient,
|
|
68
|
+
const validatorAccount = await (0, utils_2.getValidatorAccount)(config, signers, publicClient, chain);
|
|
74
69
|
if (!validatorAccount) {
|
|
75
70
|
throw new Error('No validator account found');
|
|
76
71
|
}
|
|
77
72
|
const bundlerClient = (0, utils_1.getBundlerClient)(config, publicClient);
|
|
78
73
|
if (withSession) {
|
|
79
|
-
await (0, smart_session_1.enableSmartSession)(
|
|
74
|
+
await (0, smart_session_1.enableSmartSession)(chain, config, withSession);
|
|
80
75
|
}
|
|
81
|
-
const calls = (0, utils_2.parseCalls)(callInputs,
|
|
76
|
+
const calls = (0, utils_2.parseCalls)(callInputs, chain.id);
|
|
82
77
|
const hash = await bundlerClient.sendUserOperation({
|
|
83
78
|
account: validatorAccount,
|
|
84
79
|
calls,
|
|
@@ -86,17 +81,16 @@ async function sendTransactionAsUserOp(config, sourceChain, targetChain, callInp
|
|
|
86
81
|
return {
|
|
87
82
|
type: 'userop',
|
|
88
83
|
hash,
|
|
89
|
-
|
|
90
|
-
targetChain: targetChain.id,
|
|
84
|
+
chain: chain.id,
|
|
91
85
|
};
|
|
92
86
|
}
|
|
93
|
-
async function sendTransactionAsIntent(config,
|
|
94
|
-
const { intentRoute, hash: intentHash } = await (0, utils_2.prepareTransactionAsIntent)(config,
|
|
87
|
+
async function sendTransactionAsIntent(config, sourceChains, targetChain, callInputs, gasLimit, tokenRequests, accountAddress, signers) {
|
|
88
|
+
const { intentRoute, hash: intentHash } = await (0, utils_2.prepareTransactionAsIntent)(config, sourceChains, targetChain, callInputs, gasLimit, tokenRequests, accountAddress);
|
|
95
89
|
if (!intentRoute) {
|
|
96
90
|
throw new error_1.OrderPathRequiredForIntentsError();
|
|
97
91
|
}
|
|
98
|
-
const signature = await (0, utils_2.signIntent)(config,
|
|
99
|
-
return await (0, utils_2.submitIntentInternal)(config,
|
|
92
|
+
const signature = await (0, utils_2.signIntent)(config, targetChain, intentHash, signers);
|
|
93
|
+
return await (0, utils_2.submitIntentInternal)(config, sourceChains, targetChain, intentRoute.intentOp, signature);
|
|
100
94
|
}
|
|
101
95
|
async function waitForExecution(config, result, acceptsPreconfirmations) {
|
|
102
96
|
const validStatuses = new Set([
|
|
@@ -121,9 +115,9 @@ async function waitForExecution(config, result, acceptsPreconfirmations) {
|
|
|
121
115
|
return intentStatus;
|
|
122
116
|
}
|
|
123
117
|
case 'userop': {
|
|
124
|
-
const targetChain = (0, registry_1.getChainById)(result.
|
|
118
|
+
const targetChain = (0, registry_1.getChainById)(result.chain);
|
|
125
119
|
if (!targetChain) {
|
|
126
|
-
throw new Error(`Unsupported chain ID: ${result.
|
|
120
|
+
throw new Error(`Unsupported chain ID: ${result.chain}`);
|
|
127
121
|
}
|
|
128
122
|
const publicClient = (0, viem_1.createPublicClient)({
|
|
129
123
|
chain: targetChain,
|
|
@@ -148,44 +142,3 @@ async function getPortfolio(config, onTestnets) {
|
|
|
148
142
|
const orchestrator = (0, utils_2.getOrchestratorByChain)(chainId, config.rhinestoneApiKey);
|
|
149
143
|
return orchestrator.getPortfolio(address);
|
|
150
144
|
}
|
|
151
|
-
async function deposit(config, chain, amount, tokenAddress) {
|
|
152
|
-
async function getCalls(address) {
|
|
153
|
-
if (!tokenAddress || tokenAddress === viem_1.zeroAddress) {
|
|
154
|
-
// ETH deposit
|
|
155
|
-
return [(0, compact_1.getDepositEtherCall)(address, amount)];
|
|
156
|
-
}
|
|
157
|
-
else {
|
|
158
|
-
// ERC20 deposit
|
|
159
|
-
const publicClient = (0, viem_1.createPublicClient)({
|
|
160
|
-
chain,
|
|
161
|
-
transport: (0, utils_1.createTransport)(chain, config.provider),
|
|
162
|
-
});
|
|
163
|
-
const allowance = await publicClient.readContract({
|
|
164
|
-
address: tokenAddress,
|
|
165
|
-
abi: viem_1.erc20Abi,
|
|
166
|
-
functionName: 'allowance',
|
|
167
|
-
args: [address, compact_1.COMPACT_ADDRESS],
|
|
168
|
-
});
|
|
169
|
-
const calls = [];
|
|
170
|
-
if (allowance < amount) {
|
|
171
|
-
calls.push((0, compact_1.getApproveErc20Call)(tokenAddress, amount));
|
|
172
|
-
}
|
|
173
|
-
calls.push((0, compact_1.getDepositErc20Call)(address, tokenAddress, amount));
|
|
174
|
-
return calls;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
const address = (0, accounts_1.getAddress)(config);
|
|
178
|
-
const owners = config.owners;
|
|
179
|
-
const calls = await getCalls(address);
|
|
180
|
-
return await sendTransactionAsUserOp(config, chain, chain, calls, owners.type === 'ecdsa'
|
|
181
|
-
? {
|
|
182
|
-
type: 'owner',
|
|
183
|
-
kind: 'ecdsa',
|
|
184
|
-
accounts: owners.accounts,
|
|
185
|
-
}
|
|
186
|
-
: {
|
|
187
|
-
type: 'owner',
|
|
188
|
-
kind: 'passkey',
|
|
189
|
-
account: owners.account,
|
|
190
|
-
});
|
|
191
|
-
}
|
|
@@ -24,7 +24,7 @@ async function getSessionDetails(config, sessions, sessionIndex, signature) {
|
|
|
24
24
|
};
|
|
25
25
|
sessionDetails.enableSessionData.signature =
|
|
26
26
|
signature ??
|
|
27
|
-
(await (0, accounts_1.getPackedSignature)(config,
|
|
27
|
+
(await (0, accounts_1.getPackedSignature)(config, undefined, chain, validator, sessionDetails.permissionEnableHash));
|
|
28
28
|
return sessionDetails;
|
|
29
29
|
}
|
|
30
30
|
async function getEnableSessionDetails(accountType, sessions, sessionIndex, accountAddress, provider) {
|
|
@@ -5,8 +5,7 @@ import type { Call, CallInput, RhinestoneAccountConfig, SignerSet, TokenRequest,
|
|
|
5
5
|
type TransactionResult = {
|
|
6
6
|
type: 'userop';
|
|
7
7
|
hash: Hex;
|
|
8
|
-
|
|
9
|
-
targetChain: number;
|
|
8
|
+
chain: number;
|
|
10
9
|
} | {
|
|
11
10
|
type: 'intent';
|
|
12
11
|
id: bigint;
|
|
@@ -33,10 +32,10 @@ interface SignedTransactionData extends PreparedTransactionData {
|
|
|
33
32
|
declare function prepareTransaction(config: RhinestoneAccountConfig, transaction: Transaction): Promise<PreparedTransactionData>;
|
|
34
33
|
declare function signTransaction(config: RhinestoneAccountConfig, preparedTransaction: PreparedTransactionData): Promise<SignedTransactionData>;
|
|
35
34
|
declare function submitTransaction(config: RhinestoneAccountConfig, signedTransaction: SignedTransactionData): Promise<TransactionResult>;
|
|
36
|
-
declare function prepareTransactionAsIntent(config: RhinestoneAccountConfig,
|
|
37
|
-
declare function signIntent(config: RhinestoneAccountConfig,
|
|
35
|
+
declare function prepareTransactionAsIntent(config: RhinestoneAccountConfig, sourceChains: Chain[] | undefined, targetChain: Chain, callInputs: CallInput[], gasLimit: bigint | undefined, tokenRequests: TokenRequest[], accountAddress: Address): Promise<IntentData>;
|
|
36
|
+
declare function signIntent(config: RhinestoneAccountConfig, targetChain: Chain, intentHash: Hex, signers?: SignerSet): Promise<`0x${string}`>;
|
|
38
37
|
declare function getOrchestratorByChain(chainId: number, apiKey: string): import("../orchestrator").Orchestrator;
|
|
39
|
-
declare function submitIntentInternal(config: RhinestoneAccountConfig,
|
|
38
|
+
declare function submitIntentInternal(config: RhinestoneAccountConfig, sourceChains: Chain[] | undefined, targetChain: Chain, intentOp: IntentOp, signature: Hex): Promise<TransactionResult>;
|
|
40
39
|
declare function getValidatorAccount(config: RhinestoneAccountConfig, signers: SignerSet | undefined, publicClient: PublicClient, chain: Chain): Promise<import("viem/account-abstraction").SmartAccount<import("viem/account-abstraction").SmartAccountImplementation<import("viem").Abi, "0.7">> | null | undefined>;
|
|
41
40
|
declare function parseCalls(calls: CallInput[], chainId: number): Call[];
|
|
42
41
|
export { prepareTransaction, signTransaction, submitTransaction, getOrchestratorByChain, signIntent, prepareTransactionAsIntent, submitIntentInternal, getValidatorAccount, parseCalls, };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../execution/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,KAAK,EAEV,KAAK,GAAG,EACR,KAAK,YAAY,EAGlB,MAAM,MAAM,CAAA;AACb,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,0BAA0B,CAAA;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../execution/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,KAAK,EAEV,KAAK,GAAG,EACR,KAAK,YAAY,EAGlB,MAAM,MAAM,CAAA;AACb,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,0BAA0B,CAAA;AAoBjC,OAAO,EAIL,KAAK,QAAQ,EACb,KAAK,WAAW,EAEjB,MAAM,iBAAiB,CAAA;AAMxB,OAAO,KAAK,EACV,IAAI,EACJ,SAAS,EACT,uBAAuB,EACvB,SAAS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SAAS,EAC5B,aAAa,EAAE,YAAY,EAAE,EAC7B,cAAc,EAAE,OAAO,uBAmDxB;AAED,iBAAe,UAAU,CACvB,MAAM,EAAE,uBAAuB,EAC/B,WAAW,EAAE,KAAK,EAClB,UAAU,EAAE,GAAG,EACf,OAAO,CAAC,EAAE,SAAS,0BAoBpB;AA2FD,iBAAS,sBAAsB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,0CAK9D;AAED,iBAAe,oBAAoB,CACjC,MAAM,EAAE,uBAAuB,EAC/B,YAAY,EAAE,KAAK,EAAE,GAAG,SAAS,EACjC,WAAW,EAAE,KAAK,EAClB,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,GAAG,8BAkBf;AAED,iBAAe,mBAAmB,CAChC,MAAM,EAAE,uBAAuB,EAC/B,OAAO,EAAE,SAAS,GAAG,SAAS,EAC9B,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,KAAK,yKA6Bb;AAiDD,iBAAS,UAAU,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,EAAE,CAM/D;AAED,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,sBAAsB,EACtB,UAAU,EACV,0BAA0B,EAC1B,oBAAoB,EACpB,mBAAmB,EACnB,UAAU,GACX,CAAA;AACD,YAAY,EACV,UAAU,EACV,iBAAiB,EACjB,uBAAuB,EACvB,qBAAqB,GACtB,CAAA"}
|
|
@@ -20,22 +20,19 @@ const consts_1 = require("../orchestrator/consts");
|
|
|
20
20
|
const registry_1 = require("../orchestrator/registry");
|
|
21
21
|
const error_1 = require("./error");
|
|
22
22
|
async function prepareTransaction(config, transaction) {
|
|
23
|
-
const {
|
|
23
|
+
const { sourceChains, targetChain, tokenRequests, signers } = getTransactionParams(transaction);
|
|
24
24
|
const accountAddress = (0, accounts_1.getAddress)(config);
|
|
25
25
|
let data;
|
|
26
26
|
const asUserOp = signers?.type === 'guardians' || signers?.type === 'session';
|
|
27
27
|
if (asUserOp) {
|
|
28
|
-
if (
|
|
29
|
-
throw new error_1.
|
|
30
|
-
}
|
|
31
|
-
if (sourceChain.id !== targetChain.id) {
|
|
32
|
-
throw new error_1.SourceTargetChainMismatchError();
|
|
28
|
+
if (sourceChains && sourceChains.length > 0) {
|
|
29
|
+
throw new error_1.SourceChainsNotAvailableForUserOpFlowError();
|
|
33
30
|
}
|
|
34
31
|
// Smart sessions require a UserOp flow
|
|
35
|
-
data = await prepareTransactionAsUserOp(config,
|
|
32
|
+
data = await prepareTransactionAsUserOp(config, targetChain, transaction.calls, signers);
|
|
36
33
|
}
|
|
37
34
|
else {
|
|
38
|
-
data = await prepareTransactionAsIntent(config,
|
|
35
|
+
data = await prepareTransactionAsIntent(config, sourceChains, targetChain, transaction.calls, transaction.gasLimit, tokenRequests, accountAddress);
|
|
39
36
|
}
|
|
40
37
|
return {
|
|
41
38
|
data,
|
|
@@ -43,12 +40,12 @@ async function prepareTransaction(config, transaction) {
|
|
|
43
40
|
};
|
|
44
41
|
}
|
|
45
42
|
async function signTransaction(config, preparedTransaction) {
|
|
46
|
-
const {
|
|
43
|
+
const { targetChain, signers } = getTransactionParams(preparedTransaction.transaction);
|
|
47
44
|
const data = preparedTransaction.data;
|
|
48
45
|
const asUserOp = data.type === 'userop';
|
|
49
46
|
let signature;
|
|
50
47
|
if (asUserOp) {
|
|
51
|
-
const chain =
|
|
48
|
+
const chain = targetChain;
|
|
52
49
|
const userOp = data.userOp;
|
|
53
50
|
if (!userOp) {
|
|
54
51
|
throw new error_1.UserOperationRequiredForSmartSessionsError();
|
|
@@ -57,7 +54,7 @@ async function signTransaction(config, preparedTransaction) {
|
|
|
57
54
|
signature = await signUserOp(config, chain, signers, userOp);
|
|
58
55
|
}
|
|
59
56
|
else {
|
|
60
|
-
signature = await signIntent(config,
|
|
57
|
+
signature = await signIntent(config, targetChain, data.hash, signers);
|
|
61
58
|
}
|
|
62
59
|
return {
|
|
63
60
|
data,
|
|
@@ -67,10 +64,10 @@ async function signTransaction(config, preparedTransaction) {
|
|
|
67
64
|
}
|
|
68
65
|
async function submitTransaction(config, signedTransaction) {
|
|
69
66
|
const { data, transaction, signature } = signedTransaction;
|
|
70
|
-
const {
|
|
67
|
+
const { sourceChains, targetChain } = getTransactionParams(transaction);
|
|
71
68
|
const asUserOp = data.type === 'userop';
|
|
72
69
|
if (asUserOp) {
|
|
73
|
-
const chain =
|
|
70
|
+
const chain = targetChain;
|
|
74
71
|
const userOp = data.userOp;
|
|
75
72
|
if (!userOp) {
|
|
76
73
|
throw new error_1.UserOperationRequiredForSmartSessionsError();
|
|
@@ -83,11 +80,11 @@ async function submitTransaction(config, signedTransaction) {
|
|
|
83
80
|
if (!intentOp) {
|
|
84
81
|
throw new error_1.OrderPathRequiredForIntentsError();
|
|
85
82
|
}
|
|
86
|
-
return await submitIntent(config,
|
|
83
|
+
return await submitIntent(config, sourceChains, targetChain, intentOp, signature);
|
|
87
84
|
}
|
|
88
85
|
}
|
|
89
86
|
function getTransactionParams(transaction) {
|
|
90
|
-
const
|
|
87
|
+
const sourceChains = 'chain' in transaction ? [transaction.chain] : transaction.sourceChains;
|
|
91
88
|
const targetChain = 'chain' in transaction ? transaction.chain : transaction.targetChain;
|
|
92
89
|
const initialTokenRequests = transaction.tokenRequests;
|
|
93
90
|
const signers = transaction.signers;
|
|
@@ -101,7 +98,7 @@ function getTransactionParams(transaction) {
|
|
|
101
98
|
]
|
|
102
99
|
: initialTokenRequests;
|
|
103
100
|
return {
|
|
104
|
-
|
|
101
|
+
sourceChains,
|
|
105
102
|
targetChain,
|
|
106
103
|
tokenRequests,
|
|
107
104
|
signers,
|
|
@@ -133,12 +130,12 @@ async function prepareTransactionAsUserOp(config, chain, callInputs, signers) {
|
|
|
133
130
|
}),
|
|
134
131
|
};
|
|
135
132
|
}
|
|
136
|
-
async function prepareTransactionAsIntent(config,
|
|
133
|
+
async function prepareTransactionAsIntent(config, sourceChains, targetChain, callInputs, gasLimit, tokenRequests, accountAddress) {
|
|
137
134
|
const initCode = (0, accounts_1.getInitCode)(config);
|
|
138
135
|
const calls = parseCalls(callInputs, targetChain.id);
|
|
139
|
-
const accountAccessList =
|
|
136
|
+
const accountAccessList = sourceChains && sourceChains.length > 0
|
|
140
137
|
? {
|
|
141
|
-
chainIds:
|
|
138
|
+
chainIds: sourceChains.map((chain) => chain.id),
|
|
142
139
|
}
|
|
143
140
|
: undefined;
|
|
144
141
|
const metaIntent = {
|
|
@@ -177,18 +174,14 @@ async function prepareTransactionAsIntent(config, sourceChain, targetChain, call
|
|
|
177
174
|
hash: intentHash,
|
|
178
175
|
};
|
|
179
176
|
}
|
|
180
|
-
async function signIntent(config,
|
|
177
|
+
async function signIntent(config, targetChain, intentHash, signers) {
|
|
181
178
|
const validator = getValidator(config, signers);
|
|
182
179
|
if (!validator) {
|
|
183
180
|
throw new Error('Validator not available');
|
|
184
181
|
}
|
|
185
182
|
const ownerValidator = (0, validators_1.getOwnerValidator)(config);
|
|
186
183
|
const isRoot = validator.address === ownerValidator.address;
|
|
187
|
-
const
|
|
188
|
-
if (!owners) {
|
|
189
|
-
throw new Error('No owners found');
|
|
190
|
-
}
|
|
191
|
-
const signature = await (0, accounts_1.getPackedSignature)(config, owners, sourceChain || targetChain, {
|
|
184
|
+
const signature = await (0, accounts_1.getPackedSignature)(config, signers, targetChain, {
|
|
192
185
|
address: validator.address,
|
|
193
186
|
isRoot,
|
|
194
187
|
}, intentHash);
|
|
@@ -245,20 +238,19 @@ async function submitUserOp(config, chain, userOp, signature) {
|
|
|
245
238
|
return {
|
|
246
239
|
type: 'userop',
|
|
247
240
|
hash,
|
|
248
|
-
|
|
249
|
-
targetChain: chain.id,
|
|
241
|
+
chain: chain.id,
|
|
250
242
|
};
|
|
251
243
|
}
|
|
252
|
-
async function submitIntent(config,
|
|
253
|
-
return submitIntentInternal(config,
|
|
244
|
+
async function submitIntent(config, sourceChains, targetChain, intentOp, signature) {
|
|
245
|
+
return submitIntentInternal(config, sourceChains, targetChain, intentOp, signature);
|
|
254
246
|
}
|
|
255
247
|
function getOrchestratorByChain(chainId, apiKey) {
|
|
256
248
|
const orchestratorUrl = (0, registry_1.isTestnet)(chainId)
|
|
257
|
-
? consts_1.
|
|
249
|
+
? consts_1.STAGING_ORCHESTRATOR_URL
|
|
258
250
|
: consts_1.PROD_ORCHESTRATOR_URL;
|
|
259
251
|
return (0, orchestrator_1.getOrchestrator)(apiKey, orchestratorUrl);
|
|
260
252
|
}
|
|
261
|
-
async function submitIntentInternal(config,
|
|
253
|
+
async function submitIntentInternal(config, sourceChains, targetChain, intentOp, signature) {
|
|
262
254
|
const signedIntentOp = {
|
|
263
255
|
...intentOp,
|
|
264
256
|
originSignatures: Array(intentOp.elements.length).fill(signature),
|
|
@@ -269,7 +261,7 @@ async function submitIntentInternal(config, sourceChain, targetChain, intentOp,
|
|
|
269
261
|
return {
|
|
270
262
|
type: 'intent',
|
|
271
263
|
id: BigInt(intentResults.result.id),
|
|
272
|
-
|
|
264
|
+
sourceChains: sourceChains?.map((chain) => chain.id),
|
|
273
265
|
targetChain: targetChain.id,
|
|
274
266
|
};
|
|
275
267
|
}
|
|
@@ -302,10 +294,7 @@ function getValidator(config, signers) {
|
|
|
302
294
|
if (withOwner) {
|
|
303
295
|
// ECDSA
|
|
304
296
|
if (withOwner.kind === 'ecdsa') {
|
|
305
|
-
return (0, core_1.getOwnableValidator)(
|
|
306
|
-
threshold: 1,
|
|
307
|
-
owners: withOwner.accounts.map((account) => account.address),
|
|
308
|
-
});
|
|
297
|
+
return (0, core_1.getOwnableValidator)(1, withOwner.accounts.map((account) => account.address));
|
|
309
298
|
}
|
|
310
299
|
// Passkeys (WebAuthn)
|
|
311
300
|
if (withOwner.kind === 'passkey') {
|
|
@@ -315,6 +304,10 @@ function getValidator(config, signers) {
|
|
|
315
304
|
authenticatorId: passkeyAccount.id,
|
|
316
305
|
});
|
|
317
306
|
}
|
|
307
|
+
// Multi-factor
|
|
308
|
+
if (withOwner.kind === 'multi-factor') {
|
|
309
|
+
return (0, core_1.getMultiFactorValidator)(1, withOwner.validators);
|
|
310
|
+
}
|
|
318
311
|
}
|
|
319
312
|
// Smart sessions
|
|
320
313
|
const withSession = signers.type === 'session' ? signers.session : null;
|
|
@@ -329,43 +322,6 @@ function getValidator(config, signers) {
|
|
|
329
322
|
// Fallback
|
|
330
323
|
return undefined;
|
|
331
324
|
}
|
|
332
|
-
function getOwners(config, signers) {
|
|
333
|
-
if (!signers) {
|
|
334
|
-
return config.owners;
|
|
335
|
-
}
|
|
336
|
-
// Owners
|
|
337
|
-
const withOwner = signers.type === 'owner' ? signers : null;
|
|
338
|
-
if (withOwner) {
|
|
339
|
-
// ECDSA
|
|
340
|
-
if (withOwner.kind === 'ecdsa') {
|
|
341
|
-
return {
|
|
342
|
-
type: 'ecdsa',
|
|
343
|
-
accounts: withOwner.accounts,
|
|
344
|
-
};
|
|
345
|
-
}
|
|
346
|
-
// Passkeys (WebAuthn)
|
|
347
|
-
if (withOwner.kind === 'passkey') {
|
|
348
|
-
return {
|
|
349
|
-
type: 'passkey',
|
|
350
|
-
account: withOwner.account,
|
|
351
|
-
};
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
// Smart sessions
|
|
355
|
-
const withSession = signers.type === 'session' ? signers.session : null;
|
|
356
|
-
if (withSession) {
|
|
357
|
-
return withSession.owners;
|
|
358
|
-
}
|
|
359
|
-
// Guardians (social recovery)
|
|
360
|
-
const withGuardians = signers.type === 'guardians' ? signers : null;
|
|
361
|
-
if (withGuardians) {
|
|
362
|
-
return {
|
|
363
|
-
type: 'ecdsa',
|
|
364
|
-
accounts: withGuardians.guardians,
|
|
365
|
-
};
|
|
366
|
-
}
|
|
367
|
-
return undefined;
|
|
368
|
-
}
|
|
369
325
|
function parseCalls(calls, chainId) {
|
|
370
326
|
return calls.map((call) => ({
|
|
371
327
|
data: call.data ?? '0x',
|
package/dist/src/index.d.ts
CHANGED
|
@@ -2,9 +2,9 @@ import type { Address, Chain, Hex } from 'viem';
|
|
|
2
2
|
import type { UserOperationReceipt } from 'viem/account-abstraction';
|
|
3
3
|
import { AccountError, Eip7702AccountMustHaveEoaError, Eip7702NotSupportedForAccountError, ExistingEip7702AccountsNotSupportedError, FactoryArgsNotAvailableError, isAccountError, SigningNotSupportedForAccountError, SignMessageNotSupportedByAccountError, SmartSessionsNotEnabledError } from './accounts';
|
|
4
4
|
import { createTransport } from './accounts/utils';
|
|
5
|
-
import { addOwner, changeThreshold, disableEcdsa, disablePasskeys, enableEcdsa, enablePasskeys, encodeSmartSessionSignature, recover, removeOwner, setUpRecovery, trustAttester } from './actions';
|
|
5
|
+
import { addOwner, changeMultiFactorThreshold, changeThreshold, disableEcdsa, disableMultiFactor, disablePasskeys, enableEcdsa, enableMultiFactor, enablePasskeys, encodeSmartSessionSignature, recover, removeOwner, removeSubValidator, setSubValidator, setUpRecovery, trustAttester } from './actions';
|
|
6
6
|
import type { TransactionResult } from './execution';
|
|
7
|
-
import { ExecutionError, IntentFailedError, isExecutionError, OrderPathRequiredForIntentsError, SessionChainRequiredError,
|
|
7
|
+
import { ExecutionError, IntentFailedError, isExecutionError, OrderPathRequiredForIntentsError, SessionChainRequiredError, SourceChainsNotAvailableForUserOpFlowError, UserOperationRequiredForSmartSessionsError } from './execution';
|
|
8
8
|
import { type SessionDetails } from './execution/smart-session';
|
|
9
9
|
import { type IntentData, type PreparedTransactionData, type SignedTransactionData } from './execution/utils';
|
|
10
10
|
import { AuthenticationRequiredError, InsufficientBalanceError, type IntentCost, type IntentInput, IntentNotFoundError, type IntentOp, type IntentOpStatus, type IntentResult, type IntentRoute, InvalidApiKeyError, InvalidIntentSignatureError, isOrchestratorError, NoPathFoundError, OnlyOneTargetTokenAmountCanBeUnsetError, OrchestratorError, type Portfolio, type SettlementSystem, type SignedIntentOp, TokenNotSupportedError, UnsupportedChainError, UnsupportedChainIdError, UnsupportedTokenError } from './orchestrator';
|
|
@@ -27,7 +27,6 @@ interface RhinestoneAccount {
|
|
|
27
27
|
threshold: number;
|
|
28
28
|
} | null>;
|
|
29
29
|
getValidators: (chain: Chain) => Promise<Address[]>;
|
|
30
|
-
deposit: (chain: Chain, amount: bigint, tokenAddress?: Address) => Promise<TransactionResult>;
|
|
31
30
|
}
|
|
32
31
|
/**
|
|
33
32
|
* Initialize a Rhinestone account
|
|
@@ -36,6 +35,6 @@ interface RhinestoneAccount {
|
|
|
36
35
|
* @returns account
|
|
37
36
|
*/
|
|
38
37
|
declare function createRhinestoneAccount(config: RhinestoneAccountConfig): Promise<RhinestoneAccount>;
|
|
39
|
-
export { createRhinestoneAccount, createTransport, addOwner, changeThreshold, disableEcdsa, disablePasskeys, enableEcdsa, enablePasskeys, recover, removeOwner,
|
|
38
|
+
export { createRhinestoneAccount, createTransport, addOwner, changeMultiFactorThreshold, changeThreshold, disableEcdsa, disableMultiFactor, disablePasskeys, enableEcdsa, enableMultiFactor, enablePasskeys, encodeSmartSessionSignature, recover, removeOwner, removeSubValidator, setSubValidator, setUpRecovery, trustAttester, isAccountError, AccountError, Eip7702AccountMustHaveEoaError, ExistingEip7702AccountsNotSupportedError, FactoryArgsNotAvailableError, SmartSessionsNotEnabledError, SigningNotSupportedForAccountError, SignMessageNotSupportedByAccountError, Eip7702NotSupportedForAccountError, isExecutionError, IntentFailedError, ExecutionError, SourceChainsNotAvailableForUserOpFlowError, UserOperationRequiredForSmartSessionsError, OrderPathRequiredForIntentsError, SessionChainRequiredError, isOrchestratorError, AuthenticationRequiredError, InsufficientBalanceError, InvalidApiKeyError, InvalidIntentSignatureError, NoPathFoundError, OnlyOneTargetTokenAmountCanBeUnsetError, OrchestratorError, IntentNotFoundError, TokenNotSupportedError, UnsupportedChainError, UnsupportedChainIdError, UnsupportedTokenError, };
|
|
40
39
|
export type { RhinestoneAccount, Session, Call, IntentData, PreparedTransactionData, SignedTransactionData, TransactionResult, IntentCost, IntentInput, IntentOp, IntentOpStatus, IntentResult, IntentRoute, SettlementSystem, SignedIntentOp, Portfolio, };
|
|
41
40
|
//# 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,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AAC/C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AACpE,OAAO,EACL,YAAY,EAEZ,8BAA8B,EAC9B,kCAAkC,EAClC,wCAAwC,EACxC,4BAA4B,EAE5B,cAAc,EACd,kCAAkC,EAClC,qCAAqC,EACrC,4BAA4B,EAC7B,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EACL,QAAQ,EACR,eAAe,EACf,YAAY,EACZ,eAAe,EACf,WAAW,EACX,cAAc,EACd,2BAA2B,EAC3B,OAAO,EACP,WAAW,EACX,aAAa,EACb,aAAa,EACd,MAAM,WAAW,CAAA;AAClB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AAC/C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AACpE,OAAO,EACL,YAAY,EAEZ,8BAA8B,EAC9B,kCAAkC,EAClC,wCAAwC,EACxC,4BAA4B,EAE5B,cAAc,EACd,kCAAkC,EAClC,qCAAqC,EACrC,4BAA4B,EAC7B,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EACL,QAAQ,EACR,0BAA0B,EAC1B,eAAe,EACf,YAAY,EACZ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ACL,uBAAuB,EACvB,eAAe,EAEf,QAAQ,EACR,0BAA0B,EAC1B,eAAe,EACf,YAAY,EACZ,kBAAkB,EAClB,eAAe,EACf,WAAW,EACX,iBAAiB,EACjB,cAAc,EACd,2BAA2B,EAC3B,OAAO,EACP,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,aAAa,EAEb,cAAc,EACd,YAAY,EACZ,8BAA8B,EAC9B,wCAAwC,EACxC,4BAA4B,EAC5B,4BAA4B,EAC5B,kCAAkC,EAClC,qCAAqC,EACrC,kCAAkC,EAElC,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,0CAA0C,EAC1C,0CAA0C,EAC1C,gCAAgC,EAChC,yBAAyB,EAEzB,mBAAmB,EACnB,2BAA2B,EAC3B,wBAAwB,EACxB,kBAAkB,EAClB,2BAA2B,EAC3B,gBAAgB,EAChB,uCAAuC,EACvC,iBAAiB,EACjB,mBAAmB,EACnB,sBAAsB,EACtB,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,GACtB,CAAA;AACD,YAAY,EACV,iBAAiB,EACjB,OAAO,EACP,IAAI,EACJ,UAAU,EACV,uBAAuB,EACvB,qBAAqB,EACrB,iBAAiB,EACjB,UAAU,EACV,WAAW,EACX,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,SAAS,GACV,CAAA"}
|
package/dist/src/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UnsupportedTokenError = exports.UnsupportedChainIdError = exports.UnsupportedChainError = exports.TokenNotSupportedError = exports.IntentNotFoundError = exports.OrchestratorError = exports.OnlyOneTargetTokenAmountCanBeUnsetError = exports.NoPathFoundError = exports.InvalidIntentSignatureError = exports.InvalidApiKeyError = exports.InsufficientBalanceError = exports.AuthenticationRequiredError = exports.isOrchestratorError = exports.SessionChainRequiredError = exports.OrderPathRequiredForIntentsError = exports.UserOperationRequiredForSmartSessionsError = exports.
|
|
3
|
+
exports.UnsupportedTokenError = exports.UnsupportedChainIdError = exports.UnsupportedChainError = exports.TokenNotSupportedError = exports.IntentNotFoundError = exports.OrchestratorError = exports.OnlyOneTargetTokenAmountCanBeUnsetError = exports.NoPathFoundError = exports.InvalidIntentSignatureError = exports.InvalidApiKeyError = exports.InsufficientBalanceError = exports.AuthenticationRequiredError = exports.isOrchestratorError = exports.SessionChainRequiredError = exports.OrderPathRequiredForIntentsError = exports.UserOperationRequiredForSmartSessionsError = exports.SourceChainsNotAvailableForUserOpFlowError = exports.ExecutionError = exports.IntentFailedError = exports.isExecutionError = exports.Eip7702NotSupportedForAccountError = exports.SignMessageNotSupportedByAccountError = exports.SigningNotSupportedForAccountError = exports.SmartSessionsNotEnabledError = exports.FactoryArgsNotAvailableError = exports.ExistingEip7702AccountsNotSupportedError = exports.Eip7702AccountMustHaveEoaError = exports.AccountError = exports.isAccountError = exports.trustAttester = exports.setUpRecovery = exports.setSubValidator = exports.removeSubValidator = exports.removeOwner = exports.recover = exports.encodeSmartSessionSignature = exports.enablePasskeys = exports.enableMultiFactor = exports.enableEcdsa = exports.disablePasskeys = exports.disableMultiFactor = exports.disableEcdsa = exports.changeThreshold = exports.changeMultiFactorThreshold = exports.addOwner = exports.createTransport = void 0;
|
|
4
4
|
exports.createRhinestoneAccount = createRhinestoneAccount;
|
|
5
5
|
const accounts_1 = require("./accounts");
|
|
6
6
|
Object.defineProperty(exports, "AccountError", { enumerable: true, get: function () { return accounts_1.AccountError; } });
|
|
@@ -16,14 +16,19 @@ const utils_1 = require("./accounts/utils");
|
|
|
16
16
|
Object.defineProperty(exports, "createTransport", { enumerable: true, get: function () { return utils_1.createTransport; } });
|
|
17
17
|
const actions_1 = require("./actions");
|
|
18
18
|
Object.defineProperty(exports, "addOwner", { enumerable: true, get: function () { return actions_1.addOwner; } });
|
|
19
|
+
Object.defineProperty(exports, "changeMultiFactorThreshold", { enumerable: true, get: function () { return actions_1.changeMultiFactorThreshold; } });
|
|
19
20
|
Object.defineProperty(exports, "changeThreshold", { enumerable: true, get: function () { return actions_1.changeThreshold; } });
|
|
20
21
|
Object.defineProperty(exports, "disableEcdsa", { enumerable: true, get: function () { return actions_1.disableEcdsa; } });
|
|
22
|
+
Object.defineProperty(exports, "disableMultiFactor", { enumerable: true, get: function () { return actions_1.disableMultiFactor; } });
|
|
21
23
|
Object.defineProperty(exports, "disablePasskeys", { enumerable: true, get: function () { return actions_1.disablePasskeys; } });
|
|
22
24
|
Object.defineProperty(exports, "enableEcdsa", { enumerable: true, get: function () { return actions_1.enableEcdsa; } });
|
|
25
|
+
Object.defineProperty(exports, "enableMultiFactor", { enumerable: true, get: function () { return actions_1.enableMultiFactor; } });
|
|
23
26
|
Object.defineProperty(exports, "enablePasskeys", { enumerable: true, get: function () { return actions_1.enablePasskeys; } });
|
|
24
27
|
Object.defineProperty(exports, "encodeSmartSessionSignature", { enumerable: true, get: function () { return actions_1.encodeSmartSessionSignature; } });
|
|
25
28
|
Object.defineProperty(exports, "recover", { enumerable: true, get: function () { return actions_1.recover; } });
|
|
26
29
|
Object.defineProperty(exports, "removeOwner", { enumerable: true, get: function () { return actions_1.removeOwner; } });
|
|
30
|
+
Object.defineProperty(exports, "removeSubValidator", { enumerable: true, get: function () { return actions_1.removeSubValidator; } });
|
|
31
|
+
Object.defineProperty(exports, "setSubValidator", { enumerable: true, get: function () { return actions_1.setSubValidator; } });
|
|
27
32
|
Object.defineProperty(exports, "setUpRecovery", { enumerable: true, get: function () { return actions_1.setUpRecovery; } });
|
|
28
33
|
Object.defineProperty(exports, "trustAttester", { enumerable: true, get: function () { return actions_1.trustAttester; } });
|
|
29
34
|
const execution_1 = require("./execution");
|
|
@@ -32,8 +37,7 @@ Object.defineProperty(exports, "IntentFailedError", { enumerable: true, get: fun
|
|
|
32
37
|
Object.defineProperty(exports, "isExecutionError", { enumerable: true, get: function () { return execution_1.isExecutionError; } });
|
|
33
38
|
Object.defineProperty(exports, "OrderPathRequiredForIntentsError", { enumerable: true, get: function () { return execution_1.OrderPathRequiredForIntentsError; } });
|
|
34
39
|
Object.defineProperty(exports, "SessionChainRequiredError", { enumerable: true, get: function () { return execution_1.SessionChainRequiredError; } });
|
|
35
|
-
Object.defineProperty(exports, "
|
|
36
|
-
Object.defineProperty(exports, "SourceTargetChainMismatchError", { enumerable: true, get: function () { return execution_1.SourceTargetChainMismatchError; } });
|
|
40
|
+
Object.defineProperty(exports, "SourceChainsNotAvailableForUserOpFlowError", { enumerable: true, get: function () { return execution_1.SourceChainsNotAvailableForUserOpFlowError; } });
|
|
37
41
|
Object.defineProperty(exports, "UserOperationRequiredForSmartSessionsError", { enumerable: true, get: function () { return execution_1.UserOperationRequiredForSmartSessionsError; } });
|
|
38
42
|
const smart_session_1 = require("./execution/smart-session");
|
|
39
43
|
const utils_2 = require("./execution/utils");
|
|
@@ -129,9 +133,6 @@ async function createRhinestoneAccount(config) {
|
|
|
129
133
|
const account = getAddress();
|
|
130
134
|
return (0, modules_1.getValidators)(accountType, account, chain, config.provider);
|
|
131
135
|
}
|
|
132
|
-
async function deposit(chain, amount, tokenAddress) {
|
|
133
|
-
return (0, execution_1.deposit)(config, chain, amount, tokenAddress);
|
|
134
|
-
}
|
|
135
136
|
return {
|
|
136
137
|
config,
|
|
137
138
|
deploy,
|
|
@@ -147,6 +148,5 @@ async function createRhinestoneAccount(config) {
|
|
|
147
148
|
areAttestersTrusted,
|
|
148
149
|
getOwners,
|
|
149
150
|
getValidators,
|
|
150
|
-
deposit,
|
|
151
151
|
};
|
|
152
152
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Account, type Address, type Hex } from 'viem';
|
|
2
|
-
import type { OwnerSet, RhinestoneAccountConfig } from '../../types';
|
|
2
|
+
import type { OwnableValidatorConfig, OwnerSet, RhinestoneAccountConfig, WebauthnValidatorConfig } from '../../types';
|
|
3
3
|
import { type Module } from '../common';
|
|
4
4
|
interface PublicKey {
|
|
5
5
|
prefix?: number | undefined;
|
|
@@ -12,15 +12,14 @@ interface WebauthnCredential {
|
|
|
12
12
|
}
|
|
13
13
|
declare const OWNABLE_VALIDATOR_ADDRESS: Address;
|
|
14
14
|
declare const WEBAUTHN_VALIDATOR_ADDRESS: Address;
|
|
15
|
+
declare const MULTI_FACTOR_VALIDATOR_ADDRESS: Address;
|
|
15
16
|
declare function getOwnerValidator(config: RhinestoneAccountConfig): Module;
|
|
16
17
|
declare function getMockSignature(ownerSet: OwnerSet): Hex;
|
|
17
18
|
declare function getValidator(owners: OwnerSet): Module;
|
|
18
|
-
declare function getOwnableValidator(
|
|
19
|
-
threshold: number;
|
|
20
|
-
owners: Address[];
|
|
21
|
-
}): Module;
|
|
19
|
+
declare function getOwnableValidator(threshold: number, owners: Address[]): Module;
|
|
22
20
|
declare function getWebAuthnValidator(webAuthnCredential: WebauthnCredential): Module;
|
|
21
|
+
declare function getMultiFactorValidator(threshold: number, validators: (OwnableValidatorConfig | WebauthnValidatorConfig | null)[]): Module;
|
|
23
22
|
declare function getSocialRecoveryValidator(guardians: Account[], threshold?: number): Module;
|
|
24
|
-
export { OWNABLE_VALIDATOR_ADDRESS, WEBAUTHN_VALIDATOR_ADDRESS, getOwnerValidator, getOwnableValidator, getWebAuthnValidator, getSocialRecoveryValidator, getValidator, getMockSignature, };
|
|
23
|
+
export { OWNABLE_VALIDATOR_ADDRESS, WEBAUTHN_VALIDATOR_ADDRESS, MULTI_FACTOR_VALIDATOR_ADDRESS, getOwnerValidator, getOwnableValidator, getWebAuthnValidator, getMultiFactorValidator, getSocialRecoveryValidator, getValidator, getMockSignature, };
|
|
25
24
|
export type { WebauthnCredential };
|
|
26
25
|
//# sourceMappingURL=core.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../../modules/validators/core.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KA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