@rhinestone/sdk 1.5.0 → 2.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/accounts/error.d.ts +1 -1
- package/dist/src/accounts/error.js +1 -19
- package/dist/src/accounts/index.d.ts +5 -5
- package/dist/src/accounts/index.js +121 -157
- package/dist/src/accounts/json-rpc/index.d.ts +1 -1
- package/dist/src/accounts/json-rpc/index.js +8 -10
- package/dist/src/accounts/json-rpc/providers.d.ts +1 -1
- package/dist/src/accounts/json-rpc/providers.js +4 -7
- package/dist/src/accounts/kernel.d.ts +3 -3
- package/dist/src/accounts/kernel.js +66 -75
- package/dist/src/accounts/nexus.d.ts +3 -3
- package/dist/src/accounts/nexus.js +62 -73
- package/dist/src/accounts/passport.d.ts +3 -3
- package/dist/src/accounts/passport.js +9 -13
- package/dist/src/accounts/safe.d.ts +3 -3
- package/dist/src/accounts/safe.js +54 -63
- package/dist/src/accounts/signing/common.d.ts +2 -2
- package/dist/src/accounts/signing/common.js +30 -36
- package/dist/src/accounts/signing/message.d.ts +2 -2
- package/dist/src/accounts/signing/message.js +10 -12
- package/dist/src/accounts/signing/passkeys.js +11 -17
- package/dist/src/accounts/signing/typedData.d.ts +1 -1
- package/dist/src/accounts/signing/typedData.js +6 -8
- package/dist/src/accounts/startale.d.ts +3 -3
- package/dist/src/accounts/startale.js +37 -47
- package/dist/src/accounts/utils.d.ts +2 -2
- package/dist/src/accounts/utils.js +22 -28
- package/dist/src/accounts/walletClient.js +4 -8
- package/dist/src/actions/compact.d.ts +1 -1
- package/dist/src/actions/compact.js +22 -35
- package/dist/src/actions/deployment.d.ts +1 -1
- package/dist/src/actions/deployment.js +11 -13
- package/dist/src/actions/ecdsa.d.ts +1 -1
- package/dist/src/actions/ecdsa.js +14 -20
- package/dist/src/actions/index.d.ts +2 -2
- package/dist/src/actions/index.js +6 -10
- package/dist/src/actions/mfa.d.ts +1 -1
- package/dist/src/actions/mfa.js +18 -24
- package/dist/src/actions/passkeys.d.ts +2 -2
- package/dist/src/actions/passkeys.js +14 -20
- package/dist/src/actions/recovery.d.ts +1 -1
- package/dist/src/actions/recovery.js +25 -29
- package/dist/src/actions/smart-sessions.d.ts +1 -1
- package/dist/src/actions/smart-sessions.js +8 -12
- package/dist/src/auth/provider.d.ts +1 -1
- package/dist/src/auth/provider.js +1 -4
- package/dist/src/errors/index.d.ts +3 -3
- package/dist/src/errors/index.js +10 -54
- package/dist/src/execution/compact.d.ts +3 -3
- package/dist/src/execution/compact.js +10 -18
- package/dist/src/execution/error.js +1 -11
- package/dist/src/execution/index.d.ts +8 -8
- package/dist/src/execution/index.js +50 -65
- package/dist/src/execution/permit2.d.ts +5 -5
- package/dist/src/execution/permit2.js +8 -13
- package/dist/src/execution/singleChainOps.d.ts +2 -2
- package/dist/src/execution/singleChainOps.js +1 -3
- package/dist/src/execution/types.d.ts +1 -1
- package/dist/src/execution/types.js +1 -2
- package/dist/src/execution/utils.d.ts +4 -4
- package/dist/src/execution/utils.js +133 -156
- package/dist/src/index.d.ts +9 -9
- package/dist/src/index.js +55 -66
- package/dist/src/jwt-server/digest.js +3 -6
- package/dist/src/jwt-server/express.d.ts +1 -1
- package/dist/src/jwt-server/express.d.ts.map +1 -1
- package/dist/src/jwt-server/express.js +6 -7
- package/dist/src/jwt-server/handlers.d.ts +1 -1
- package/dist/src/jwt-server/handlers.js +7 -11
- package/dist/src/jwt-server/index.d.ts +7 -7
- package/dist/src/jwt-server/index.js +6 -17
- package/dist/src/jwt-server/jcs.js +1 -4
- package/dist/src/jwt-server/signer.d.ts +1 -1
- package/dist/src/jwt-server/signer.js +10 -13
- package/dist/src/jwt-server/sponsorship.js +2 -7
- package/dist/src/jwt-server/web.d.ts +1 -1
- package/dist/src/jwt-server/web.js +5 -9
- package/dist/src/modules/abi/smart-session-emissary.js +1 -3
- package/dist/src/modules/abi/smart-sessions.js +1 -4
- package/dist/src/modules/chain-abstraction.js +1 -5
- package/dist/src/modules/common.d.ts +1 -1
- package/dist/src/modules/common.js +1 -13
- package/dist/src/modules/index.d.ts +5 -5
- package/dist/src/modules/index.js +35 -50
- package/dist/src/modules/legacy.d.ts +2 -2
- package/dist/src/modules/legacy.js +11 -14
- package/dist/src/modules/read.d.ts +1 -1
- package/dist/src/modules/read.js +11 -15
- package/dist/src/modules/validators/core.d.ts +2 -2
- package/dist/src/modules/validators/core.js +26 -44
- package/dist/src/modules/validators/index.d.ts +2 -2
- package/dist/src/modules/validators/index.js +3 -19
- package/dist/src/modules/validators/policies/claim/permit2.d.ts +1 -1
- package/dist/src/modules/validators/policies/claim/permit2.js +39 -44
- package/dist/src/modules/validators/policies/claim/types.js +11 -14
- package/dist/src/modules/validators/smart-sessions.d.ts +3 -3
- package/dist/src/modules/validators/smart-sessions.js +65 -94
- package/dist/src/orchestrator/client.d.ts +2 -2
- package/dist/src/orchestrator/client.js +46 -50
- package/dist/src/orchestrator/consts.d.ts +1 -1
- package/dist/src/orchestrator/consts.d.ts.map +1 -1
- package/dist/src/orchestrator/consts.js +2 -8
- package/dist/src/orchestrator/error.js +1 -33
- package/dist/src/orchestrator/index.d.ts +7 -7
- package/dist/src/orchestrator/index.js +7 -56
- package/dist/src/orchestrator/registry.d.ts +2 -2
- package/dist/src/orchestrator/registry.js +19 -33
- package/dist/src/orchestrator/types.js +1 -17
- package/dist/src/orchestrator/utils.js +1 -3
- package/dist/src/types.d.ts +3 -3
- package/dist/src/types.js +1 -2
- package/dist/src/utils/index.d.ts +2 -2
- package/dist/src/utils/index.js +9 -15
- package/package.json +15 -98
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SignerNotSupportedError = exports.IntentStatusTimeoutError = exports.IntentFailedError = exports.SessionChainRequiredError = exports.OrderPathRequiredForIntentsError = exports.Eip7702InitSignatureRequiredError = exports.ExecutionError = void 0;
|
|
4
|
-
exports.isExecutionError = isExecutionError;
|
|
5
1
|
class ExecutionError extends Error {
|
|
6
2
|
_message;
|
|
7
3
|
_context;
|
|
@@ -27,7 +23,6 @@ class ExecutionError extends Error {
|
|
|
27
23
|
return this._traceId;
|
|
28
24
|
}
|
|
29
25
|
}
|
|
30
|
-
exports.ExecutionError = ExecutionError;
|
|
31
26
|
class SignerNotSupportedError extends ExecutionError {
|
|
32
27
|
constructor(params) {
|
|
33
28
|
super({
|
|
@@ -36,7 +31,6 @@ class SignerNotSupportedError extends ExecutionError {
|
|
|
36
31
|
});
|
|
37
32
|
}
|
|
38
33
|
}
|
|
39
|
-
exports.SignerNotSupportedError = SignerNotSupportedError;
|
|
40
34
|
class OrderPathRequiredForIntentsError extends ExecutionError {
|
|
41
35
|
constructor(params) {
|
|
42
36
|
super({
|
|
@@ -45,7 +39,6 @@ class OrderPathRequiredForIntentsError extends ExecutionError {
|
|
|
45
39
|
});
|
|
46
40
|
}
|
|
47
41
|
}
|
|
48
|
-
exports.OrderPathRequiredForIntentsError = OrderPathRequiredForIntentsError;
|
|
49
42
|
class SessionChainRequiredError extends ExecutionError {
|
|
50
43
|
constructor(params) {
|
|
51
44
|
super({
|
|
@@ -54,7 +47,6 @@ class SessionChainRequiredError extends ExecutionError {
|
|
|
54
47
|
});
|
|
55
48
|
}
|
|
56
49
|
}
|
|
57
|
-
exports.SessionChainRequiredError = SessionChainRequiredError;
|
|
58
50
|
class IntentFailedError extends ExecutionError {
|
|
59
51
|
constructor(params) {
|
|
60
52
|
super({
|
|
@@ -63,7 +55,6 @@ class IntentFailedError extends ExecutionError {
|
|
|
63
55
|
});
|
|
64
56
|
}
|
|
65
57
|
}
|
|
66
|
-
exports.IntentFailedError = IntentFailedError;
|
|
67
58
|
class IntentStatusTimeoutError extends ExecutionError {
|
|
68
59
|
constructor(params) {
|
|
69
60
|
super({
|
|
@@ -72,7 +63,6 @@ class IntentStatusTimeoutError extends ExecutionError {
|
|
|
72
63
|
});
|
|
73
64
|
}
|
|
74
65
|
}
|
|
75
|
-
exports.IntentStatusTimeoutError = IntentStatusTimeoutError;
|
|
76
66
|
class Eip7702InitSignatureRequiredError extends ExecutionError {
|
|
77
67
|
constructor(params) {
|
|
78
68
|
super({
|
|
@@ -81,7 +71,7 @@ class Eip7702InitSignatureRequiredError extends ExecutionError {
|
|
|
81
71
|
});
|
|
82
72
|
}
|
|
83
73
|
}
|
|
84
|
-
exports.Eip7702InitSignatureRequiredError = Eip7702InitSignatureRequiredError;
|
|
85
74
|
function isExecutionError(error) {
|
|
86
75
|
return error instanceof ExecutionError;
|
|
87
76
|
}
|
|
77
|
+
export { isExecutionError, ExecutionError, Eip7702InitSignatureRequiredError, OrderPathRequiredForIntentsError, SessionChainRequiredError, IntentFailedError, IntentStatusTimeoutError, SignerNotSupportedError, };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { type Address, type Chain, type Hex } from 'viem';
|
|
2
2
|
import type { UserOperationReceipt } from 'viem/_types/account-abstraction';
|
|
3
|
-
import { type AuthProvider } from '../auth/provider';
|
|
4
|
-
import { type IntentOpStatus, type SplitIntentsInput } from '../orchestrator';
|
|
5
|
-
import type { SettlementLayer } from '../orchestrator/types';
|
|
6
|
-
import type { CalldataInput, CallInput, RhinestoneAccountConfig, RhinestoneConfig, SignerSet, SourceAssetInput, Sponsorship, TokenRequest, TokenSymbol, Transaction, UserOperationTransaction } from '../types';
|
|
7
|
-
import { ExecutionError, IntentFailedError, IntentStatusTimeoutError, isExecutionError, OrderPathRequiredForIntentsError, SessionChainRequiredError, SignerNotSupportedError } from './error';
|
|
8
|
-
import type { TransactionResult, UserOperationResult } from './utils';
|
|
3
|
+
import { type AuthProvider } from '../auth/provider.js';
|
|
4
|
+
import { type IntentOpStatus, type SplitIntentsInput } from '../orchestrator/index.js';
|
|
5
|
+
import type { SettlementLayer } from '../orchestrator/types.js';
|
|
6
|
+
import type { CalldataInput, CallInput, RhinestoneAccountConfig, RhinestoneConfig, SignerSet, SourceAssetInput, Sponsorship, TokenRequest, TokenSymbol, Transaction, UserOperationTransaction } from '../types.js';
|
|
7
|
+
import { ExecutionError, IntentFailedError, IntentStatusTimeoutError, isExecutionError, OrderPathRequiredForIntentsError, SessionChainRequiredError, SignerNotSupportedError } from './error.js';
|
|
8
|
+
import type { TransactionResult, UserOperationResult } from './utils.js';
|
|
9
9
|
interface TransactionStatus {
|
|
10
10
|
fill: {
|
|
11
11
|
hash: Hex | undefined;
|
|
@@ -33,11 +33,11 @@ declare function sendTransactionInternal(config: RhinestoneConfig, sourceChains:
|
|
|
33
33
|
}): Promise<TransactionResult>;
|
|
34
34
|
declare function sendUserOperationInternal(config: RhinestoneConfig, chain: Chain, callInputs: CalldataInput[], signers?: SignerSet): Promise<UserOperationResult>;
|
|
35
35
|
declare function waitForExecution(config: RhinestoneConfig, result: TransactionResult | UserOperationResult, acceptsPreconfirmations: boolean): Promise<TransactionStatus | UserOperationReceipt>;
|
|
36
|
-
declare function getPortfolio(config: RhinestoneConfig, onTestnets: boolean): Promise<import("../orchestrator").Portfolio>;
|
|
36
|
+
declare function getPortfolio(config: RhinestoneConfig, onTestnets: boolean): Promise<import("../orchestrator/index.js").Portfolio>;
|
|
37
37
|
declare function getIntentStatus(authProvider: AuthProvider, endpointUrl: string | undefined, intentId: bigint, headers?: Record<string, string>): Promise<TransactionStatus & {
|
|
38
38
|
status: IntentOpStatus['status'];
|
|
39
39
|
}>;
|
|
40
|
-
declare function splitIntents(authProvider: AuthProvider, endpointUrl: string | undefined, input: SplitIntentsInput, headers?: Record<string, string>): Promise<import("../orchestrator").SplitIntentsResult>;
|
|
40
|
+
declare function splitIntents(authProvider: AuthProvider, endpointUrl: string | undefined, input: SplitIntentsInput, headers?: Record<string, string>): Promise<import("../orchestrator/index.js").SplitIntentsResult>;
|
|
41
41
|
export { sendTransaction, sendTransactionInternal, sendUserOperation, sendUserOperationInternal, waitForExecution, getPortfolio, getIntentStatus, splitIntents, isExecutionError, ExecutionError, IntentFailedError, IntentStatusTimeoutError, OrderPathRequiredForIntentsError, SessionChainRequiredError, SignerNotSupportedError, };
|
|
42
42
|
export type { TransactionStatus, TransactionResult, UserOperationResult };
|
|
43
43
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,29 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
exports.getPortfolio = getPortfolio;
|
|
10
|
-
exports.getIntentStatus = getIntentStatus;
|
|
11
|
-
exports.splitIntents = splitIntents;
|
|
12
|
-
const viem_1 = require("viem");
|
|
13
|
-
const accounts_1 = require("../accounts");
|
|
14
|
-
const utils_1 = require("../accounts/utils");
|
|
15
|
-
const provider_1 = require("../auth/provider");
|
|
16
|
-
const orchestrator_1 = require("../orchestrator");
|
|
17
|
-
const registry_1 = require("../orchestrator/registry");
|
|
18
|
-
const error_1 = require("./error");
|
|
19
|
-
Object.defineProperty(exports, "ExecutionError", { enumerable: true, get: function () { return error_1.ExecutionError; } });
|
|
20
|
-
Object.defineProperty(exports, "IntentFailedError", { enumerable: true, get: function () { return error_1.IntentFailedError; } });
|
|
21
|
-
Object.defineProperty(exports, "IntentStatusTimeoutError", { enumerable: true, get: function () { return error_1.IntentStatusTimeoutError; } });
|
|
22
|
-
Object.defineProperty(exports, "isExecutionError", { enumerable: true, get: function () { return error_1.isExecutionError; } });
|
|
23
|
-
Object.defineProperty(exports, "OrderPathRequiredForIntentsError", { enumerable: true, get: function () { return error_1.OrderPathRequiredForIntentsError; } });
|
|
24
|
-
Object.defineProperty(exports, "SessionChainRequiredError", { enumerable: true, get: function () { return error_1.SessionChainRequiredError; } });
|
|
25
|
-
Object.defineProperty(exports, "SignerNotSupportedError", { enumerable: true, get: function () { return error_1.SignerNotSupportedError; } });
|
|
26
|
-
const utils_2 = require("./utils");
|
|
1
|
+
import { createPublicClient } from 'viem';
|
|
2
|
+
import { deploy, getAddress } from '../accounts/index.js';
|
|
3
|
+
import { createTransport, getBundlerClient } from '../accounts/utils.js';
|
|
4
|
+
import { createAuthProvider } from '../auth/provider.js';
|
|
5
|
+
import { getOrchestrator, INTENT_STATUS_COMPLETED, INTENT_STATUS_FAILED, INTENT_STATUS_FILLED, INTENT_STATUS_PRECONFIRMED, isRateLimited, isRetryable, } from '../orchestrator/index.js';
|
|
6
|
+
import { getChainById, getSupportedChainIds, isTestnet, } from '../orchestrator/registry.js';
|
|
7
|
+
import { ExecutionError, IntentFailedError, IntentStatusTimeoutError, isExecutionError, OrderPathRequiredForIntentsError, SessionChainRequiredError, SignerNotSupportedError, } from './error.js';
|
|
8
|
+
import { getTargetExecutionSignature, getTokenRequests, getValidatorAccount, parseCalls, prepareTransactionAsIntent, resolveCallInputs, signAuthorizationsInternal, signIntent, submitIntentInternal, } from './utils.js';
|
|
27
9
|
const POLL_INITIAL_MS = 500;
|
|
28
10
|
const POLL_SLOW_AFTER_MS = 15000;
|
|
29
11
|
const POLL_SLOW_MS = 2000;
|
|
@@ -36,7 +18,7 @@ async function sendTransaction(config, transaction) {
|
|
|
36
18
|
const { calls, gasLimit, tokenRequests, recipient, signers, sponsored, eip7702InitSignature, settlementLayers, sourceAssets, feeAsset, } = transaction;
|
|
37
19
|
const isUserOpSigner = signers?.type === 'guardians';
|
|
38
20
|
if (isUserOpSigner) {
|
|
39
|
-
throw new
|
|
21
|
+
throw new SignerNotSupportedError();
|
|
40
22
|
}
|
|
41
23
|
return await sendTransactionInternal(config, sourceChains, targetChain, {
|
|
42
24
|
callInputs: calls,
|
|
@@ -52,17 +34,17 @@ async function sendTransaction(config, transaction) {
|
|
|
52
34
|
});
|
|
53
35
|
}
|
|
54
36
|
async function sendUserOperation(config, transaction) {
|
|
55
|
-
const accountAddress =
|
|
56
|
-
const resolvedCalls = await
|
|
37
|
+
const accountAddress = getAddress(config);
|
|
38
|
+
const resolvedCalls = await resolveCallInputs(transaction.calls, config, transaction.chain, accountAddress);
|
|
57
39
|
return await sendUserOperationInternal(config, transaction.chain, resolvedCalls, transaction.signers);
|
|
58
40
|
}
|
|
59
41
|
async function sendTransactionInternal(config, sourceChains, targetChain, options) {
|
|
60
|
-
const accountAddress =
|
|
61
|
-
const resolvedCalls = await
|
|
62
|
-
const tokenRequests =
|
|
42
|
+
const accountAddress = getAddress(config);
|
|
43
|
+
const resolvedCalls = await resolveCallInputs(options.callInputs, config, targetChain, accountAddress);
|
|
44
|
+
const tokenRequests = getTokenRequests(targetChain, options.initialTokenRequests);
|
|
63
45
|
const sendAsUserOp = options.signers?.type === 'guardians';
|
|
64
46
|
if (sendAsUserOp) {
|
|
65
|
-
throw new
|
|
47
|
+
throw new SignerNotSupportedError();
|
|
66
48
|
}
|
|
67
49
|
else {
|
|
68
50
|
return await sendTransactionAsIntent(config, sourceChains, targetChain, resolvedCalls, options.gasLimit, tokenRequests, options.recipient, options.signers, options.sponsored, options.eip7702InitSignature, options.settlementLayers, options.sourceAssets, options.feeAsset, options.lockFunds);
|
|
@@ -70,17 +52,17 @@ async function sendTransactionInternal(config, sourceChains, targetChain, option
|
|
|
70
52
|
}
|
|
71
53
|
async function sendUserOperationInternal(config, chain, callInputs, signers) {
|
|
72
54
|
// Make sure the account is deployed
|
|
73
|
-
await
|
|
74
|
-
const publicClient =
|
|
55
|
+
await deploy(config, chain);
|
|
56
|
+
const publicClient = createPublicClient({
|
|
75
57
|
chain,
|
|
76
|
-
transport:
|
|
58
|
+
transport: createTransport(chain, config.provider),
|
|
77
59
|
});
|
|
78
|
-
const validatorAccount = await
|
|
60
|
+
const validatorAccount = await getValidatorAccount(config, signers, publicClient, chain);
|
|
79
61
|
if (!validatorAccount) {
|
|
80
62
|
throw new Error('No validator account found');
|
|
81
63
|
}
|
|
82
|
-
const bundlerClient =
|
|
83
|
-
const calls =
|
|
64
|
+
const bundlerClient = getBundlerClient(config, publicClient);
|
|
65
|
+
const calls = parseCalls(callInputs, chain.id);
|
|
84
66
|
const hash = await bundlerClient.sendUserOperation({
|
|
85
67
|
account: validatorAccount,
|
|
86
68
|
calls,
|
|
@@ -92,26 +74,26 @@ async function sendUserOperationInternal(config, chain, callInputs, signers) {
|
|
|
92
74
|
};
|
|
93
75
|
}
|
|
94
76
|
async function sendTransactionAsIntent(config, sourceChains, targetChain, callInputs, gasLimit, tokenRequests, recipient, signers, sponsored, eip7702InitSignature, settlementLayers, sourceAssets, feeAsset, lockFunds) {
|
|
95
|
-
const prepared = await
|
|
77
|
+
const prepared = await prepareTransactionAsIntent(config, sourceChains, targetChain, callInputs, gasLimit, tokenRequests, recipient, sponsored ?? false, eip7702InitSignature, settlementLayers, sourceAssets, feeAsset, lockFunds, undefined, undefined, signers);
|
|
96
78
|
if (!prepared) {
|
|
97
|
-
throw new
|
|
79
|
+
throw new OrderPathRequiredForIntentsError();
|
|
98
80
|
}
|
|
99
81
|
const { intentRoute, intentInput } = prepared;
|
|
100
|
-
const { originSignatures, destinationSignature } = await
|
|
101
|
-
const targetExecutionSignature = await
|
|
82
|
+
const { originSignatures, destinationSignature } = await signIntent(config, intentRoute.intentOp, targetChain, signers);
|
|
83
|
+
const targetExecutionSignature = await getTargetExecutionSignature(config, intentRoute.intentOp, targetChain, signers);
|
|
102
84
|
const authorizations = config.eoa
|
|
103
|
-
? await
|
|
85
|
+
? await signAuthorizationsInternal(config, intentRoute)
|
|
104
86
|
: [];
|
|
105
|
-
return await
|
|
87
|
+
return await submitIntentInternal(config, sourceChains, targetChain, intentRoute.intentOp, originSignatures, destinationSignature, targetExecutionSignature, authorizations, false, intentInput);
|
|
106
88
|
}
|
|
107
89
|
async function waitForExecution(config, result, acceptsPreconfirmations) {
|
|
108
90
|
const validStatuses = new Set([
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
91
|
+
INTENT_STATUS_FAILED,
|
|
92
|
+
INTENT_STATUS_COMPLETED,
|
|
93
|
+
INTENT_STATUS_FILLED,
|
|
112
94
|
]);
|
|
113
95
|
if (acceptsPreconfirmations) {
|
|
114
|
-
validStatuses.add(
|
|
96
|
+
validStatuses.add(INTENT_STATUS_PRECONFIRMED);
|
|
115
97
|
}
|
|
116
98
|
switch (result.type) {
|
|
117
99
|
case 'intent': {
|
|
@@ -122,13 +104,13 @@ async function waitForExecution(config, result, acceptsPreconfirmations) {
|
|
|
122
104
|
while (intentStatus === null || !validStatuses.has(intentStatus.status)) {
|
|
123
105
|
const now = Date.now();
|
|
124
106
|
if (now - startTs >= POLL_MAX_WAIT_MS) {
|
|
125
|
-
throw new
|
|
107
|
+
throw new IntentStatusTimeoutError({
|
|
126
108
|
context: {
|
|
127
109
|
intentId: result.id.toString(),
|
|
128
110
|
},
|
|
129
111
|
});
|
|
130
112
|
}
|
|
131
|
-
const orchestrator =
|
|
113
|
+
const orchestrator = getOrchestrator(config._authProvider ?? createAuthProvider(config), config.endpointUrl, config.headers);
|
|
132
114
|
try {
|
|
133
115
|
intentStatus = await orchestrator.getIntentOpStatus(result.id);
|
|
134
116
|
// reset error backoff on success
|
|
@@ -139,7 +121,7 @@ async function waitForExecution(config, result, acceptsPreconfirmations) {
|
|
|
139
121
|
await new Promise((resolve) => setTimeout(resolve, nextDelayMs));
|
|
140
122
|
}
|
|
141
123
|
catch (err) {
|
|
142
|
-
if (
|
|
124
|
+
if (isRateLimited(err)) {
|
|
143
125
|
const retryAfter = err?.context?.retryAfter;
|
|
144
126
|
let retryMs = nextDelayMs;
|
|
145
127
|
if (retryAfter) {
|
|
@@ -160,7 +142,7 @@ async function waitForExecution(config, result, acceptsPreconfirmations) {
|
|
|
160
142
|
await new Promise((resolve) => setTimeout(resolve, retryMs));
|
|
161
143
|
continue;
|
|
162
144
|
}
|
|
163
|
-
if (
|
|
145
|
+
if (isRetryable(err)) {
|
|
164
146
|
const backoff = Math.min(errorBackoffMs, POLL_ERROR_BACKOFF_MAX_MS);
|
|
165
147
|
errorBackoffMs = Math.min(errorBackoffMs * 2, POLL_ERROR_BACKOFF_MAX_MS);
|
|
166
148
|
await new Promise((resolve) => setTimeout(resolve, backoff));
|
|
@@ -169,9 +151,9 @@ async function waitForExecution(config, result, acceptsPreconfirmations) {
|
|
|
169
151
|
throw err;
|
|
170
152
|
}
|
|
171
153
|
}
|
|
172
|
-
if (intentStatus.status ===
|
|
154
|
+
if (intentStatus.status === INTENT_STATUS_FAILED) {
|
|
173
155
|
const intentId = result.id.toString();
|
|
174
|
-
throw new
|
|
156
|
+
throw new IntentFailedError({
|
|
175
157
|
context: {
|
|
176
158
|
intentId,
|
|
177
159
|
},
|
|
@@ -189,12 +171,12 @@ async function waitForExecution(config, result, acceptsPreconfirmations) {
|
|
|
189
171
|
};
|
|
190
172
|
}
|
|
191
173
|
case 'userop': {
|
|
192
|
-
const targetChain =
|
|
193
|
-
const publicClient =
|
|
174
|
+
const targetChain = getChainById(result.chain);
|
|
175
|
+
const publicClient = createPublicClient({
|
|
194
176
|
chain: targetChain,
|
|
195
|
-
transport:
|
|
177
|
+
transport: createTransport(targetChain, config.provider),
|
|
196
178
|
});
|
|
197
|
-
const bundlerClient =
|
|
179
|
+
const bundlerClient = getBundlerClient(config, publicClient);
|
|
198
180
|
const receipt = await bundlerClient.waitForUserOperationReceipt({
|
|
199
181
|
hash: result.hash,
|
|
200
182
|
});
|
|
@@ -203,12 +185,12 @@ async function waitForExecution(config, result, acceptsPreconfirmations) {
|
|
|
203
185
|
}
|
|
204
186
|
}
|
|
205
187
|
async function getPortfolio(config, onTestnets) {
|
|
206
|
-
const address =
|
|
207
|
-
const orchestrator =
|
|
208
|
-
const supportedChainIds =
|
|
188
|
+
const address = getAddress(config);
|
|
189
|
+
const orchestrator = getOrchestrator(config._authProvider ?? createAuthProvider(config), config.endpointUrl, config.headers);
|
|
190
|
+
const supportedChainIds = getSupportedChainIds();
|
|
209
191
|
const filteredChainIds = supportedChainIds.filter((id) => {
|
|
210
192
|
try {
|
|
211
|
-
return
|
|
193
|
+
return isTestnet(id) === onTestnets;
|
|
212
194
|
}
|
|
213
195
|
catch {
|
|
214
196
|
return false;
|
|
@@ -217,7 +199,7 @@ async function getPortfolio(config, onTestnets) {
|
|
|
217
199
|
return orchestrator.getPortfolio(address, { chainIds: filteredChainIds });
|
|
218
200
|
}
|
|
219
201
|
async function getIntentStatus(authProvider, endpointUrl, intentId, headers) {
|
|
220
|
-
const orchestrator =
|
|
202
|
+
const orchestrator = getOrchestrator(authProvider, endpointUrl, headers);
|
|
221
203
|
const internalStatus = await orchestrator.getIntentOpStatus(intentId);
|
|
222
204
|
return {
|
|
223
205
|
status: internalStatus.status,
|
|
@@ -232,6 +214,9 @@ async function getIntentStatus(authProvider, endpointUrl, intentId, headers) {
|
|
|
232
214
|
};
|
|
233
215
|
}
|
|
234
216
|
async function splitIntents(authProvider, endpointUrl, input, headers) {
|
|
235
|
-
const orchestrator =
|
|
217
|
+
const orchestrator = getOrchestrator(authProvider, endpointUrl, headers);
|
|
236
218
|
return orchestrator.splitIntents(input);
|
|
237
219
|
}
|
|
220
|
+
export { sendTransaction, sendTransactionInternal, sendUserOperation, sendUserOperationInternal, waitForExecution, getPortfolio, getIntentStatus, splitIntents,
|
|
221
|
+
// Errors
|
|
222
|
+
isExecutionError, ExecutionError, IntentFailedError, IntentStatusTimeoutError, OrderPathRequiredForIntentsError, SessionChainRequiredError, SignerNotSupportedError, };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Address, type Chain } from 'viem';
|
|
2
|
-
import type { IntentOpElement } from '../orchestrator/types';
|
|
3
|
-
import type { RhinestoneConfig } from '../types';
|
|
4
|
-
import type { BatchPermit2Result, MultiChainPermit2Config, MultiChainPermit2Result, TokenPermissions } from './types';
|
|
2
|
+
import type { IntentOpElement } from '../orchestrator/types.js';
|
|
3
|
+
import type { RhinestoneConfig } from '../types.js';
|
|
4
|
+
import type { BatchPermit2Result, MultiChainPermit2Config, MultiChainPermit2Result, TokenPermissions } from './types.js';
|
|
5
5
|
declare function getTypedData(element: IntentOpElement, nonce: bigint, expires: bigint): {
|
|
6
6
|
readonly domain: {
|
|
7
7
|
readonly name: "Permit2";
|
|
@@ -103,8 +103,8 @@ declare function getTypedData(element: IntentOpElement, nonce: bigint, expires:
|
|
|
103
103
|
readonly fillExpiry: bigint;
|
|
104
104
|
};
|
|
105
105
|
readonly minGas: bigint;
|
|
106
|
-
readonly originOps: import("../orchestrator/types").Op;
|
|
107
|
-
readonly destOps: import("../orchestrator/types").Op;
|
|
106
|
+
readonly originOps: import("../orchestrator/types.js").Op;
|
|
107
|
+
readonly destOps: import("../orchestrator/types.js").Op;
|
|
108
108
|
readonly q: `0x${string}`;
|
|
109
109
|
};
|
|
110
110
|
};
|
|
@@ -1,13 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.getTypedData = getTypedData;
|
|
4
|
-
exports.checkERC20Allowance = checkERC20Allowance;
|
|
5
|
-
exports.checkERC20AllowanceDirect = checkERC20AllowanceDirect;
|
|
6
|
-
exports.getPermit2Address = getPermit2Address;
|
|
7
|
-
exports.signPermit2Batch = signPermit2Batch;
|
|
8
|
-
exports.signPermit2Sequential = signPermit2Sequential;
|
|
9
|
-
const viem_1 = require("viem");
|
|
10
|
-
const utils_1 = require("../accounts/utils");
|
|
1
|
+
import { createPublicClient, keccak256, } from 'viem';
|
|
2
|
+
import { createTransport } from '../accounts/utils.js';
|
|
11
3
|
const PERMIT2_ADDRESS = '0x000000000022D473030F116dDEE9F6B43aC78BA3';
|
|
12
4
|
function toToken(id) {
|
|
13
5
|
return `0x${(id & ((1n << 160n) - 1n)).toString(16).padStart(40, '0')}`;
|
|
@@ -90,7 +82,7 @@ function getTypedData(element, nonce, expires) {
|
|
|
90
82
|
minGas: BigInt(mandate.minGas),
|
|
91
83
|
originOps: mandate.preClaimOps,
|
|
92
84
|
destOps: mandate.destinationOps,
|
|
93
|
-
q:
|
|
85
|
+
q: keccak256(mandate.qualifier.encodedVal),
|
|
94
86
|
},
|
|
95
87
|
},
|
|
96
88
|
};
|
|
@@ -124,9 +116,9 @@ async function checkERC20AllowanceDirect(owner, spender, tokenAddress, publicCli
|
|
|
124
116
|
}
|
|
125
117
|
async function checkERC20Allowance(tokenAddress, chain, config) {
|
|
126
118
|
try {
|
|
127
|
-
const publicClient =
|
|
119
|
+
const publicClient = createPublicClient({
|
|
128
120
|
chain,
|
|
129
|
-
transport:
|
|
121
|
+
transport: createTransport(chain, config.provider),
|
|
130
122
|
});
|
|
131
123
|
// Get the account owner from the config
|
|
132
124
|
const owner = config.eoa?.address;
|
|
@@ -283,3 +275,6 @@ async function signPermit2Sequential(configs, onProgress) {
|
|
|
283
275
|
allSuccessful: failedSignatures === 0,
|
|
284
276
|
};
|
|
285
277
|
}
|
|
278
|
+
export { getTypedData, checkERC20Allowance, checkERC20AllowanceDirect, getPermit2Address,
|
|
279
|
+
// Multi-chain permit2 signing methods
|
|
280
|
+
signPermit2Batch, signPermit2Sequential, };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Address } from 'viem';
|
|
2
|
-
import type { IntentOpElement } from '../orchestrator/types';
|
|
2
|
+
import type { IntentOpElement } from '../orchestrator/types.js';
|
|
3
3
|
declare function getTypedData(account: Address, intentExecutorAddress: Address, element: IntentOpElement, nonce: bigint): {
|
|
4
4
|
domain: {
|
|
5
5
|
name: string;
|
|
@@ -29,7 +29,7 @@ declare function getTypedData(account: Address, intentExecutorAddress: Address,
|
|
|
29
29
|
message: {
|
|
30
30
|
account: `0x${string}`;
|
|
31
31
|
nonce: bigint;
|
|
32
|
-
op: import("../orchestrator/types").Op;
|
|
32
|
+
op: import("../orchestrator/types.js").Op;
|
|
33
33
|
gasRefund: {
|
|
34
34
|
token: Address;
|
|
35
35
|
exchangeRate: bigint;
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getTypedData = getTypedData;
|
|
4
1
|
function getTypedData(account, intentExecutorAddress, element, nonce) {
|
|
5
2
|
const { destinationChainId, destinationOps } = element.mandate;
|
|
6
3
|
const gasRefund = element.mandate.qualifier.settlementContext.gasRefund;
|
|
@@ -42,3 +39,4 @@ function getTypedData(account, intentExecutorAddress, element, nonce) {
|
|
|
42
39
|
},
|
|
43
40
|
};
|
|
44
41
|
}
|
|
42
|
+
export { getTypedData };
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type Address, type Chain, type HashTypedDataParameters, type Hex, type PublicClient, type SignableMessage, type SignedAuthorization, type SignedAuthorizationList, type TypedData, type TypedDataDefinition, type TypedDataDomain } from 'viem';
|
|
2
2
|
import { type UserOperation } from 'viem/account-abstraction';
|
|
3
|
-
import type { ResolvedSessionSignerSet } from '../modules/validators/smart-sessions';
|
|
4
|
-
import { type IntentOp, type IntentRoute } from '../orchestrator';
|
|
5
|
-
import { type AuxiliaryFunds, type OriginSignature, type SettlementLayer } from '../orchestrator/types';
|
|
6
|
-
import type { Call, CalldataInput, CallInput, RhinestoneAccountConfig, RhinestoneConfig, Session, SessionEnableData, SessionSignerSet, SignerSet, SourceAssetInput, Sponsorship, TokenRequest, TokenSymbol, Transaction, UserOperationTransaction } from '../types';
|
|
3
|
+
import type { ResolvedSessionSignerSet } from '../modules/validators/smart-sessions.js';
|
|
4
|
+
import { type IntentOp, type IntentRoute } from '../orchestrator/index.js';
|
|
5
|
+
import { type AuxiliaryFunds, type OriginSignature, type SettlementLayer } from '../orchestrator/types.js';
|
|
6
|
+
import type { Call, CalldataInput, CallInput, RhinestoneAccountConfig, RhinestoneConfig, Session, SessionEnableData, SessionSignerSet, SignerSet, SourceAssetInput, Sponsorship, TokenRequest, TokenSymbol, Transaction, UserOperationTransaction } from '../types.js';
|
|
7
7
|
type InternalSignerSet = Exclude<SignerSet, SessionSignerSet> | ResolvedSessionSignerSet;
|
|
8
8
|
declare function resolveSessionForChain(signers: SessionSignerSet, chainId: number): {
|
|
9
9
|
session: Session;
|