@rhinestone/sdk 1.0.0-alpha.10 → 1.0.0-alpha.12
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 +8 -6
- package/dist/src/accounts/index.d.ts.map +1 -1
- package/dist/src/accounts/index.js +69 -134
- package/dist/src/accounts/index.test.js +2 -2
- package/dist/src/accounts/kernel.d.ts +3 -2
- package/dist/src/accounts/kernel.d.ts.map +1 -1
- package/dist/src/accounts/kernel.js +3 -5
- package/dist/src/accounts/kernel.test.js +5 -10
- package/dist/src/accounts/nexus.d.ts +2 -2
- package/dist/src/accounts/nexus.d.ts.map +1 -1
- package/dist/src/accounts/nexus.js +5 -6
- package/dist/src/accounts/nexus.test.js +11 -12
- package/dist/src/accounts/safe.d.ts +2 -2
- package/dist/src/accounts/safe.d.ts.map +1 -1
- package/dist/src/accounts/safe.js +3 -5
- package/dist/src/accounts/safe.test.js +4 -5
- package/dist/src/accounts/signing/common.d.ts +23 -0
- package/dist/src/accounts/signing/common.d.ts.map +1 -0
- package/dist/src/accounts/signing/common.js +113 -0
- package/dist/src/accounts/signing/message.d.ts +5 -0
- package/dist/src/accounts/signing/message.d.ts.map +1 -0
- package/dist/src/accounts/signing/message.js +51 -0
- package/dist/src/accounts/signing/typedData.d.ts +5 -0
- package/dist/src/accounts/signing/typedData.d.ts.map +1 -0
- package/dist/src/accounts/signing/typedData.js +39 -0
- package/dist/src/accounts/startale.d.ts +2 -2
- package/dist/src/accounts/startale.d.ts.map +1 -1
- package/dist/src/accounts/startale.js +3 -3
- package/dist/src/accounts/startale.test.js +4 -5
- package/dist/src/actions/index.d.ts +84 -0
- package/dist/src/actions/index.d.ts.map +1 -1
- package/dist/src/actions/index.js +92 -0
- package/dist/src/actions/index.test.js +15 -15
- package/dist/src/actions/smart-session.d.ts +6 -0
- package/dist/src/actions/smart-session.d.ts.map +1 -1
- package/dist/src/actions/smart-session.js +6 -0
- package/dist/src/execution/compact.d.ts +128 -1
- package/dist/src/execution/compact.d.ts.map +1 -1
- package/dist/src/execution/compact.js +91 -0
- package/dist/src/execution/index.d.ts.map +1 -1
- package/dist/src/execution/index.js +7 -8
- package/dist/src/execution/utils.d.ts +7 -6
- package/dist/src/execution/utils.d.ts.map +1 -1
- package/dist/src/execution/utils.js +48 -9
- package/dist/src/index.d.ts +5 -4
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +75 -11
- package/dist/src/modules/index.test.js +1 -1
- package/dist/src/modules/validators/core.js +1 -1
- package/dist/src/modules/validators/core.test.js +3 -3
- package/dist/src/modules/validators/smart-sessions.js +3 -3
- package/dist/src/modules/validators/smart-sessions.test.js +4 -4
- package/dist/src/orchestrator/index.d.ts +1 -2
- package/dist/src/orchestrator/index.d.ts.map +1 -1
- package/dist/src/orchestrator/index.js +1 -3
- package/dist/src/orchestrator/types.d.ts +12 -0
- package/dist/src/orchestrator/types.d.ts.map +1 -1
- package/dist/src/orchestrator/utils.d.ts +1 -3
- package/dist/src/orchestrator/utils.d.ts.map +1 -1
- package/dist/src/orchestrator/utils.js +0 -102
- package/dist/src/types.d.ts +1 -0
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -4,6 +4,7 @@ exports.COMPACT_ADDRESS = void 0;
|
|
|
4
4
|
exports.getDepositEtherCall = getDepositEtherCall;
|
|
5
5
|
exports.getDepositErc20Call = getDepositErc20Call;
|
|
6
6
|
exports.getApproveErc20Call = getApproveErc20Call;
|
|
7
|
+
exports.getIntentData = getIntentData;
|
|
7
8
|
const viem_1 = require("viem");
|
|
8
9
|
const COMPACT_ADDRESS = '0xa2E6C7Ba8613E1534dCB990e7e4962216C0a5d58';
|
|
9
10
|
exports.COMPACT_ADDRESS = COMPACT_ADDRESS;
|
|
@@ -103,3 +104,93 @@ function lockTag() {
|
|
|
103
104
|
const hex = tagBig.toString(16).slice(0, 24);
|
|
104
105
|
return `0x${hex}`;
|
|
105
106
|
}
|
|
107
|
+
// Define the typed data structure as const to preserve type safety
|
|
108
|
+
const COMPACT_TYPED_DATA_TYPES = {
|
|
109
|
+
MultichainCompact: [
|
|
110
|
+
{ name: 'sponsor', type: 'address' },
|
|
111
|
+
{ name: 'nonce', type: 'uint256' },
|
|
112
|
+
{ name: 'expires', type: 'uint256' },
|
|
113
|
+
{ name: 'elements', type: 'Element[]' },
|
|
114
|
+
],
|
|
115
|
+
Element: [
|
|
116
|
+
{ name: 'arbiter', type: 'address' },
|
|
117
|
+
{ name: 'chainId', type: 'uint256' },
|
|
118
|
+
{ name: 'commitments', type: 'Lock[]' },
|
|
119
|
+
{ name: 'mandate', type: 'Mandate' },
|
|
120
|
+
],
|
|
121
|
+
Lock: [
|
|
122
|
+
{ name: 'lockTag', type: 'bytes12' },
|
|
123
|
+
{ name: 'token', type: 'address' },
|
|
124
|
+
{ name: 'amount', type: 'uint256' },
|
|
125
|
+
],
|
|
126
|
+
Mandate: [
|
|
127
|
+
{ name: 'target', type: 'Target' },
|
|
128
|
+
{ name: 'originOps', type: 'Op[]' },
|
|
129
|
+
{ name: 'destOps', type: 'Op[]' },
|
|
130
|
+
{ name: 'q', type: 'bytes32' },
|
|
131
|
+
],
|
|
132
|
+
Target: [
|
|
133
|
+
{ name: 'recipient', type: 'address' },
|
|
134
|
+
{ name: 'tokenOut', type: 'Token[]' },
|
|
135
|
+
{ name: 'targetChain', type: 'uint256' },
|
|
136
|
+
{ name: 'fillExpiry', type: 'uint256' },
|
|
137
|
+
],
|
|
138
|
+
Token: [
|
|
139
|
+
{ name: 'token', type: 'address' },
|
|
140
|
+
{ name: 'amount', type: 'uint256' },
|
|
141
|
+
],
|
|
142
|
+
Op: [
|
|
143
|
+
{ name: 'to', type: 'address' },
|
|
144
|
+
{ name: 'value', type: 'uint256' },
|
|
145
|
+
{ name: 'data', type: 'bytes' },
|
|
146
|
+
],
|
|
147
|
+
};
|
|
148
|
+
function getIntentData(intentOp) {
|
|
149
|
+
const typedData = {
|
|
150
|
+
domain: {
|
|
151
|
+
name: 'The Compact',
|
|
152
|
+
version: '1',
|
|
153
|
+
chainId: BigInt(intentOp.elements[0].chainId),
|
|
154
|
+
verifyingContract: '0x73d2dc0c21fca4ec1601895d50df7f5624f07d3f',
|
|
155
|
+
},
|
|
156
|
+
types: COMPACT_TYPED_DATA_TYPES,
|
|
157
|
+
primaryType: 'MultichainCompact',
|
|
158
|
+
message: {
|
|
159
|
+
sponsor: intentOp.sponsor,
|
|
160
|
+
nonce: BigInt(intentOp.nonce),
|
|
161
|
+
expires: BigInt(intentOp.expires),
|
|
162
|
+
elements: intentOp.elements.map((element) => ({
|
|
163
|
+
arbiter: element.arbiter,
|
|
164
|
+
chainId: BigInt(element.chainId),
|
|
165
|
+
commitments: element.idsAndAmounts.map((token) => ({
|
|
166
|
+
lockTag: (0, viem_1.slice)((0, viem_1.toHex)(BigInt(token[0])), 0, 12),
|
|
167
|
+
token: (0, viem_1.slice)((0, viem_1.toHex)(BigInt(token[0])), 12, 32),
|
|
168
|
+
amount: BigInt(token[1]),
|
|
169
|
+
})),
|
|
170
|
+
mandate: {
|
|
171
|
+
target: {
|
|
172
|
+
recipient: element.mandate.recipient,
|
|
173
|
+
tokenOut: element.mandate.tokenOut.map((token) => ({
|
|
174
|
+
token: (0, viem_1.slice)((0, viem_1.toHex)(BigInt(token[0])), 12, 32),
|
|
175
|
+
amount: BigInt(token[1]),
|
|
176
|
+
})),
|
|
177
|
+
targetChain: BigInt(element.mandate.destinationChainId),
|
|
178
|
+
fillExpiry: BigInt(element.mandate.fillDeadline),
|
|
179
|
+
},
|
|
180
|
+
originOps: element.mandate.preClaimOps.map((op) => ({
|
|
181
|
+
to: op.to,
|
|
182
|
+
value: BigInt(op.value),
|
|
183
|
+
data: op.data,
|
|
184
|
+
})),
|
|
185
|
+
destOps: element.mandate.destinationOps.map((op) => ({
|
|
186
|
+
to: op.to,
|
|
187
|
+
value: BigInt(op.value),
|
|
188
|
+
data: op.data,
|
|
189
|
+
})),
|
|
190
|
+
q: (0, viem_1.keccak256)(element.mandate.qualifier?.encodedVal ?? '0x'),
|
|
191
|
+
},
|
|
192
|
+
})),
|
|
193
|
+
},
|
|
194
|
+
};
|
|
195
|
+
return typedData;
|
|
196
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../execution/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,KAAK,EAAmC,MAAM,MAAM,CAAA;AAKhF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAQrD,OAAO,KAAK,EAEV,uBAAuB,EAGvB,WAAW,EACZ,MAAM,UAAU,CAAA;AACjB,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,gCAAgC,EAChC,yBAAyB,EACzB,0CAA0C,EAC1C,0CAA0C,EAC3C,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAa5D,iBAAe,eAAe,CAC5B,MAAM,EAAE,uBAAuB,EAC/B,WAAW,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../execution/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,KAAK,EAAmC,MAAM,MAAM,CAAA;AAKhF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAQrD,OAAO,KAAK,EAEV,uBAAuB,EAGvB,WAAW,EACZ,MAAM,UAAU,CAAA;AACjB,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,gCAAgC,EAChC,yBAAyB,EACzB,0CAA0C,EAC1C,0CAA0C,EAC3C,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAa5D,iBAAe,eAAe,CAC5B,MAAM,EAAE,uBAAuB,EAC/B,WAAW,EAAE,WAAW,8BA2BzB;AAyID,iBAAe,gBAAgB,CAC7B,MAAM,EAAE,uBAAuB,EAC/B,MAAM,EAAE,iBAAiB,EACzB,uBAAuB,EAAE,OAAO;;;;;;;;;;;;GA2CjC;AAED,iBAAe,qBAAqB,CAClC,MAAM,EAAE,uBAAuB,EAC/B,KAAK,EAAE,KAAK,EACZ,YAAY,EAAE,OAAO,EACrB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,CAAC,CASjB;AAED,iBAAe,YAAY,CACzB,MAAM,EAAE,uBAAuB,EAC/B,UAAU,EAAE,OAAO,gDAMpB;AAED,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,qBAAqB,EACrB,YAAY,EAEZ,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,0CAA0C,EAC1C,0CAA0C,EAC1C,gCAAgC,EAChC,yBAAyB,GAC1B,CAAA;AACD,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,CAAA"}
|
|
@@ -25,14 +25,14 @@ const POLLING_INTERVAL = 500;
|
|
|
25
25
|
async function sendTransaction(config, transaction) {
|
|
26
26
|
if ('chain' in transaction) {
|
|
27
27
|
// Same-chain transaction
|
|
28
|
-
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, transaction.sponsored);
|
|
29
29
|
}
|
|
30
30
|
else {
|
|
31
31
|
// Cross-chain transaction
|
|
32
|
-
return await sendTransactionInternal(config, transaction.sourceChains || [], transaction.targetChain, transaction.calls, transaction.gasLimit, transaction.tokenRequests, transaction.signers);
|
|
32
|
+
return await sendTransactionInternal(config, transaction.sourceChains || [], transaction.targetChain, transaction.calls, transaction.gasLimit, transaction.tokenRequests, transaction.signers, transaction.sponsored);
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
-
async function sendTransactionInternal(config, sourceChains, targetChain, callInputs, gasLimit, initialTokenRequests, signers) {
|
|
35
|
+
async function sendTransactionInternal(config, sourceChains, targetChain, callInputs, gasLimit, initialTokenRequests, signers, sponsored) {
|
|
36
36
|
const accountAddress = (0, accounts_1.getAddress)(config);
|
|
37
37
|
// Across requires passing some value to repay the solvers
|
|
38
38
|
const tokenRequests = !initialTokenRequests || initialTokenRequests.length === 0
|
|
@@ -53,7 +53,7 @@ async function sendTransactionInternal(config, sourceChains, targetChain, callIn
|
|
|
53
53
|
return await sendTransactionAsUserOp(config, targetChain, callInputs, signers);
|
|
54
54
|
}
|
|
55
55
|
else {
|
|
56
|
-
return await sendTransactionAsIntent(config, sourceChains, targetChain, callInputs, gasLimit, tokenRequests, accountAddress, signers);
|
|
56
|
+
return await sendTransactionAsIntent(config, sourceChains, targetChain, callInputs, gasLimit, tokenRequests, accountAddress, signers, sponsored);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
async function sendTransactionAsUserOp(config, chain, callInputs, signers) {
|
|
@@ -83,17 +83,16 @@ async function sendTransactionAsUserOp(config, chain, callInputs, signers) {
|
|
|
83
83
|
chain: chain.id,
|
|
84
84
|
};
|
|
85
85
|
}
|
|
86
|
-
async function sendTransactionAsIntent(config, sourceChains, targetChain, callInputs, gasLimit, tokenRequests, accountAddress, signers) {
|
|
87
|
-
const { intentRoute
|
|
86
|
+
async function sendTransactionAsIntent(config, sourceChains, targetChain, callInputs, gasLimit, tokenRequests, accountAddress, signers, sponsored) {
|
|
87
|
+
const { intentRoute } = await (0, utils_2.prepareTransactionAsIntent)(config, sourceChains, targetChain, callInputs, gasLimit, tokenRequests, accountAddress, sponsored ?? false);
|
|
88
88
|
if (!intentRoute) {
|
|
89
89
|
throw new error_1.OrderPathRequiredForIntentsError();
|
|
90
90
|
}
|
|
91
|
-
const signature = await (0, utils_2.signIntent)(config, targetChain,
|
|
91
|
+
const signature = await (0, utils_2.signIntent)(config, targetChain, intentRoute.intentOp, signers);
|
|
92
92
|
const authorizations = config.eoa
|
|
93
93
|
? await (0, utils_2.signAuthorizationsInternal)(config, {
|
|
94
94
|
type: 'intent',
|
|
95
95
|
intentRoute,
|
|
96
|
-
hash: intentHash,
|
|
97
96
|
})
|
|
98
97
|
: [];
|
|
99
98
|
return await (0, utils_2.submitIntentInternal)(config, sourceChains, targetChain, intentRoute.intentOp, signature, authorizations);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Address, type Chain, type Hex, type PublicClient, type SignedAuthorization, type SignedAuthorizationList } from 'viem';
|
|
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
4
|
import type { Call, CallInput, RhinestoneAccountConfig, SignerSet, TokenRequest, Transaction } from '../types';
|
|
@@ -9,12 +9,11 @@ type TransactionResult = {
|
|
|
9
9
|
} | {
|
|
10
10
|
type: 'intent';
|
|
11
11
|
id: bigint;
|
|
12
|
-
|
|
12
|
+
sourceChains?: number[];
|
|
13
13
|
targetChain: number;
|
|
14
14
|
};
|
|
15
15
|
interface IntentData {
|
|
16
16
|
type: 'intent';
|
|
17
|
-
hash: Hex;
|
|
18
17
|
intentRoute: IntentRoute;
|
|
19
18
|
}
|
|
20
19
|
interface UserOpData {
|
|
@@ -32,14 +31,16 @@ interface SignedTransactionData extends PreparedTransactionData {
|
|
|
32
31
|
declare function prepareTransaction(config: RhinestoneAccountConfig, transaction: Transaction): Promise<PreparedTransactionData>;
|
|
33
32
|
declare function signTransaction(config: RhinestoneAccountConfig, preparedTransaction: PreparedTransactionData): Promise<SignedTransactionData>;
|
|
34
33
|
declare function signAuthorizations(config: RhinestoneAccountConfig, preparedTransaction: PreparedTransactionData): Promise<SignedAuthorization[]>;
|
|
34
|
+
declare function signMessage(config: RhinestoneAccountConfig, message: SignableMessage, chain: Chain, signers: SignerSet | undefined): Promise<`0x${string}`>;
|
|
35
|
+
declare function signTypedData<typedData extends TypedData | Record<string, unknown> = TypedData, primaryType extends keyof typedData | 'EIP712Domain' = keyof typedData>(config: RhinestoneAccountConfig, parameters: HashTypedDataParameters<typedData, primaryType>, chain: Chain, signers: SignerSet | undefined): Promise<`0x${string}`>;
|
|
35
36
|
declare function signAuthorizationsInternal(config: RhinestoneAccountConfig, data: IntentData | UserOpData): Promise<SignedAuthorization[]>;
|
|
36
37
|
declare function submitTransaction(config: RhinestoneAccountConfig, signedTransaction: SignedTransactionData, authorizations: SignedAuthorizationList): Promise<TransactionResult>;
|
|
37
|
-
declare function prepareTransactionAsIntent(config: RhinestoneAccountConfig, sourceChains: Chain[] | undefined, targetChain: Chain, callInputs: CallInput[], gasLimit: bigint | undefined, tokenRequests: TokenRequest[], accountAddress: Address, eip7702InitSignature?: Hex): Promise<IntentData>;
|
|
38
|
-
declare function signIntent(config: RhinestoneAccountConfig, targetChain: Chain,
|
|
38
|
+
declare function prepareTransactionAsIntent(config: RhinestoneAccountConfig, sourceChains: Chain[] | undefined, targetChain: Chain, callInputs: CallInput[], gasLimit: bigint | undefined, tokenRequests: TokenRequest[], accountAddress: Address, isSponsored: boolean, eip7702InitSignature?: Hex): Promise<IntentData>;
|
|
39
|
+
declare function signIntent(config: RhinestoneAccountConfig, targetChain: Chain, intentOp: IntentOp, signers?: SignerSet): Promise<`0x${string}`>;
|
|
39
40
|
declare function getOrchestratorByChain(chainId: number, apiKey: string): import("../orchestrator").Orchestrator;
|
|
40
41
|
declare function submitIntentInternal(config: RhinestoneAccountConfig, sourceChains: Chain[] | undefined, targetChain: Chain, intentOp: IntentOp, signature: Hex, authorizations: SignedAuthorizationList): Promise<TransactionResult>;
|
|
41
42
|
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>;
|
|
42
43
|
declare function parseCalls(calls: CallInput[], chainId: number): Call[];
|
|
43
|
-
export { prepareTransaction, signTransaction, signAuthorizations, signAuthorizationsInternal, submitTransaction, getOrchestratorByChain, signIntent, prepareTransactionAsIntent, submitIntentInternal, getValidatorAccount, parseCalls, };
|
|
44
|
+
export { prepareTransaction, signTransaction, signAuthorizations, signAuthorizationsInternal, signMessage, signTypedData, submitTransaction, getOrchestratorByChain, signIntent, prepareTransactionAsIntent, submitIntentInternal, getValidatorAccount, parseCalls, };
|
|
44
45
|
export type { IntentData, TransactionResult, PreparedTransactionData, SignedTransactionData, };
|
|
45
46
|
//# 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,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,EAER,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;AAuBjC,OAAO,EAGL,KAAK,QAAQ,EACb,KAAK,WAAW,EAGjB,MAAM,iBAAiB,CAAA;AAUxB,OAAO,KAAK,EACV,IAAI,EACJ,SAAS,EACT,uBAAuB,EACvB,SAAS,EACT,YAAY,EACZ,WAAW,EACZ,MAAM,UAAU,CAAA;AAQjB,KAAK,iBAAiB,GAClB;IACE,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AAK,yKA6Bb;AAiDD,iBAAS,UAAU,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,EAAE,CAM/D;AAmDD,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EAClB,0BAA0B,EAC1B,WAAW,EACX,aAAa,EACb,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"}
|
|
@@ -4,6 +4,8 @@ exports.prepareTransaction = prepareTransaction;
|
|
|
4
4
|
exports.signTransaction = signTransaction;
|
|
5
5
|
exports.signAuthorizations = signAuthorizations;
|
|
6
6
|
exports.signAuthorizationsInternal = signAuthorizationsInternal;
|
|
7
|
+
exports.signMessage = signMessage;
|
|
8
|
+
exports.signTypedData = signTypedData;
|
|
7
9
|
exports.submitTransaction = submitTransaction;
|
|
8
10
|
exports.getOrchestratorByChain = getOrchestratorByChain;
|
|
9
11
|
exports.signIntent = signIntent;
|
|
@@ -20,9 +22,10 @@ const core_1 = require("../modules/validators/core");
|
|
|
20
22
|
const orchestrator_1 = require("../orchestrator");
|
|
21
23
|
const consts_1 = require("../orchestrator/consts");
|
|
22
24
|
const registry_1 = require("../orchestrator/registry");
|
|
25
|
+
const compact_1 = require("./compact");
|
|
23
26
|
const error_1 = require("./error");
|
|
24
27
|
async function prepareTransaction(config, transaction) {
|
|
25
|
-
const { sourceChains, targetChain, tokenRequests, signers, eip7702InitSignature, } = getTransactionParams(transaction);
|
|
28
|
+
const { sourceChains, targetChain, tokenRequests, signers, sponsored, eip7702InitSignature, } = getTransactionParams(transaction);
|
|
26
29
|
const accountAddress = (0, accounts_1.getAddress)(config);
|
|
27
30
|
let data;
|
|
28
31
|
const asUserOp = signers?.type === 'guardians' || signers?.type === 'session';
|
|
@@ -34,7 +37,7 @@ async function prepareTransaction(config, transaction) {
|
|
|
34
37
|
data = await prepareTransactionAsUserOp(config, targetChain, transaction.calls, signers);
|
|
35
38
|
}
|
|
36
39
|
else {
|
|
37
|
-
data = await prepareTransactionAsIntent(config, sourceChains, targetChain, transaction.calls, transaction.gasLimit, tokenRequests, accountAddress, eip7702InitSignature);
|
|
40
|
+
data = await prepareTransactionAsIntent(config, sourceChains, targetChain, transaction.calls, transaction.gasLimit, tokenRequests, accountAddress, sponsored ?? false, eip7702InitSignature);
|
|
38
41
|
}
|
|
39
42
|
return {
|
|
40
43
|
data,
|
|
@@ -56,7 +59,7 @@ async function signTransaction(config, preparedTransaction) {
|
|
|
56
59
|
signature = await signUserOp(config, chain, signers, userOp);
|
|
57
60
|
}
|
|
58
61
|
else {
|
|
59
|
-
signature = await signIntent(config, targetChain, data.
|
|
62
|
+
signature = await signIntent(config, targetChain, data.intentRoute.intentOp, signers);
|
|
60
63
|
}
|
|
61
64
|
return {
|
|
62
65
|
data,
|
|
@@ -67,6 +70,33 @@ async function signTransaction(config, preparedTransaction) {
|
|
|
67
70
|
async function signAuthorizations(config, preparedTransaction) {
|
|
68
71
|
return await signAuthorizationsInternal(config, preparedTransaction.data);
|
|
69
72
|
}
|
|
73
|
+
async function signMessage(config, message, chain, signers) {
|
|
74
|
+
const validator = getValidator(config, signers);
|
|
75
|
+
if (!validator) {
|
|
76
|
+
throw new Error('Validator not available');
|
|
77
|
+
}
|
|
78
|
+
const ownerValidator = (0, validators_1.getOwnerValidator)(config);
|
|
79
|
+
const isRoot = validator.address === ownerValidator.address;
|
|
80
|
+
const hash = (0, viem_1.hashMessage)(message);
|
|
81
|
+
const signature = await (0, accounts_1.getPackedSignature)(config, signers, chain, {
|
|
82
|
+
address: validator.address,
|
|
83
|
+
isRoot,
|
|
84
|
+
}, hash);
|
|
85
|
+
return await (0, accounts_1.toErc6492Signature)(config, signature, chain);
|
|
86
|
+
}
|
|
87
|
+
async function signTypedData(config, parameters, chain, signers) {
|
|
88
|
+
const validator = getValidator(config, signers);
|
|
89
|
+
if (!validator) {
|
|
90
|
+
throw new Error('Validator not available');
|
|
91
|
+
}
|
|
92
|
+
const ownerValidator = (0, validators_1.getOwnerValidator)(config);
|
|
93
|
+
const isRoot = validator.address === ownerValidator.address;
|
|
94
|
+
const signature = await (0, accounts_1.getTypedDataPackedSignature)(config, signers, chain, {
|
|
95
|
+
address: validator.address,
|
|
96
|
+
isRoot,
|
|
97
|
+
}, parameters);
|
|
98
|
+
return await (0, accounts_1.toErc6492Signature)(config, signature, chain);
|
|
99
|
+
}
|
|
70
100
|
async function signAuthorizationsInternal(config, data) {
|
|
71
101
|
const eoa = config.eoa;
|
|
72
102
|
if (!eoa) {
|
|
@@ -131,6 +161,7 @@ function getTransactionParams(transaction) {
|
|
|
131
161
|
const initialTokenRequests = transaction.tokenRequests;
|
|
132
162
|
const signers = transaction.signers;
|
|
133
163
|
const eip7702InitSignature = transaction.eip7702InitSignature;
|
|
164
|
+
const sponsored = transaction.sponsored;
|
|
134
165
|
// Across requires passing some value to repay the solvers
|
|
135
166
|
const tokenRequests = !initialTokenRequests || initialTokenRequests.length === 0
|
|
136
167
|
? [
|
|
@@ -145,6 +176,7 @@ function getTransactionParams(transaction) {
|
|
|
145
176
|
targetChain,
|
|
146
177
|
tokenRequests,
|
|
147
178
|
signers,
|
|
179
|
+
sponsored,
|
|
148
180
|
eip7702InitSignature,
|
|
149
181
|
};
|
|
150
182
|
}
|
|
@@ -174,7 +206,7 @@ async function prepareTransactionAsUserOp(config, chain, callInputs, signers) {
|
|
|
174
206
|
}),
|
|
175
207
|
};
|
|
176
208
|
}
|
|
177
|
-
async function prepareTransactionAsIntent(config, sourceChains, targetChain, callInputs, gasLimit, tokenRequests, accountAddress, eip7702InitSignature) {
|
|
209
|
+
async function prepareTransactionAsIntent(config, sourceChains, targetChain, callInputs, gasLimit, tokenRequests, accountAddress, isSponsored, eip7702InitSignature) {
|
|
178
210
|
const calls = parseCalls(callInputs, targetChain.id);
|
|
179
211
|
const accountAccessList = sourceChains && sourceChains.length > 0
|
|
180
212
|
? {
|
|
@@ -197,27 +229,34 @@ async function prepareTransactionAsIntent(config, sourceChains, targetChain, cal
|
|
|
197
229
|
destinationExecutions: calls,
|
|
198
230
|
destinationGasUnits: gasLimit,
|
|
199
231
|
accountAccessList,
|
|
232
|
+
options: {
|
|
233
|
+
topupCompact: false,
|
|
234
|
+
sponsorSettings: {
|
|
235
|
+
gasSponsored: isSponsored,
|
|
236
|
+
bridgeFeesSponsored: isSponsored,
|
|
237
|
+
swapFeesSponsored: isSponsored,
|
|
238
|
+
},
|
|
239
|
+
},
|
|
200
240
|
};
|
|
201
241
|
const orchestrator = getOrchestratorByChain(targetChain.id, config.rhinestoneApiKey);
|
|
202
242
|
const intentRoute = await orchestrator.getIntentRoute(metaIntent);
|
|
203
|
-
const intentHash = (0, orchestrator_1.getIntentOpHash)(intentRoute.intentOp);
|
|
204
243
|
return {
|
|
205
244
|
type: 'intent',
|
|
206
245
|
intentRoute,
|
|
207
|
-
hash: intentHash,
|
|
208
246
|
};
|
|
209
247
|
}
|
|
210
|
-
async function signIntent(config, targetChain,
|
|
248
|
+
async function signIntent(config, targetChain, intentOp, signers) {
|
|
211
249
|
const validator = getValidator(config, signers);
|
|
212
250
|
if (!validator) {
|
|
213
251
|
throw new Error('Validator not available');
|
|
214
252
|
}
|
|
215
253
|
const ownerValidator = (0, validators_1.getOwnerValidator)(config);
|
|
216
254
|
const isRoot = validator.address === ownerValidator.address;
|
|
217
|
-
const
|
|
255
|
+
const typedData = (0, compact_1.getIntentData)(intentOp);
|
|
256
|
+
const signature = await (0, accounts_1.getTypedDataPackedSignature)(config, signers, targetChain, {
|
|
218
257
|
address: validator.address,
|
|
219
258
|
isRoot,
|
|
220
|
-
},
|
|
259
|
+
}, typedData);
|
|
221
260
|
return signature;
|
|
222
261
|
}
|
|
223
262
|
async function signUserOp(config, chain, signers, userOp) {
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import type { Address, Chain, Hex, SignedAuthorizationList } from 'viem';
|
|
1
|
+
import type { Address, Chain, HashTypedDataParameters, Hex, SignableMessage, SignedAuthorizationList, TypedData } 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
|
-
import { createTransport } from './accounts/utils';
|
|
5
4
|
import { addOwner, changeMultiFactorThreshold, changeThreshold, disableEcdsa, disableMultiFactor, disablePasskeys, enableEcdsa, enableMultiFactor, enablePasskeys, encodeSmartSessionSignature, recover, removeOwner, removeSubValidator, setSubValidator, setUpRecovery } from './actions';
|
|
6
5
|
import type { TransactionResult } from './execution';
|
|
7
6
|
import { ExecutionError, IntentFailedError, isExecutionError, OrderPathRequiredForIntentsError, SessionChainRequiredError, SourceChainsNotAvailableForUserOpFlowError, UserOperationRequiredForSmartSessionsError } from './execution';
|
|
8
7
|
import { type SessionDetails } from './execution/smart-session';
|
|
9
8
|
import { type IntentData, type PreparedTransactionData, type SignedTransactionData } from './execution/utils';
|
|
10
9
|
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';
|
|
11
|
-
import type { Call, RhinestoneAccountConfig, Session, Transaction } from './types';
|
|
10
|
+
import type { Call, RhinestoneAccountConfig, Session, SignerSet, Transaction } from './types';
|
|
12
11
|
interface RhinestoneAccount {
|
|
13
12
|
config: RhinestoneAccountConfig;
|
|
14
13
|
deploy: (chain: Chain, session?: Session) => Promise<void>;
|
|
@@ -16,6 +15,8 @@ interface RhinestoneAccount {
|
|
|
16
15
|
prepareTransaction: (transaction: Transaction) => Promise<PreparedTransactionData>;
|
|
17
16
|
signTransaction: (preparedTransaction: PreparedTransactionData) => Promise<SignedTransactionData>;
|
|
18
17
|
signAuthorizations: (preparedTransaction: PreparedTransactionData) => Promise<SignedAuthorizationList>;
|
|
18
|
+
signMessage: (message: SignableMessage, chain: Chain, signers: SignerSet | undefined) => Promise<Hex>;
|
|
19
|
+
signTypedData: <typedData extends TypedData | Record<string, unknown> = TypedData, primaryType extends keyof typedData | 'EIP712Domain' = keyof typedData>(parameters: HashTypedDataParameters<typedData, primaryType>, chain: Chain, signers: SignerSet | undefined) => Promise<Hex>;
|
|
19
20
|
submitTransaction: (signedTransaction: SignedTransactionData, authorizations?: SignedAuthorizationList) => Promise<TransactionResult>;
|
|
20
21
|
sendTransaction: (transaction: Transaction) => Promise<TransactionResult>;
|
|
21
22
|
waitForExecution: (result: TransactionResult, acceptsPreconfirmations?: boolean) => Promise<IntentOpStatus | UserOperationReceipt>;
|
|
@@ -36,6 +37,6 @@ interface RhinestoneAccount {
|
|
|
36
37
|
* @returns account
|
|
37
38
|
*/
|
|
38
39
|
declare function createRhinestoneAccount(config: RhinestoneAccountConfig): Promise<RhinestoneAccount>;
|
|
39
|
-
export { createRhinestoneAccount,
|
|
40
|
+
export { createRhinestoneAccount, addOwner, changeMultiFactorThreshold, changeThreshold, disableEcdsa, disableMultiFactor, disablePasskeys, enableEcdsa, enableMultiFactor, enablePasskeys, encodeSmartSessionSignature, recover, removeOwner, removeSubValidator, setSubValidator, setUpRecovery, 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
41
|
export type { RhinestoneAccount, Session, Call, IntentData, PreparedTransactionData, SignedTransactionData, TransactionResult, IntentCost, IntentInput, IntentOp, IntentOpStatus, IntentResult, IntentRoute, SettlementSystem, SignedIntentOp, Portfolio, };
|
|
41
42
|
//# 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,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,KAAK,EACL,uBAAuB,EACvB,GAAG,EACH,eAAe,EACf,uBAAuB,EACvB,SAAS,EACV,MAAM,MAAM,CAAA;AACb,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AACpE,OAAO,EACL,YAAY,EAEZ,8BAA8B,EAC9B,kCAAkC,EAClC,wCAAwC,EACxC,4BAA4B,EAE5B,cAAc,EACd,kCAAkC,EAClC,qCAAqC,EACrC,4BAA4B,EAE7B,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,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,EA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W,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.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.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 =
|
|
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.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 = 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; } });
|
|
@@ -12,8 +12,6 @@ Object.defineProperty(exports, "isAccountError", { enumerable: true, get: functi
|
|
|
12
12
|
Object.defineProperty(exports, "SigningNotSupportedForAccountError", { enumerable: true, get: function () { return accounts_1.SigningNotSupportedForAccountError; } });
|
|
13
13
|
Object.defineProperty(exports, "SignMessageNotSupportedByAccountError", { enumerable: true, get: function () { return accounts_1.SignMessageNotSupportedByAccountError; } });
|
|
14
14
|
Object.defineProperty(exports, "SmartSessionsNotEnabledError", { enumerable: true, get: function () { return accounts_1.SmartSessionsNotEnabledError; } });
|
|
15
|
-
const utils_1 = require("./accounts/utils");
|
|
16
|
-
Object.defineProperty(exports, "createTransport", { enumerable: true, get: function () { return utils_1.createTransport; } });
|
|
17
15
|
const actions_1 = require("./actions");
|
|
18
16
|
Object.defineProperty(exports, "addOwner", { enumerable: true, get: function () { return actions_1.addOwner; } });
|
|
19
17
|
Object.defineProperty(exports, "changeMultiFactorThreshold", { enumerable: true, get: function () { return actions_1.changeMultiFactorThreshold; } });
|
|
@@ -39,7 +37,7 @@ Object.defineProperty(exports, "SessionChainRequiredError", { enumerable: true,
|
|
|
39
37
|
Object.defineProperty(exports, "SourceChainsNotAvailableForUserOpFlowError", { enumerable: true, get: function () { return execution_1.SourceChainsNotAvailableForUserOpFlowError; } });
|
|
40
38
|
Object.defineProperty(exports, "UserOperationRequiredForSmartSessionsError", { enumerable: true, get: function () { return execution_1.UserOperationRequiredForSmartSessionsError; } });
|
|
41
39
|
const smart_session_1 = require("./execution/smart-session");
|
|
42
|
-
const
|
|
40
|
+
const utils_1 = require("./execution/utils");
|
|
43
41
|
const modules_1 = require("./modules");
|
|
44
42
|
const orchestrator_1 = require("./orchestrator");
|
|
45
43
|
Object.defineProperty(exports, "AuthenticationRequiredError", { enumerable: true, get: function () { return orchestrator_1.AuthenticationRequiredError; } });
|
|
@@ -62,23 +60,77 @@ Object.defineProperty(exports, "UnsupportedTokenError", { enumerable: true, get:
|
|
|
62
60
|
* @returns account
|
|
63
61
|
*/
|
|
64
62
|
async function createRhinestoneAccount(config) {
|
|
63
|
+
/**
|
|
64
|
+
* Deploys the account on a given chain
|
|
65
|
+
* @param chain Chain to deploy the account on
|
|
66
|
+
* @param session Session to deploy the account on (optional)
|
|
67
|
+
*/
|
|
65
68
|
function deploy(chain, session) {
|
|
66
69
|
return (0, accounts_1.deploy)(config, chain, session);
|
|
67
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Prepare and sign the EIP-7702 account initialization data
|
|
73
|
+
* @returns init data signature
|
|
74
|
+
*/
|
|
68
75
|
function signEip7702InitData() {
|
|
69
76
|
return (0, accounts_1.signEip7702InitData)(config);
|
|
70
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Prepare a transaction data
|
|
80
|
+
* @param transaction Transaction to prepare
|
|
81
|
+
* @returns prepared transaction data
|
|
82
|
+
*/
|
|
71
83
|
function prepareTransaction(transaction) {
|
|
72
|
-
return (0,
|
|
84
|
+
return (0, utils_1.prepareTransaction)(config, transaction);
|
|
73
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* Sign a transaction
|
|
88
|
+
* @param preparedTransaction Prepared transaction data
|
|
89
|
+
* @returns signed transaction data
|
|
90
|
+
* @see {@link prepareTransaction} to prepare the transaction data for signing
|
|
91
|
+
*/
|
|
74
92
|
function signTransaction(preparedTransaction) {
|
|
75
|
-
return (0,
|
|
93
|
+
return (0, utils_1.signTransaction)(config, preparedTransaction);
|
|
76
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* Sign the required EIP-7702 authorizations for a transaction
|
|
97
|
+
* @param preparedTransaction Prepared transaction data
|
|
98
|
+
* @returns signed authorizations
|
|
99
|
+
* @see {@link prepareTransaction} to prepare the transaction data for signing
|
|
100
|
+
*/
|
|
77
101
|
function signAuthorizations(preparedTransaction) {
|
|
78
|
-
return (0,
|
|
102
|
+
return (0, utils_1.signAuthorizations)(config, preparedTransaction);
|
|
79
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* Sign a message (EIP-191)
|
|
106
|
+
* @param message Message to sign
|
|
107
|
+
* @param chain Chain to sign the message on
|
|
108
|
+
* @param signers Signers to use for signing
|
|
109
|
+
* @returns signature
|
|
110
|
+
*/
|
|
111
|
+
function signMessage(message, chain, signers) {
|
|
112
|
+
return (0, utils_1.signMessage)(config, message, chain, signers);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Sign a typed data (EIP-712)
|
|
116
|
+
* @param parameters Typed data parameters
|
|
117
|
+
* @param chain Chain to sign the typed data on
|
|
118
|
+
* @param signers Signers to use for signing
|
|
119
|
+
* @returns signature
|
|
120
|
+
*/
|
|
121
|
+
function signTypedData(parameters, chain, signers) {
|
|
122
|
+
return (0, utils_1.signTypedData)(config, parameters, chain, signers);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Submit a transaction
|
|
126
|
+
* @param signedTransaction Signed transaction data
|
|
127
|
+
* @param authorizations EIP-7702 authorizations to submit (optional)
|
|
128
|
+
* @returns transaction result object (an intent ID or a UserOp hash)
|
|
129
|
+
* @see {@link signTransaction} to sign the transaction data
|
|
130
|
+
* @see {@link signAuthorizations} to sign the required EIP-7702 authorizations
|
|
131
|
+
*/
|
|
80
132
|
function submitTransaction(signedTransaction, authorizations) {
|
|
81
|
-
return (0,
|
|
133
|
+
return (0, utils_1.submitTransaction)(config, signedTransaction, authorizations ?? []);
|
|
82
134
|
}
|
|
83
135
|
/**
|
|
84
136
|
* Sign and send a transaction
|
|
@@ -122,18 +174,28 @@ async function createRhinestoneAccount(config) {
|
|
|
122
174
|
function getMaxSpendableAmount(chain, tokenAddress, gasUnits) {
|
|
123
175
|
return (0, execution_1.getMaxSpendableAmount)(config, chain, tokenAddress, gasUnits);
|
|
124
176
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
177
|
+
/**
|
|
178
|
+
* Get account owners (ECDSA)
|
|
179
|
+
* @param chain Chain to get the owners on
|
|
180
|
+
* @returns Account owners
|
|
181
|
+
*/
|
|
128
182
|
function getOwners(chain) {
|
|
129
183
|
const account = getAddress();
|
|
130
184
|
return (0, modules_1.getOwners)(account, chain, config.provider);
|
|
131
185
|
}
|
|
186
|
+
/**
|
|
187
|
+
* Get account validator modules
|
|
188
|
+
* @param chain Chain to get the validators on
|
|
189
|
+
* @returns List of account validators
|
|
190
|
+
*/
|
|
132
191
|
function getValidators(chain) {
|
|
133
192
|
const accountType = config.account?.type || 'nexus';
|
|
134
193
|
const account = getAddress();
|
|
135
194
|
return (0, modules_1.getValidators)(accountType, account, chain, config.provider);
|
|
136
195
|
}
|
|
196
|
+
function getSessionDetails(sessions, sessionIndex, signature) {
|
|
197
|
+
return (0, smart_session_1.getSessionDetails)(config, sessions, sessionIndex, signature);
|
|
198
|
+
}
|
|
137
199
|
return {
|
|
138
200
|
config,
|
|
139
201
|
deploy,
|
|
@@ -141,6 +203,8 @@ async function createRhinestoneAccount(config) {
|
|
|
141
203
|
prepareTransaction,
|
|
142
204
|
signTransaction,
|
|
143
205
|
signAuthorizations,
|
|
206
|
+
signMessage,
|
|
207
|
+
signTypedData,
|
|
144
208
|
submitTransaction,
|
|
145
209
|
sendTransaction,
|
|
146
210
|
waitForExecution,
|
|
@@ -15,7 +15,7 @@ const index_1 = require("./index");
|
|
|
15
15
|
},
|
|
16
16
|
};
|
|
17
17
|
const setup = (0, index_1.getSetup)(config);
|
|
18
|
-
(0, vitest_1.expect)(setup.validators[0].address).toBe('
|
|
18
|
+
(0, vitest_1.expect)(setup.validators[0].address).toBe('0x20C008719Ba9D8aA14C7d07D122cd5E965aA8da5');
|
|
19
19
|
(0, vitest_1.expect)(setup.validators[0].type).toBe(1n);
|
|
20
20
|
});
|
|
21
21
|
(0, vitest_1.test)('should use webauthn validator for passkey owners', () => {
|
|
@@ -10,7 +10,7 @@ exports.getValidator = getValidator;
|
|
|
10
10
|
exports.getMockSignature = getMockSignature;
|
|
11
11
|
const viem_1 = require("viem");
|
|
12
12
|
const common_1 = require("../common");
|
|
13
|
-
const OWNABLE_VALIDATOR_ADDRESS = '
|
|
13
|
+
const OWNABLE_VALIDATOR_ADDRESS = '0x20C008719Ba9D8aA14C7d07D122cd5E965aA8da5';
|
|
14
14
|
exports.OWNABLE_VALIDATOR_ADDRESS = OWNABLE_VALIDATOR_ADDRESS;
|
|
15
15
|
const WEBAUTHN_VALIDATOR_ADDRESS = '0x0000000000578c4cB0e472a5462da43C495C3F33';
|
|
16
16
|
exports.WEBAUTHN_VALIDATOR_ADDRESS = WEBAUTHN_VALIDATOR_ADDRESS;
|
|
@@ -14,7 +14,7 @@ const core_1 = require("./core");
|
|
|
14
14
|
});
|
|
15
15
|
(0, vitest_1.expect)(validator.type).toEqual(common_1.MODULE_TYPE_ID_VALIDATOR);
|
|
16
16
|
(0, vitest_1.expect)((0, viem_1.isAddress)(validator.address)).toEqual(true);
|
|
17
|
-
(0, vitest_1.expect)(validator.address).toEqual('
|
|
17
|
+
(0, vitest_1.expect)(validator.address).toEqual('0x20C008719Ba9D8aA14C7d07D122cd5E965aA8da5');
|
|
18
18
|
(0, vitest_1.expect)(validator.initData).toEqual('0x000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001000000000000000000000000f6c02c78ded62973b43bfa523b247da099486936');
|
|
19
19
|
});
|
|
20
20
|
(0, vitest_1.test)('ECDSA: two addresses', () => {
|
|
@@ -24,7 +24,7 @@ const core_1 = require("./core");
|
|
|
24
24
|
});
|
|
25
25
|
(0, vitest_1.expect)(validator.type).toEqual(common_1.MODULE_TYPE_ID_VALIDATOR);
|
|
26
26
|
(0, vitest_1.expect)((0, viem_1.isAddress)(validator.address)).toEqual(true);
|
|
27
|
-
(0, vitest_1.expect)(validator.address).toEqual('
|
|
27
|
+
(0, vitest_1.expect)(validator.address).toEqual('0x20C008719Ba9D8aA14C7d07D122cd5E965aA8da5');
|
|
28
28
|
(0, vitest_1.expect)(validator.initData).toEqual('0x0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7000000000000000000000000f6c02c78ded62973b43bfa523b247da099486936');
|
|
29
29
|
});
|
|
30
30
|
(0, vitest_1.test)('ECDSA: three addresses, custom threshold', () => {
|
|
@@ -35,7 +35,7 @@ const core_1 = require("./core");
|
|
|
35
35
|
});
|
|
36
36
|
(0, vitest_1.expect)(validator.type).toEqual(common_1.MODULE_TYPE_ID_VALIDATOR);
|
|
37
37
|
(0, vitest_1.expect)((0, viem_1.isAddress)(validator.address)).toEqual(true);
|
|
38
|
-
(0, vitest_1.expect)(validator.address).toEqual('
|
|
38
|
+
(0, vitest_1.expect)(validator.address).toEqual('0x20C008719Ba9D8aA14C7d07D122cd5E965aA8da5');
|
|
39
39
|
(0, vitest_1.expect)(validator.initData).toEqual('0x0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000030000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7000000000000000000000000c27b7578151c5ef713c62c65db09763d57ac3596000000000000000000000000f6c02c78ded62973b43bfa523b247da099486936');
|
|
40
40
|
});
|
|
41
41
|
(0, vitest_1.test)('Passkey', () => {
|
|
@@ -294,9 +294,9 @@ function getPolicyData(policy) {
|
|
|
294
294
|
case 'time-frame': {
|
|
295
295
|
return {
|
|
296
296
|
policy: TIME_FRAME_POLICY_ADDRESS,
|
|
297
|
-
initData: (0, viem_1.encodePacked)(['
|
|
298
|
-
|
|
299
|
-
|
|
297
|
+
initData: (0, viem_1.encodePacked)(['uint48', 'uint48'], [
|
|
298
|
+
Math.floor(policy.validUntil / 1000),
|
|
299
|
+
Math.floor(policy.validAfter / 1000),
|
|
300
300
|
]),
|
|
301
301
|
};
|
|
302
302
|
}
|