@charterlabs/rhinestone-sdk 0.2.7-dev.2 → 0.2.7-dev.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/accounts/error.d.ts +38 -3
- package/dist/src/accounts/error.d.ts.map +1 -1
- package/dist/src/accounts/error.js +55 -7
- package/dist/src/accounts/index.d.ts +28 -20
- package/dist/src/accounts/index.d.ts.map +1 -1
- package/dist/src/accounts/index.js +196 -21
- package/dist/src/accounts/index.test.js +2 -4
- package/dist/src/accounts/json-rpc/providers.d.ts.map +1 -1
- package/dist/src/accounts/json-rpc/providers.js +42 -4
- package/dist/src/accounts/kernel.d.ts +1 -1
- package/dist/src/accounts/kernel.d.ts.map +1 -1
- package/dist/src/accounts/kernel.js +29 -1
- package/dist/src/accounts/kernel.test.js +35 -8
- package/dist/src/accounts/nexus.d.ts +4 -3
- package/dist/src/accounts/nexus.d.ts.map +1 -1
- package/dist/src/accounts/nexus.js +82 -14
- package/dist/src/accounts/nexus.test.js +33 -6
- package/dist/src/accounts/safe.d.ts.map +1 -1
- package/dist/src/accounts/safe.js +85 -53
- package/dist/src/accounts/safe.test.js +33 -6
- package/dist/src/accounts/signing/common.d.ts +4 -4
- package/dist/src/accounts/signing/common.d.ts.map +1 -1
- package/dist/src/accounts/signing/common.js +21 -9
- package/dist/src/accounts/signing/message.d.ts +1 -1
- package/dist/src/accounts/signing/message.d.ts.map +1 -1
- package/dist/src/accounts/signing/message.js +6 -6
- package/dist/src/accounts/signing/passkeys.d.ts +8 -1
- package/dist/src/accounts/signing/passkeys.d.ts.map +1 -1
- package/dist/src/accounts/signing/passkeys.js +35 -0
- package/dist/src/accounts/signing/passkeys.test.js +15 -0
- package/dist/src/accounts/signing/typedData.d.ts.map +1 -1
- package/dist/src/accounts/signing/typedData.js +2 -2
- package/dist/src/accounts/startale.test.js +0 -4
- package/dist/src/accounts/utils.d.ts +2 -2
- package/dist/src/accounts/utils.d.ts.map +1 -1
- package/dist/src/accounts/walletClient.d.ts +7 -0
- package/dist/src/accounts/walletClient.d.ts.map +1 -0
- package/dist/src/accounts/walletClient.js +38 -0
- package/dist/src/actions/compact.d.ts +13 -0
- package/dist/src/actions/compact.d.ts.map +1 -0
- package/dist/src/actions/compact.js +210 -0
- package/dist/src/actions/ecdsa.d.ts +35 -0
- package/dist/src/actions/ecdsa.d.ts.map +1 -0
- package/dist/src/actions/ecdsa.js +114 -0
- package/dist/src/actions/ecdsa.test.d.ts +2 -0
- package/dist/src/actions/ecdsa.test.d.ts.map +1 -0
- package/dist/src/actions/ecdsa.test.js +99 -0
- package/dist/src/actions/index.d.ts +23 -166
- package/dist/src/actions/index.d.ts.map +1 -1
- package/dist/src/actions/index.js +25 -544
- package/dist/src/actions/mfa.d.ts +37 -0
- package/dist/src/actions/mfa.d.ts.map +1 -0
- package/dist/src/actions/mfa.js +133 -0
- package/dist/src/actions/passkeys.d.ts +37 -0
- package/dist/src/actions/passkeys.d.ts.map +1 -0
- package/dist/src/actions/passkeys.js +129 -0
- package/dist/src/actions/passkeys.test.d.ts +2 -0
- package/dist/src/actions/passkeys.test.d.ts.map +1 -0
- package/dist/src/actions/passkeys.test.js +54 -0
- package/dist/src/actions/recovery.d.ts +33 -0
- package/dist/src/actions/recovery.d.ts.map +1 -0
- package/dist/src/actions/recovery.js +193 -0
- package/dist/src/actions/recovery.test.d.ts +2 -0
- package/dist/src/actions/recovery.test.d.ts.map +1 -0
- package/dist/src/actions/recovery.test.js +168 -0
- package/dist/src/errors/index.d.ts +5 -0
- package/dist/src/errors/index.d.ts.map +1 -0
- package/dist/src/errors/index.js +35 -0
- package/dist/src/execution/compact.d.ts +24 -8
- package/dist/src/execution/compact.d.ts.map +1 -1
- package/dist/src/execution/compact.js +29 -103
- package/dist/src/execution/error.d.ts +2 -9
- package/dist/src/execution/error.d.ts.map +1 -1
- package/dist/src/execution/error.js +4 -13
- package/dist/src/execution/index.d.ts +33 -22
- package/dist/src/execution/index.d.ts.map +1 -1
- package/dist/src/execution/index.js +60 -41
- package/dist/src/execution/permit2.d.ts +148 -0
- package/dist/src/execution/permit2.d.ts.map +1 -0
- package/dist/src/execution/permit2.js +282 -0
- package/dist/src/execution/smart-session.d.ts +3 -3
- package/dist/src/execution/smart-session.d.ts.map +1 -1
- package/dist/src/execution/types.d.ts +35 -0
- package/dist/src/execution/types.d.ts.map +1 -0
- package/dist/src/execution/types.js +2 -0
- package/dist/src/execution/utils.d.ts +36 -28
- package/dist/src/execution/utils.d.ts.map +1 -1
- package/dist/src/execution/utils.js +248 -91
- package/dist/src/index.d.ts +37 -19
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +130 -66
- package/dist/src/modules/common.d.ts +10 -4
- package/dist/src/modules/common.d.ts.map +1 -1
- package/dist/src/modules/common.js +22 -1
- package/dist/src/modules/index.d.ts +3 -2
- package/dist/src/modules/index.d.ts.map +1 -1
- package/dist/src/modules/index.js +16 -13
- package/dist/src/modules/index.test.js +8 -11
- package/dist/src/modules/read.d.ts.map +1 -1
- package/dist/src/modules/read.js +4 -0
- package/dist/src/modules/validators/core.d.ts +5 -3
- package/dist/src/modules/validators/core.d.ts.map +1 -1
- package/dist/src/modules/validators/core.js +29 -10
- package/dist/src/modules/validators/core.test.js +4 -4
- package/dist/src/modules/validators/smart-sessions.test.js +0 -3
- package/dist/src/modules/validators/webauthn-contract.d.ts.map +1 -1
- package/dist/src/orchestrator/client.d.ts +2 -1
- package/dist/src/orchestrator/client.d.ts.map +1 -1
- package/dist/src/orchestrator/client.js +36 -14
- package/dist/src/orchestrator/consts.d.ts +1 -2
- package/dist/src/orchestrator/consts.d.ts.map +1 -1
- package/dist/src/orchestrator/consts.js +1 -3
- package/dist/src/orchestrator/registry.d.ts +2 -2
- package/dist/src/orchestrator/registry.d.ts.map +1 -1
- package/dist/src/orchestrator/registry.js +68 -30
- package/dist/src/orchestrator/registry.test.js +4 -4
- package/dist/src/orchestrator/types.d.ts +34 -25
- package/dist/src/orchestrator/types.d.ts.map +1 -1
- package/dist/src/types.d.ts +64 -9
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +73 -2
- package/dist/src/accounts/json-rpc/index.test.d.ts +0 -2
- package/dist/src/accounts/json-rpc/index.test.d.ts.map +0 -1
- package/dist/src/accounts/json-rpc/index.test.js +0 -16
- package/dist/src/accounts/json-rpc/providers.test.d.ts +0 -2
- package/dist/src/accounts/json-rpc/providers.test.d.ts.map +0 -1
- package/dist/src/accounts/json-rpc/providers.test.js +0 -15
- 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,46 +1,54 @@
|
|
|
1
1
|
import { type Address, type Chain, type HashTypedDataParameters, type Hex, type PublicClient, type SignableMessage, type SignedAuthorization, type SignedAuthorizationList, type TypedData } from 'viem';
|
|
2
2
|
import { type UserOperation } from 'viem/account-abstraction';
|
|
3
3
|
import { type IntentOp, type IntentRoute } from '../orchestrator';
|
|
4
|
-
import type {
|
|
5
|
-
type
|
|
4
|
+
import type { SettlementLayer } from '../orchestrator/types';
|
|
5
|
+
import type { Call, CalldataInput, CallInput, RhinestoneConfig, SignerSet, SourceAssetInput, TokenRequest, TokenSymbol, Transaction, UserOperationTransaction } from '../types';
|
|
6
|
+
interface UserOperationResult {
|
|
6
7
|
type: 'userop';
|
|
7
8
|
hash: Hex;
|
|
8
9
|
chain: number;
|
|
9
|
-
}
|
|
10
|
+
}
|
|
11
|
+
interface TransactionResult {
|
|
10
12
|
type: 'intent';
|
|
11
13
|
id: bigint;
|
|
12
14
|
sourceChains?: number[];
|
|
13
15
|
targetChain: number;
|
|
14
|
-
};
|
|
15
|
-
interface IntentData {
|
|
16
|
-
type: 'intent';
|
|
17
|
-
intentRoute: IntentRoute;
|
|
18
|
-
}
|
|
19
|
-
interface UserOpData {
|
|
20
|
-
type: 'userop';
|
|
21
|
-
hash: Hex;
|
|
22
|
-
userOp: UserOperation;
|
|
23
16
|
}
|
|
24
17
|
interface PreparedTransactionData {
|
|
25
|
-
|
|
18
|
+
intentRoute: IntentRoute;
|
|
26
19
|
transaction: Transaction;
|
|
27
20
|
}
|
|
21
|
+
interface PreparedUserOperationData {
|
|
22
|
+
userOperation: UserOperation;
|
|
23
|
+
hash: Hex;
|
|
24
|
+
transaction: UserOperationTransaction;
|
|
25
|
+
}
|
|
28
26
|
interface SignedTransactionData extends PreparedTransactionData {
|
|
29
27
|
signature: Hex;
|
|
30
28
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
declare function
|
|
35
|
-
declare function
|
|
36
|
-
declare function
|
|
37
|
-
declare function
|
|
38
|
-
declare function
|
|
39
|
-
declare function
|
|
40
|
-
declare function
|
|
41
|
-
declare function
|
|
42
|
-
declare function
|
|
43
|
-
declare function
|
|
44
|
-
|
|
45
|
-
|
|
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>;
|
|
44
|
+
declare function getTokenRequests(sourceChains: Chain[], targetChain: Chain, initialTokenRequests: TokenRequest[] | undefined, settlementLayers: SettlementLayer[] | undefined): TokenRequest[];
|
|
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}`>;
|
|
47
|
+
declare function getOrchestratorByChain(chainId: number, apiKey: string | undefined, orchestratorUrl?: string): import("../orchestrator").Orchestrator;
|
|
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 | undefined>;
|
|
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, };
|
|
46
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,
|
|
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;AA4BjC,OAAO,EAGL,KAAK,QAAQ,EACb,KAAK,WAAW,EAEjB,MAAM,iBAAiB,CA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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,yKA6Bb;AAmDD,iBAAS,UAAU,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,EAAE,CAMnE;AAuGD,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"}
|
|
@@ -7,12 +7,19 @@ exports.signAuthorizationsInternal = signAuthorizationsInternal;
|
|
|
7
7
|
exports.signMessage = signMessage;
|
|
8
8
|
exports.signTypedData = signTypedData;
|
|
9
9
|
exports.submitTransaction = submitTransaction;
|
|
10
|
+
exports.simulateTransaction = simulateTransaction;
|
|
11
|
+
exports.prepareUserOperation = prepareUserOperation;
|
|
12
|
+
exports.signUserOperation = signUserOperation;
|
|
13
|
+
exports.submitUserOperation = submitUserOperation;
|
|
10
14
|
exports.getOrchestratorByChain = getOrchestratorByChain;
|
|
11
15
|
exports.signIntent = signIntent;
|
|
12
16
|
exports.prepareTransactionAsIntent = prepareTransactionAsIntent;
|
|
13
17
|
exports.submitIntentInternal = submitIntentInternal;
|
|
18
|
+
exports.simulateIntentInternal = simulateIntentInternal;
|
|
14
19
|
exports.getValidatorAccount = getValidatorAccount;
|
|
15
20
|
exports.parseCalls = parseCalls;
|
|
21
|
+
exports.getTokenRequests = getTokenRequests;
|
|
22
|
+
exports.resolveCallInputs = resolveCallInputs;
|
|
16
23
|
const viem_1 = require("viem");
|
|
17
24
|
const account_abstraction_1 = require("viem/account-abstraction");
|
|
18
25
|
const accounts_1 = require("../accounts");
|
|
@@ -24,51 +31,74 @@ const consts_1 = require("../orchestrator/consts");
|
|
|
24
31
|
const registry_1 = require("../orchestrator/registry");
|
|
25
32
|
const compact_1 = require("./compact");
|
|
26
33
|
const error_1 = require("./error");
|
|
34
|
+
const permit2_1 = require("./permit2");
|
|
27
35
|
async function prepareTransaction(config, transaction) {
|
|
28
|
-
const { sourceChains, targetChain, tokenRequests, signers, sponsored, eip7702InitSignature, } = getTransactionParams(transaction);
|
|
36
|
+
const { sourceChains, targetChain, tokenRequests, signers, sponsored, eip7702InitSignature, settlementLayers, sourceAssets, feeAsset, lockFunds, } = getTransactionParams(transaction);
|
|
29
37
|
const accountAddress = (0, accounts_1.getAddress)(config);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if (sourceChains && sourceChains.length > 0) {
|
|
34
|
-
throw new error_1.SourceChainsNotAvailableForUserOpFlowError();
|
|
35
|
-
}
|
|
36
|
-
// Smart sessions require a UserOp flow
|
|
37
|
-
data = await prepareTransactionAsUserOp(config, targetChain, transaction.calls, signers);
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
data = await prepareTransactionAsIntent(config, sourceChains, targetChain, transaction.calls, transaction.gasLimit, tokenRequests, accountAddress, sponsored ?? false, eip7702InitSignature);
|
|
38
|
+
const isUserOpSigner = signers?.type === 'guardians' || signers?.type === 'session';
|
|
39
|
+
if (isUserOpSigner) {
|
|
40
|
+
throw new error_1.SignerNotSupportedError();
|
|
41
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);
|
|
42
43
|
return {
|
|
43
|
-
|
|
44
|
+
intentRoute,
|
|
44
45
|
transaction,
|
|
45
46
|
};
|
|
46
47
|
}
|
|
47
|
-
async function
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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);
|
|
57
73
|
}
|
|
58
|
-
// Smart sessions require a UserOp flow
|
|
59
|
-
signature = await signUserOp(config, chain, signers, userOp);
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
signature = await signIntent(config, targetChain, data.intentRoute.intentOp, signers);
|
|
63
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);
|
|
64
81
|
return {
|
|
65
|
-
|
|
82
|
+
intentRoute,
|
|
66
83
|
transaction: preparedTransaction.transaction,
|
|
67
84
|
signature,
|
|
68
85
|
};
|
|
69
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
|
+
}
|
|
70
100
|
async function signAuthorizations(config, preparedTransaction) {
|
|
71
|
-
return await signAuthorizationsInternal(config, preparedTransaction.
|
|
101
|
+
return await signAuthorizationsInternal(config, preparedTransaction.intentRoute);
|
|
72
102
|
}
|
|
73
103
|
async function signMessage(config, message, chain, signers) {
|
|
74
104
|
const validator = getValidator(config, signers);
|
|
@@ -103,14 +133,16 @@ async function signAuthorizationsInternal(config, data) {
|
|
|
103
133
|
throw new Error('EIP-7702 initialization is required for EOA accounts');
|
|
104
134
|
}
|
|
105
135
|
const accountAddress = (0, accounts_1.getAddress)(config);
|
|
106
|
-
const requiredDelegations =
|
|
107
|
-
? data.
|
|
108
|
-
{}
|
|
136
|
+
const requiredDelegations = 'intentOp' in data
|
|
137
|
+
? data.intentOp.signedMetadata.account.requiredDelegations || {}
|
|
109
138
|
: {};
|
|
110
139
|
const authorizations = [];
|
|
111
140
|
for (const chainId in requiredDelegations) {
|
|
112
141
|
const delegation = requiredDelegations[chainId];
|
|
113
142
|
const chain = (0, registry_1.getChainById)(Number(chainId));
|
|
143
|
+
if (!chain) {
|
|
144
|
+
throw new Error(`Chain not supported: ${chainId}`);
|
|
145
|
+
}
|
|
114
146
|
const walletClient = (0, viem_1.createWalletClient)({
|
|
115
147
|
chain,
|
|
116
148
|
account: eoa,
|
|
@@ -132,25 +164,26 @@ async function signAuthorizationsInternal(config, data) {
|
|
|
132
164
|
return authorizations;
|
|
133
165
|
}
|
|
134
166
|
async function submitTransaction(config, signedTransaction, authorizations) {
|
|
135
|
-
const {
|
|
167
|
+
const { intentRoute, transaction, signature } = signedTransaction;
|
|
136
168
|
const { sourceChains, targetChain } = getTransactionParams(transaction);
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
169
|
+
const intentOp = intentRoute.intentOp;
|
|
170
|
+
return await submitIntent(config, sourceChains, targetChain, intentOp, signature, authorizations);
|
|
171
|
+
}
|
|
172
|
+
async function submitUserOperation(config, signedUserOperation) {
|
|
173
|
+
const chain = signedUserOperation.transaction.chain;
|
|
174
|
+
const userOp = signedUserOperation.userOperation;
|
|
175
|
+
const signature = signedUserOperation.signature;
|
|
176
|
+
// Smart sessions require a UserOp flow
|
|
177
|
+
return await submitUserOp(config, chain, userOp, signature);
|
|
178
|
+
}
|
|
179
|
+
async function simulateTransaction(config, signedTransaction, authorizations) {
|
|
180
|
+
const { intentRoute, transaction, signature } = signedTransaction;
|
|
181
|
+
const { sourceChains, targetChain } = getTransactionParams(transaction);
|
|
182
|
+
const intentOp = intentRoute.intentOp;
|
|
183
|
+
if (!intentOp) {
|
|
184
|
+
throw new error_1.OrderPathRequiredForIntentsError();
|
|
153
185
|
}
|
|
186
|
+
return await simulateIntent(config, sourceChains, targetChain, intentOp, signature, authorizations);
|
|
154
187
|
}
|
|
155
188
|
function getTransactionParams(transaction) {
|
|
156
189
|
const sourceChains = 'chain' in transaction ? [transaction.chain] : transaction.sourceChains;
|
|
@@ -159,15 +192,12 @@ function getTransactionParams(transaction) {
|
|
|
159
192
|
const signers = transaction.signers;
|
|
160
193
|
const eip7702InitSignature = transaction.eip7702InitSignature;
|
|
161
194
|
const sponsored = transaction.sponsored;
|
|
162
|
-
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
},
|
|
169
|
-
]
|
|
170
|
-
: initialTokenRequests;
|
|
195
|
+
const gasLimit = transaction.gasLimit;
|
|
196
|
+
const settlementLayers = transaction.settlementLayers;
|
|
197
|
+
const sourceAssets = transaction.sourceAssets;
|
|
198
|
+
const feeAsset = transaction.feeAsset;
|
|
199
|
+
const lockFunds = transaction.lockFunds;
|
|
200
|
+
const tokenRequests = getTokenRequests(sourceChains || [], targetChain, initialTokenRequests, settlementLayers);
|
|
171
201
|
return {
|
|
172
202
|
sourceChains,
|
|
173
203
|
targetChain,
|
|
@@ -175,9 +205,32 @@ function getTransactionParams(transaction) {
|
|
|
175
205
|
signers,
|
|
176
206
|
sponsored,
|
|
177
207
|
eip7702InitSignature,
|
|
208
|
+
gasLimit,
|
|
209
|
+
settlementLayers,
|
|
210
|
+
sourceAssets,
|
|
211
|
+
feeAsset,
|
|
212
|
+
lockFunds,
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
function getTokenRequests(sourceChains, targetChain, initialTokenRequests, settlementLayers) {
|
|
216
|
+
if (initialTokenRequests) {
|
|
217
|
+
validateTokenSymbols(targetChain, initialTokenRequests.map((tokenRequest) => tokenRequest.address));
|
|
218
|
+
}
|
|
219
|
+
// Across requires passing some value to repay the solvers
|
|
220
|
+
const defaultTokenRequest = {
|
|
221
|
+
address: viem_1.zeroAddress,
|
|
222
|
+
amount: 1n,
|
|
178
223
|
};
|
|
224
|
+
const isSameChain = (settlementLayers?.length === 1 && settlementLayers[0] === 'SAME_CHAIN') ||
|
|
225
|
+
(sourceChains.length === 1 && sourceChains[0].id === targetChain.id);
|
|
226
|
+
const tokenRequests = !initialTokenRequests || initialTokenRequests.length === 0
|
|
227
|
+
? isSameChain
|
|
228
|
+
? []
|
|
229
|
+
: [defaultTokenRequest]
|
|
230
|
+
: initialTokenRequests;
|
|
231
|
+
return tokenRequests;
|
|
179
232
|
}
|
|
180
|
-
async function prepareTransactionAsUserOp(config, chain, callInputs, signers) {
|
|
233
|
+
async function prepareTransactionAsUserOp(config, chain, callInputs, signers, gasLimit) {
|
|
181
234
|
const publicClient = (0, viem_1.createPublicClient)({
|
|
182
235
|
chain,
|
|
183
236
|
transport: (0, utils_1.createTransport)(chain, config.provider),
|
|
@@ -191,9 +244,9 @@ async function prepareTransactionAsUserOp(config, chain, callInputs, signers) {
|
|
|
191
244
|
const userOp = await bundlerClient.prepareUserOperation({
|
|
192
245
|
account: validatorAccount,
|
|
193
246
|
calls,
|
|
247
|
+
callGasLimit: gasLimit,
|
|
194
248
|
});
|
|
195
249
|
return {
|
|
196
|
-
type: 'userop',
|
|
197
250
|
userOp,
|
|
198
251
|
hash: (0, account_abstraction_1.getUserOperationHash)({
|
|
199
252
|
userOperation: userOp,
|
|
@@ -203,14 +256,19 @@ async function prepareTransactionAsUserOp(config, chain, callInputs, signers) {
|
|
|
203
256
|
}),
|
|
204
257
|
};
|
|
205
258
|
}
|
|
206
|
-
async function prepareTransactionAsIntent(config, sourceChains, targetChain, callInputs, gasLimit, tokenRequests, accountAddress, isSponsored, eip7702InitSignature) {
|
|
259
|
+
async function prepareTransactionAsIntent(config, sourceChains, targetChain, callInputs, gasLimit, tokenRequests, accountAddress, isSponsored, eip7702InitSignature, settlementLayers, sourceAssets, feeAsset, lockFunds) {
|
|
207
260
|
const calls = parseCalls(callInputs, targetChain.id);
|
|
208
|
-
const accountAccessList = sourceChains
|
|
209
|
-
|
|
210
|
-
|
|
261
|
+
const accountAccessList = createAccountAccessList(sourceChains, sourceAssets);
|
|
262
|
+
const { setupOps, delegations } = await getSetupOperationsAndDelegations(config, targetChain, accountAddress, eip7702InitSignature);
|
|
263
|
+
const getAccountType = (config) => {
|
|
264
|
+
if (config.account?.type === 'eoa') {
|
|
265
|
+
return 'EOA';
|
|
211
266
|
}
|
|
212
|
-
|
|
213
|
-
|
|
267
|
+
else {
|
|
268
|
+
return 'ERC7579';
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
const accountType = getAccountType(config);
|
|
214
272
|
const metaIntent = {
|
|
215
273
|
destinationChainId: targetChain.id,
|
|
216
274
|
tokenTransfers: tokenRequests.map((tokenRequest) => ({
|
|
@@ -219,7 +277,7 @@ async function prepareTransactionAsIntent(config, sourceChains, targetChain, cal
|
|
|
219
277
|
})),
|
|
220
278
|
account: {
|
|
221
279
|
address: accountAddress,
|
|
222
|
-
accountType:
|
|
280
|
+
accountType: accountType,
|
|
223
281
|
setupOps,
|
|
224
282
|
delegations,
|
|
225
283
|
},
|
|
@@ -227,34 +285,79 @@ async function prepareTransactionAsIntent(config, sourceChains, targetChain, cal
|
|
|
227
285
|
destinationGasUnits: gasLimit,
|
|
228
286
|
accountAccessList,
|
|
229
287
|
options: {
|
|
230
|
-
topupCompact: false,
|
|
288
|
+
topupCompact: lockFunds ?? false,
|
|
289
|
+
feeToken: feeAsset,
|
|
231
290
|
sponsorSettings: {
|
|
232
291
|
gasSponsored: isSponsored,
|
|
233
292
|
bridgeFeesSponsored: isSponsored,
|
|
234
293
|
swapFeesSponsored: isSponsored,
|
|
235
294
|
},
|
|
295
|
+
settlementLayers,
|
|
236
296
|
},
|
|
237
297
|
};
|
|
238
|
-
const orchestrator = getOrchestratorByChain(targetChain.id, config.
|
|
298
|
+
const orchestrator = getOrchestratorByChain(targetChain.id, config.apiKey, config.endpointUrl);
|
|
239
299
|
const intentRoute = await orchestrator.getIntentRoute(metaIntent);
|
|
240
|
-
return
|
|
241
|
-
type: 'intent',
|
|
242
|
-
intentRoute,
|
|
243
|
-
};
|
|
300
|
+
return intentRoute;
|
|
244
301
|
}
|
|
245
302
|
async function signIntent(config, targetChain, intentOp, signers) {
|
|
303
|
+
if (config.account?.type === 'eoa') {
|
|
304
|
+
let signature;
|
|
305
|
+
let digest;
|
|
306
|
+
if (config.eoa?.signTypedData) {
|
|
307
|
+
const typedData = (0, permit2_1.getTypedData)(intentOp);
|
|
308
|
+
signature = await config.eoa.signTypedData(typedData);
|
|
309
|
+
}
|
|
310
|
+
else if (config.eoa?.sign) {
|
|
311
|
+
digest = (0, compact_1.getPermit2Digest)(intentOp);
|
|
312
|
+
signature = await config.eoa.sign({ hash: digest });
|
|
313
|
+
}
|
|
314
|
+
else if (config.eoa?.signMessage) {
|
|
315
|
+
digest = (0, compact_1.getPermit2Digest)(intentOp);
|
|
316
|
+
signature = await config.eoa.signMessage({
|
|
317
|
+
message: { raw: digest },
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
else {
|
|
321
|
+
throw new accounts_1.EoaSigningMethodNotConfiguredError('signTypedData, sign, or signMessage');
|
|
322
|
+
}
|
|
323
|
+
return signature;
|
|
324
|
+
}
|
|
246
325
|
const validator = getValidator(config, signers);
|
|
247
326
|
if (!validator) {
|
|
248
327
|
throw new Error('Validator not available');
|
|
249
328
|
}
|
|
250
329
|
const ownerValidator = (0, validators_1.getOwnerValidator)(config);
|
|
251
330
|
const isRoot = validator.address === ownerValidator.address;
|
|
252
|
-
const
|
|
253
|
-
|
|
331
|
+
const signature = await getIntentSignature(config, intentOp, signers, targetChain, validator, isRoot);
|
|
332
|
+
return signature;
|
|
333
|
+
}
|
|
334
|
+
async function getIntentSignature(config, intentOp, signers, targetChain, validator, isRoot) {
|
|
335
|
+
const withJitFlow = intentOp.elements.some((element) => element.mandate.qualifier.settlementContext?.usingJIT);
|
|
336
|
+
if (withJitFlow) {
|
|
337
|
+
return await getPermit2Signature(config, intentOp, signers, targetChain, validator, isRoot);
|
|
338
|
+
}
|
|
339
|
+
return await getCompactSignature(config, intentOp, signers, targetChain, validator, isRoot);
|
|
340
|
+
}
|
|
341
|
+
async function getPermit2Signature(config, intentOp, signers, targetChain, validator, isRoot) {
|
|
342
|
+
const typedData = (0, permit2_1.getTypedData)(intentOp);
|
|
343
|
+
return await signIntentTypedData(config, signers, targetChain, validator, isRoot, typedData);
|
|
344
|
+
}
|
|
345
|
+
async function getCompactSignature(config, intentOp, signers, targetChain, validator, isRoot) {
|
|
346
|
+
const typedData = (0, compact_1.getCompactTypedData)(intentOp);
|
|
347
|
+
return await signIntentTypedData(config, signers, targetChain, validator, isRoot, typedData);
|
|
348
|
+
}
|
|
349
|
+
async function signIntentTypedData(config, signers, targetChain, validator, isRoot, parameters) {
|
|
350
|
+
if ((0, core_1.supportsEip712)(validator)) {
|
|
351
|
+
return await (0, accounts_1.getTypedDataPackedSignature)(config, signers, targetChain, {
|
|
352
|
+
address: validator.address,
|
|
353
|
+
isRoot,
|
|
354
|
+
}, parameters);
|
|
355
|
+
}
|
|
356
|
+
const hash = (0, viem_1.hashTypedData)(parameters);
|
|
357
|
+
return await (0, accounts_1.getPackedSignature)(config, signers, targetChain, {
|
|
254
358
|
address: validator.address,
|
|
255
359
|
isRoot,
|
|
256
|
-
},
|
|
257
|
-
return signature;
|
|
360
|
+
}, hash);
|
|
258
361
|
}
|
|
259
362
|
async function signUserOp(config, chain, signers, userOp) {
|
|
260
363
|
const validator = getValidator(config, signers);
|
|
@@ -313,16 +416,20 @@ async function submitUserOp(config, chain, userOp, signature) {
|
|
|
313
416
|
async function submitIntent(config, sourceChains, targetChain, intentOp, signature, authorizations) {
|
|
314
417
|
return submitIntentInternal(config, sourceChains, targetChain, intentOp, signature, authorizations);
|
|
315
418
|
}
|
|
316
|
-
function getOrchestratorByChain(chainId, apiKey,
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
419
|
+
function getOrchestratorByChain(chainId, apiKey, orchestratorUrl) {
|
|
420
|
+
if (orchestratorUrl) {
|
|
421
|
+
return (0, orchestrator_1.getOrchestrator)(apiKey, orchestratorUrl);
|
|
422
|
+
}
|
|
423
|
+
const defaultOrchestratorUrl = (0, registry_1.isTestnet)(chainId)
|
|
424
|
+
? consts_1.STAGING_ORCHESTRATOR_URL
|
|
425
|
+
: consts_1.PROD_ORCHESTRATOR_URL;
|
|
426
|
+
return (0, orchestrator_1.getOrchestrator)(apiKey, defaultOrchestratorUrl);
|
|
323
427
|
}
|
|
324
|
-
async function
|
|
325
|
-
|
|
428
|
+
async function simulateIntent(config, sourceChains, targetChain, intentOp, signature, authorizations) {
|
|
429
|
+
return simulateIntentInternal(config, sourceChains, targetChain, intentOp, signature, authorizations);
|
|
430
|
+
}
|
|
431
|
+
function createSignedIntentOp(intentOp, signature, authorizations) {
|
|
432
|
+
return {
|
|
326
433
|
...intentOp,
|
|
327
434
|
originSignatures: Array(intentOp.elements.length).fill(signature),
|
|
328
435
|
destinationSignature: signature,
|
|
@@ -337,7 +444,10 @@ async function submitIntentInternal(config, sourceChains, targetChain, intentOp,
|
|
|
337
444
|
}))
|
|
338
445
|
: undefined,
|
|
339
446
|
};
|
|
340
|
-
|
|
447
|
+
}
|
|
448
|
+
async function submitIntentInternal(config, sourceChains, targetChain, intentOp, signature, authorizations) {
|
|
449
|
+
const signedIntentOp = createSignedIntentOp(intentOp, signature, authorizations);
|
|
450
|
+
const orchestrator = getOrchestratorByChain(targetChain.id, config.apiKey, config.endpointUrl);
|
|
341
451
|
const intentResults = await orchestrator.submitIntent(signedIntentOp);
|
|
342
452
|
return {
|
|
343
453
|
type: 'intent',
|
|
@@ -346,9 +456,15 @@ async function submitIntentInternal(config, sourceChains, targetChain, intentOp,
|
|
|
346
456
|
targetChain: targetChain.id,
|
|
347
457
|
};
|
|
348
458
|
}
|
|
459
|
+
async function simulateIntentInternal(config, _sourceChains, targetChain, intentOp, signature, authorizations) {
|
|
460
|
+
const signedIntentOp = createSignedIntentOp(intentOp, signature, authorizations);
|
|
461
|
+
const orchestrator = getOrchestratorByChain(targetChain.id, config.apiKey, config.endpointUrl);
|
|
462
|
+
const simulationResults = await orchestrator.simulateIntent(signedIntentOp);
|
|
463
|
+
return simulationResults;
|
|
464
|
+
}
|
|
349
465
|
async function getValidatorAccount(config, signers, publicClient, chain) {
|
|
350
466
|
if (!signers) {
|
|
351
|
-
return
|
|
467
|
+
return (0, accounts_1.getSmartAccount)(config, publicClient, chain);
|
|
352
468
|
}
|
|
353
469
|
// Owners
|
|
354
470
|
const withOwner = signers.type === 'owner' ? signers : null;
|
|
@@ -409,9 +525,28 @@ function parseCalls(calls, chainId) {
|
|
|
409
525
|
to: (0, registry_1.resolveTokenAddress)(call.to, chainId),
|
|
410
526
|
}));
|
|
411
527
|
}
|
|
412
|
-
|
|
528
|
+
function createAccountAccessList(sourceChains, sourceAssets) {
|
|
529
|
+
if (!sourceChains && !sourceAssets)
|
|
530
|
+
return undefined;
|
|
531
|
+
const chainIds = sourceChains?.map((chain) => chain.id);
|
|
532
|
+
if (!sourceAssets) {
|
|
533
|
+
return { chainIds };
|
|
534
|
+
}
|
|
535
|
+
if (Array.isArray(sourceAssets)) {
|
|
536
|
+
return chainIds
|
|
537
|
+
? { chainIds, tokens: sourceAssets }
|
|
538
|
+
: { tokens: sourceAssets };
|
|
539
|
+
}
|
|
540
|
+
return { chainTokens: sourceAssets };
|
|
541
|
+
}
|
|
542
|
+
async function getSetupOperationsAndDelegations(config, chain, accountAddress, eip7702InitSignature) {
|
|
413
543
|
const initCode = (0, accounts_1.getInitCode)(config);
|
|
414
|
-
if (config.eoa) {
|
|
544
|
+
if (config.account?.type === 'eoa') {
|
|
545
|
+
return {
|
|
546
|
+
setupOps: [],
|
|
547
|
+
};
|
|
548
|
+
}
|
|
549
|
+
else if ((0, accounts_1.is7702)(config)) {
|
|
415
550
|
// EIP-7702 initialization is only needed for EOA accounts
|
|
416
551
|
if (!eip7702InitSignature || eip7702InitSignature === '0x') {
|
|
417
552
|
throw new Error('EIP-7702 initialization signature is required for EOA accounts');
|
|
@@ -432,6 +567,12 @@ async function getSetupOperationsAndDelegations(config, accountAddress, eip7702I
|
|
|
432
567
|
};
|
|
433
568
|
}
|
|
434
569
|
else if (initCode) {
|
|
570
|
+
const isAccountDeployed = await (0, accounts_1.isDeployed)(config, chain);
|
|
571
|
+
if (isAccountDeployed) {
|
|
572
|
+
return {
|
|
573
|
+
setupOps: [],
|
|
574
|
+
};
|
|
575
|
+
}
|
|
435
576
|
// Contract account with init code
|
|
436
577
|
return {
|
|
437
578
|
setupOps: [
|
|
@@ -449,3 +590,19 @@ async function getSetupOperationsAndDelegations(config, accountAddress, eip7702I
|
|
|
449
590
|
};
|
|
450
591
|
}
|
|
451
592
|
}
|
|
593
|
+
function validateTokenSymbols(chain, tokenAddressOrSymbols) {
|
|
594
|
+
function validateTokenSymbol(chain, addressOrSymbol) {
|
|
595
|
+
// Address
|
|
596
|
+
if ((0, viem_1.isAddress)(addressOrSymbol, { strict: false })) {
|
|
597
|
+
return true;
|
|
598
|
+
}
|
|
599
|
+
// Token symbol
|
|
600
|
+
const address = (0, registry_1.getTokenAddress)(addressOrSymbol, chain.id);
|
|
601
|
+
return (0, viem_1.isAddress)(address, { strict: false });
|
|
602
|
+
}
|
|
603
|
+
for (const addressOrSymbol of tokenAddressOrSymbols) {
|
|
604
|
+
if (!validateTokenSymbol(chain, addressOrSymbol)) {
|
|
605
|
+
throw new Error(`Invalid token symbol: ${addressOrSymbol}`);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
}
|