@charterlabs/rhinestone-sdk 0.3.8 → 0.4.1
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/README.md +89 -1
- package/dist/src/accounts/index.d.ts +6 -3
- package/dist/src/accounts/index.d.ts.map +1 -1
- package/dist/src/accounts/index.js +8 -2
- package/dist/src/accounts/json-rpc/providers.d.ts.map +1 -1
- package/dist/src/accounts/json-rpc/providers.js +3 -3
- package/dist/src/accounts/safe.d.ts.map +1 -1
- package/dist/src/accounts/safe.js +4 -1
- package/dist/src/accounts/signing/common.d.ts +10 -5
- package/dist/src/accounts/signing/common.d.ts.map +1 -1
- package/dist/src/accounts/signing/message.d.ts +3 -1
- package/dist/src/accounts/signing/message.d.ts.map +1 -1
- package/dist/src/accounts/startale.d.ts +3 -2
- package/dist/src/accounts/startale.d.ts.map +1 -1
- package/dist/src/accounts/startale.js +108 -19
- package/dist/src/accounts/utils.d.ts +1 -1
- package/dist/src/accounts/utils.d.ts.map +1 -1
- package/dist/src/auth/provider.d.ts +7 -0
- package/dist/src/auth/provider.d.ts.map +1 -0
- package/dist/src/auth/provider.js +41 -0
- package/dist/src/errors/index.d.ts +2 -2
- package/dist/src/errors/index.d.ts.map +1 -1
- package/dist/src/errors/index.js +2 -1
- package/dist/src/execution/error.d.ts +9 -1
- package/dist/src/execution/error.d.ts.map +1 -1
- package/dist/src/execution/error.js +12 -1
- package/dist/src/execution/index.d.ts +6 -4
- package/dist/src/execution/index.d.ts.map +1 -1
- package/dist/src/execution/index.js +18 -15
- package/dist/src/execution/utils.d.ts +31 -7
- package/dist/src/execution/utils.d.ts.map +1 -1
- package/dist/src/execution/utils.js +317 -46
- package/dist/src/index.d.ts +5 -5
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +13 -11
- package/dist/src/jwt-server/digest.d.ts +11 -0
- package/dist/src/jwt-server/digest.d.ts.map +1 -0
- package/dist/src/jwt-server/digest.js +22 -0
- package/dist/src/jwt-server/express.d.ts +16 -0
- package/dist/src/jwt-server/express.d.ts.map +1 -0
- package/dist/src/jwt-server/express.js +24 -0
- package/dist/src/jwt-server/handlers.d.ts +10 -0
- package/dist/src/jwt-server/handlers.d.ts.map +1 -0
- package/dist/src/jwt-server/handlers.js +41 -0
- package/dist/src/jwt-server/index.d.ts +8 -0
- package/dist/src/jwt-server/index.d.ts.map +1 -0
- package/dist/src/jwt-server/index.js +18 -0
- package/dist/src/jwt-server/jcs.d.ts +12 -0
- package/dist/src/jwt-server/jcs.d.ts.map +1 -0
- package/dist/src/jwt-server/jcs.js +60 -0
- package/dist/src/jwt-server/signer.d.ts +18 -0
- package/dist/src/jwt-server/signer.d.ts.map +1 -0
- package/dist/src/jwt-server/signer.js +71 -0
- package/dist/src/jwt-server/sponsorship.d.ts +19 -0
- package/dist/src/jwt-server/sponsorship.d.ts.map +1 -0
- package/dist/src/jwt-server/sponsorship.js +56 -0
- package/dist/src/jwt-server/web.d.ts +4 -0
- package/dist/src/jwt-server/web.d.ts.map +1 -0
- package/dist/src/jwt-server/web.js +27 -0
- package/dist/src/modules/validators/index.d.ts +2 -2
- package/dist/src/modules/validators/index.d.ts.map +1 -1
- package/dist/src/modules/validators/index.js +6 -1
- package/dist/src/modules/validators/policies/claim/permit2.d.ts +55 -0
- package/dist/src/modules/validators/policies/claim/permit2.d.ts.map +1 -0
- package/dist/src/modules/validators/policies/claim/permit2.js +239 -0
- package/dist/src/modules/validators/policies/claim/types.d.ts +12 -0
- package/dist/src/modules/validators/policies/claim/types.d.ts.map +1 -0
- package/dist/src/modules/validators/policies/claim/types.js +18 -0
- package/dist/src/modules/validators/smart-sessions.d.ts +30 -6
- package/dist/src/modules/validators/smart-sessions.d.ts.map +1 -1
- package/dist/src/modules/validators/smart-sessions.js +135 -12
- package/dist/src/orchestrator/client.d.ts +9 -4
- package/dist/src/orchestrator/client.d.ts.map +1 -1
- package/dist/src/orchestrator/client.js +29 -17
- package/dist/src/orchestrator/consts.d.ts +3 -2
- package/dist/src/orchestrator/consts.d.ts.map +1 -1
- package/dist/src/orchestrator/consts.js +4 -2
- package/dist/src/orchestrator/index.d.ts +4 -3
- package/dist/src/orchestrator/index.d.ts.map +1 -1
- package/dist/src/orchestrator/index.js +2 -2
- package/dist/src/orchestrator/registry.d.ts +2 -1
- package/dist/src/orchestrator/registry.d.ts.map +1 -1
- package/dist/src/orchestrator/registry.js +17 -1
- package/dist/src/orchestrator/types.d.ts +30 -2
- package/dist/src/orchestrator/types.d.ts.map +1 -1
- package/dist/src/types.d.ts +99 -10
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/utils/index.d.ts +3 -9
- package/dist/src/utils/index.d.ts.map +1 -1
- package/package.json +18 -4
- package/dist/src/accounts/index.test.d.ts +0 -2
- package/dist/src/accounts/index.test.d.ts.map +0 -1
- package/dist/src/accounts/index.test.js +0 -33
- 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 -35
- 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 -43
- package/dist/src/accounts/kernel.test.d.ts +0 -2
- package/dist/src/accounts/kernel.test.d.ts.map +0 -1
- package/dist/src/accounts/kernel.test.js +0 -132
- package/dist/src/accounts/nexus.test.d.ts +0 -2
- package/dist/src/accounts/nexus.test.d.ts.map +0 -1
- package/dist/src/accounts/nexus.test.js +0 -118
- package/dist/src/accounts/safe.test.d.ts +0 -2
- package/dist/src/accounts/safe.test.d.ts.map +0 -1
- package/dist/src/accounts/safe.test.js +0 -118
- package/dist/src/accounts/signing/passkeys.test.d.ts +0 -2
- package/dist/src/accounts/signing/passkeys.test.d.ts.map +0 -1
- package/dist/src/accounts/signing/passkeys.test.js +0 -88
- package/dist/src/accounts/startale.test.d.ts +0 -2
- package/dist/src/accounts/startale.test.d.ts.map +0 -1
- package/dist/src/accounts/startale.test.js +0 -92
- package/dist/src/accounts/utils.test.d.ts +0 -2
- package/dist/src/accounts/utils.test.d.ts.map +0 -1
- package/dist/src/accounts/utils.test.js +0 -49
- package/dist/src/actions/ecdsa.test.d.ts +0 -2
- package/dist/src/actions/ecdsa.test.d.ts.map +0 -1
- package/dist/src/actions/ecdsa.test.js +0 -99
- package/dist/src/actions/passkeys.test.d.ts +0 -2
- package/dist/src/actions/passkeys.test.d.ts.map +0 -1
- package/dist/src/actions/passkeys.test.js +0 -54
- package/dist/src/actions/recovery.test.d.ts +0 -2
- package/dist/src/actions/recovery.test.d.ts.map +0 -1
- package/dist/src/actions/recovery.test.js +0 -168
- package/dist/src/execution/utils.test.d.ts +0 -2
- package/dist/src/execution/utils.test.d.ts.map +0 -1
- package/dist/src/execution/utils.test.js +0 -49
- package/dist/src/modules/index.test.d.ts +0 -2
- package/dist/src/modules/index.test.d.ts.map +0 -1
- package/dist/src/modules/index.test.js +0 -81
- package/dist/src/modules/validators/core.test.d.ts +0 -2
- package/dist/src/modules/validators/core.test.d.ts.map +0 -1
- package/dist/src/modules/validators/core.test.js +0 -101
- package/dist/src/orchestrator/registry.test.d.ts +0 -2
- package/dist/src/orchestrator/registry.test.d.ts.map +0 -1
- package/dist/src/orchestrator/registry.test.js +0 -154
- package/dist/test/consts.d.ts +0 -10
- package/dist/test/consts.d.ts.map +0 -1
- package/dist/test/consts.js +0 -22
- package/dist/test/utils/utils.d.ts +0 -5
- package/dist/test/utils/utils.d.ts.map +0 -1
- package/dist/test/utils/utils.js +0 -20
package/README.md
CHANGED
|
@@ -31,6 +31,94 @@ npm install viem @rhinestone/sdk
|
|
|
31
31
|
bun install viem @rhinestone/sdk
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
+
## Authentication
|
|
35
|
+
|
|
36
|
+
The SDK supports two authentication modes: **API key** and **JWT**.
|
|
37
|
+
|
|
38
|
+
### API Key
|
|
39
|
+
|
|
40
|
+
Pass the API key from the [Rhinestone dashboard](https://dashboard.rhinestone.dev):
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
const rhinestone = new RhinestoneSDK({
|
|
44
|
+
auth: {
|
|
45
|
+
mode: 'apiKey',
|
|
46
|
+
apiKey: 'your-api-key',
|
|
47
|
+
},
|
|
48
|
+
})
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### JWT (Experimental)
|
|
52
|
+
|
|
53
|
+
JWT authentication uses RS256-signed tokens for fine-grained access control. There are two integration patterns depending on your architecture:
|
|
54
|
+
|
|
55
|
+
#### Client-server (SDK runs in browser/client)
|
|
56
|
+
|
|
57
|
+
When the SDK runs on the client and a separate backend holds the signing key, fetch tokens via HTTP:
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
const rhinestone = new RhinestoneSDK({
|
|
61
|
+
auth: {
|
|
62
|
+
mode: 'experimental_jwt',
|
|
63
|
+
accessToken: async () => {
|
|
64
|
+
const res = await fetch('/api/auth/token')
|
|
65
|
+
const { token } = await res.json()
|
|
66
|
+
return token
|
|
67
|
+
},
|
|
68
|
+
// Only needed for sponsored intents:
|
|
69
|
+
getIntentExtensionToken: async (intentInput) => {
|
|
70
|
+
const res = await fetch('/api/auth/extension-token', {
|
|
71
|
+
method: 'POST',
|
|
72
|
+
headers: { 'Content-Type': 'application/json' },
|
|
73
|
+
body: JSON.stringify({ intentInput }),
|
|
74
|
+
})
|
|
75
|
+
const { token } = await res.json()
|
|
76
|
+
return token
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
})
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Your backend is responsible for signing JWTs with the correct claims. See the [JWT documentation](https://docs.rhinestone.dev) for the required token format.
|
|
83
|
+
|
|
84
|
+
#### Same-host (SDK and signing key on the same server)
|
|
85
|
+
|
|
86
|
+
When the SDK runs server-side with access to the private key, use `createJwtSigner` to sign tokens in-process without an HTTP round-trip:
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
import { createJwtSigner } from '@rhinestone/sdk/jwt-server'
|
|
90
|
+
|
|
91
|
+
const signer = createJwtSigner({
|
|
92
|
+
jwt: {
|
|
93
|
+
privateKey: myJwk, // RS256 private key in JWK format
|
|
94
|
+
integratorId: 'int_abc',
|
|
95
|
+
projectId: 'proj_xyz',
|
|
96
|
+
appId: 'app_prod',
|
|
97
|
+
keyId: 'key_1',
|
|
98
|
+
},
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
const rhinestone = new RhinestoneSDK({
|
|
102
|
+
auth: { mode: 'experimental_jwt', ...signer },
|
|
103
|
+
})
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
`createJwtSigner` returns `{ accessToken, getIntentExtensionToken }` — the same shape as the `auth` config, so you can spread it directly. It handles all claim structure, key caching, and intent digest computation internally.
|
|
107
|
+
|
|
108
|
+
To control which intents your backend sponsors, pass `shouldSponsor` filters. The signer checks them before signing — denied requests throw a `SponsorshipDeniedError`:
|
|
109
|
+
|
|
110
|
+
```ts
|
|
111
|
+
import { createJwtSigner } from '@rhinestone/sdk/jwt-server'
|
|
112
|
+
|
|
113
|
+
const signer = createJwtSigner({
|
|
114
|
+
// ...
|
|
115
|
+
shouldSponsor: {
|
|
116
|
+
chain: ({ id }) => [1, 8453, 10].includes(id),
|
|
117
|
+
account: async (address) => isUser(address),
|
|
118
|
+
},
|
|
119
|
+
})
|
|
120
|
+
```
|
|
121
|
+
|
|
34
122
|
## Quickstart
|
|
35
123
|
|
|
36
124
|
Create a smart account:
|
|
@@ -38,7 +126,7 @@ Create a smart account:
|
|
|
38
126
|
```ts
|
|
39
127
|
import { RhinestoneSDK } from '@rhinestone/sdk'
|
|
40
128
|
|
|
41
|
-
const rhinestone = new RhinestoneSDK()
|
|
129
|
+
const rhinestone = new RhinestoneSDK({ apiKey: 'your-api-key' })
|
|
42
130
|
const account = await rhinestone.createAccount({
|
|
43
131
|
owners: {
|
|
44
132
|
type: 'ecdsa',
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { type Account, type Chain, type HashTypedDataParameters, type Hex, type PublicClient, type TypedData } from 'viem';
|
|
2
2
|
import type { Module } from '../modules/common';
|
|
3
|
+
import type { ResolvedSessionSignerSet } from '../modules/validators/smart-sessions';
|
|
3
4
|
import type { AccountProviderConfig, Call, OwnerSet, RhinestoneConfig, SignerSet } from '../types';
|
|
4
5
|
import { AccountConfigurationNotSupportedError, AccountError, Eip712DomainNotAvailableError, Eip7702AccountMustHaveEoaError, Eip7702NotSupportedForAccountError, EoaAccountMustHaveAccountError, EoaSigningMethodNotConfiguredError, EoaSigningNotSupportedError, ExistingEip7702AccountsNotSupportedError, FactoryArgsNotAvailableError, isAccountError, ModuleInstallationNotSupportedError, OwnersFieldRequiredError, SigningNotSupportedForAccountError, SmartSessionsNotEnabledError, WalletClientNoConnectedAccountError } from './error';
|
|
5
6
|
import { type ValidatorConfig } from './utils';
|
|
7
|
+
type InternalSignerSet = SignerSet | ResolvedSessionSignerSet;
|
|
6
8
|
declare function getInitCode(config: RhinestoneConfig): {
|
|
7
9
|
address: import("viem").Address;
|
|
8
10
|
} | {
|
|
@@ -31,12 +33,13 @@ declare function getModuleInstallationCalls(config: RhinestoneConfig, module: Mo
|
|
|
31
33
|
declare function getModuleUninstallationCalls(config: RhinestoneConfig, module: Module): Call[];
|
|
32
34
|
declare function getAddress(config: RhinestoneConfig): `0x${string}`;
|
|
33
35
|
declare function checkAddress(config: RhinestoneConfig): boolean;
|
|
34
|
-
declare function getEip1271Signature(config: RhinestoneConfig, signers:
|
|
35
|
-
declare function getEmissarySignature(config: RhinestoneConfig, signers:
|
|
36
|
-
declare function getTypedDataPackedSignature<typedData extends TypedData | Record<string, unknown> = TypedData, primaryType extends keyof typedData | 'EIP712Domain' = keyof typedData>(config: RhinestoneConfig, signers:
|
|
36
|
+
declare function getEip1271Signature(config: RhinestoneConfig, signers: InternalSignerSet | undefined, chain: Chain, validator: ValidatorConfig, hash: Hex, transformSignature?: (signature: Hex) => Hex): Promise<Hex>;
|
|
37
|
+
declare function getEmissarySignature(config: RhinestoneConfig, signers: InternalSignerSet | undefined, chain: Chain, hash: Hex, transformSignature?: (signature: Hex) => Hex): Promise<Hex>;
|
|
38
|
+
declare function getTypedDataPackedSignature<typedData extends TypedData | Record<string, unknown> = TypedData, primaryType extends keyof typedData | 'EIP712Domain' = keyof typedData>(config: RhinestoneConfig, signers: InternalSignerSet | undefined, chain: Chain, validator: ValidatorConfig, parameters: HashTypedDataParameters<typedData, primaryType>, transformSignature?: (signature: Hex) => Hex): Promise<Hex>;
|
|
37
39
|
declare function isDeployed(config: RhinestoneConfig, chain: Chain): Promise<boolean>;
|
|
38
40
|
declare function deploy(config: RhinestoneConfig, chain: Chain, params?: {
|
|
39
41
|
sponsored?: boolean;
|
|
42
|
+
eip7702InitSignature?: Hex;
|
|
40
43
|
}): Promise<boolean>;
|
|
41
44
|
declare function setup(config: RhinestoneConfig, chain: Chain): Promise<boolean>;
|
|
42
45
|
declare function deployStandaloneWithEoa(chain: Chain, config: RhinestoneConfig, deployer: Account): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../accounts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,KAAK,EAMV,KAAK,uBAAuB,EAC5B,KAAK,GAAG,EAER,KAAK,YAAY,EAEjB,KAAK,SAAS,EAGf,MAAM,MAAM,CAAA;AAUb,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAG/C,OAAO,KAAK,EACV,qBAAqB,EACrB,IAAI,EACJ,QAAQ,EACR,gBAAgB,EAChB,SAAS,EACV,MAAM,UAAU,CAAA;AACjB,OAAO,EACL,qCAAqC,EACrC,YAAY,EACZ,6BAA6B,EAC7B,8BAA8B,EAC9B,kCAAkC,EAClC,8BAA8B,EAC9B,kCAAkC,EAClC,2BAA2B,EAC3B,wCAAwC,EACxC,4BAA4B,E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AkB,EAClB,MAAM,EACN,UAAU,EACV,MAAM,EACN,KAAK,EACL,kBAAkB,EAClB,eAAe,EACf,uBAAuB,EACvB,mBAAmB,EACnB,oBAAoB,EACpB,2BAA2B,EAC3B,uBAAuB,EAEvB,cAAc,EACd,YAAY,EACZ,qCAAqC,EACrC,6BAA6B,EAC7B,8BAA8B,EAC9B,kCAAkC,EAClC,8BAA8B,EAC9B,kCAAkC,EAClC,2BAA2B,EAC3B,wCAAwC,EACxC,4BAA4B,EAC5B,mCAAmC,EACnC,wBAAwB,EACxB,kCAAkC,EAClC,4BAA4B,EAC5B,mCAAmC,GACpC,CAAA"}
|
|
@@ -434,7 +434,7 @@ async function deploy(config, chain, params) {
|
|
|
434
434
|
await deployWithBundler(chain, config);
|
|
435
435
|
}
|
|
436
436
|
else {
|
|
437
|
-
await deployWithIntent(chain, config, params?.sponsored ?? false);
|
|
437
|
+
await deployWithIntent(chain, config, params?.sponsored ?? false, params?.eip7702InitSignature);
|
|
438
438
|
}
|
|
439
439
|
return true;
|
|
440
440
|
}
|
|
@@ -504,7 +504,7 @@ async function setup(config, chain) {
|
|
|
504
504
|
await (0, execution_1.waitForExecution)(config, result, true);
|
|
505
505
|
return true;
|
|
506
506
|
}
|
|
507
|
-
async function deployWithIntent(chain, config, sponsored) {
|
|
507
|
+
async function deployWithIntent(chain, config, sponsored, eip7702InitSignature) {
|
|
508
508
|
const publicClient = (0, viem_1.createPublicClient)({
|
|
509
509
|
chain,
|
|
510
510
|
transport: (0, utils_1.createTransport)(chain, config.provider),
|
|
@@ -515,11 +515,17 @@ async function deployWithIntent(chain, config, sponsored) {
|
|
|
515
515
|
// Already deployed
|
|
516
516
|
return;
|
|
517
517
|
}
|
|
518
|
+
// For EIP-7702 accounts, auto-sign if no signature was provided
|
|
519
|
+
let initSignature = eip7702InitSignature;
|
|
520
|
+
if (!initSignature && is7702(config)) {
|
|
521
|
+
initSignature = await signEip7702InitData(config);
|
|
522
|
+
}
|
|
518
523
|
const result = await (0, execution_1.sendTransaction)(config, {
|
|
519
524
|
sourceChains: [chain],
|
|
520
525
|
targetChain: chain,
|
|
521
526
|
calls: [],
|
|
522
527
|
sponsored,
|
|
528
|
+
eip7702InitSignature: initSignature,
|
|
523
529
|
});
|
|
524
530
|
await (0, execution_1.waitForExecution)(config, result, true);
|
|
525
531
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../../../accounts/json-rpc/providers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../../../accounts/json-rpc/providers.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAIxD,iBAAS,aAAa,CAAC,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAiBtE;AAED,iBAAS,YAAY,CACnB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC3B,MAAM,GAAG,SAAS,CAEpB;AAED,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,CAAA"}
|
|
@@ -36,19 +36,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.getAlchemyUrl = getAlchemyUrl;
|
|
37
37
|
exports.getCustomUrl = getCustomUrl;
|
|
38
38
|
const sharedConfigs = __importStar(require("@rhinestone/shared-configs"));
|
|
39
|
+
const ALCHEMY_API_KEY_PLACEHOLDER = '$' + '{ALCHEMY_API_KEY}';
|
|
39
40
|
function getAlchemyUrl(chainId, apiKey) {
|
|
40
41
|
const providers = sharedConfigs.providerRegistry ||
|
|
41
42
|
sharedConfigs.ProviderRegistry;
|
|
42
43
|
const urlTemplate = providers.Alchemy.url_template;
|
|
43
|
-
const mapping = providers.Alchemy
|
|
44
|
-
.chain_mapping;
|
|
44
|
+
const mapping = providers.Alchemy.chain_mapping;
|
|
45
45
|
const chainParam = mapping[chainId];
|
|
46
46
|
if (!chainParam) {
|
|
47
47
|
throw new Error(`Unsupported chain: ${chainId}`);
|
|
48
48
|
}
|
|
49
49
|
return urlTemplate
|
|
50
50
|
.replace('{{chain_param}}', chainParam)
|
|
51
|
-
.split(
|
|
51
|
+
.split(ALCHEMY_API_KEY_PLACEHOLDER)
|
|
52
52
|
.join(apiKey);
|
|
53
53
|
}
|
|
54
54
|
function getCustomUrl(chainId, urls) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"safe.d.ts","sourceRoot":"","sources":["../../../accounts/safe.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,GAAG,EACR,KAAK,OAAO,EACZ,KAAK,KAAK,EAOV,KAAK,GAAG,EAER,KAAK,YAAY,EAKlB,MAAM,MAAM,CAAA;AACb,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,0BAA0B,EAEhC,MAAM,0BAA0B,CAAA;AAGjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAM/C,OAAO,KAAK,EAAE,QAAQ,EAAE,uBAAuB,EAAe,MAAM,UAAU,CAAA;AAM9E,OAAO,EAAoC,KAAK,eAAe,EAAE,MAAM,SAAS,CAAA;AAoBhF,iBAAS,aAAa,CAAC,MAAM,EAAE,uBAAuB;;;;;;SAmGrD;AAED,iBAAS,eAAe,CAAC,MAAM,EAAE,uBAAuB;;;;;;EAgFvD;AAED,iBAAS,UAAU,CAAC,MAAM,EAAE,uBAAuB,
|
|
1
|
+
{"version":3,"file":"safe.d.ts","sourceRoot":"","sources":["../../../accounts/safe.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,GAAG,EACR,KAAK,OAAO,EACZ,KAAK,KAAK,EAOV,KAAK,GAAG,EAER,KAAK,YAAY,EAKlB,MAAM,MAAM,CAAA;AACb,OAAO,EAIL,KAAK,YAAY,EACj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|
|
186
186
|
function getAddress(config) {
|
|
187
187
|
const deployArgs = getDeployArgs(config);
|
|
188
188
|
if (!deployArgs) {
|
|
189
|
+
if (config.initData?.address) {
|
|
190
|
+
return config.initData.address;
|
|
191
|
+
}
|
|
189
192
|
throw new Error('Cannot derive address: deploy args not available');
|
|
190
193
|
}
|
|
191
194
|
const { factory, implementation, salt } = deployArgs;
|
|
@@ -199,7 +202,7 @@ function getAddress(config) {
|
|
|
199
202
|
return address;
|
|
200
203
|
}
|
|
201
204
|
function getEip712Domain(config, chain) {
|
|
202
|
-
if (config.initData) {
|
|
205
|
+
if (config.initData && !('factory' in config.initData)) {
|
|
203
206
|
throw new error_1.Eip712DomainNotAvailableError('Existing Safe-7579 accounts are not yet supported');
|
|
204
207
|
}
|
|
205
208
|
return {
|
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
import type { WebAuthnP256 } from 'ox';
|
|
2
1
|
import { type Account, type Address, type Chain, type Hex } from 'viem';
|
|
3
2
|
import type { WebAuthnAccount } from 'viem/account-abstraction';
|
|
3
|
+
import { type ResolvedSessionSignerSet } from '../../modules/validators/smart-sessions';
|
|
4
4
|
import type { OwnerSet, SignerSet } from '../../types';
|
|
5
5
|
declare function convertOwnerSetToSignerSet(owners: OwnerSet): SignerSet;
|
|
6
|
+
type WebAuthnSignMetadata = {
|
|
7
|
+
authenticatorData: Hex;
|
|
8
|
+
challengeIndex?: number | undefined;
|
|
9
|
+
clientDataJSON: string;
|
|
10
|
+
typeIndex?: number | undefined;
|
|
11
|
+
userVerificationRequired?: boolean | undefined;
|
|
12
|
+
};
|
|
6
13
|
type SigningFunctions<T> = {
|
|
7
14
|
signEcdsa: (account: Account, params: T, updateV: boolean) => Promise<Hex>;
|
|
8
15
|
signPasskey: (account: WebAuthnAccount, params: T) => Promise<{
|
|
9
|
-
webauthn:
|
|
16
|
+
webauthn: WebAuthnSignMetadata;
|
|
10
17
|
signature: Hex;
|
|
11
18
|
}>;
|
|
12
19
|
};
|
|
@@ -14,9 +21,7 @@ declare function signWithMultiFactorAuth<T>(signers: SignerSet & {
|
|
|
14
21
|
type: 'owner';
|
|
15
22
|
kind: 'multi-factor';
|
|
16
23
|
}, chain: Chain, address: Address, params: T, isUserOpHash: boolean, signMain: (signers: SignerSet, chain: Chain, address: Address, params: T, isUserOpHash: boolean) => Promise<Hex>): Promise<Hex>;
|
|
17
|
-
declare function signWithSession(signers: SignerSet
|
|
18
|
-
type: 'experimental_session';
|
|
19
|
-
}, chain: Chain, address: Address, hash: Hex, signMain: (signers: SignerSet, chain: Chain, address: Address, hash: Hex, isUserOpHash: boolean) => Promise<Hex>): Promise<Hex>;
|
|
24
|
+
declare function signWithSession(signers: ResolvedSessionSignerSet, chain: Chain, address: Address, hash: Hex, signMain: (signers: SignerSet, chain: Chain, address: Address, hash: Hex, isUserOpHash: boolean) => Promise<Hex>): Promise<Hex>;
|
|
20
25
|
declare function signWithGuardians<T>(signers: SignerSet & {
|
|
21
26
|
type: 'guardians';
|
|
22
27
|
}, params: T, signingFunctions: SigningFunctions<T>): Promise<Hex>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../../accounts/signing/common.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../../accounts/signing/common.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,OAAO,EACZ,KAAK,KAAK,EAMV,KAAK,GAAG,EAKT,MAAM,MAAM,CAAA;AACb,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAQ/D,OAAO,EAEL,KAAK,wBAAwB,EAC9B,MAAM,yCAAyC,CAAA;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAStD,iBAAS,0BAA0B,CAAC,MAAM,EAAE,QAAQ,GAAG,SAAS,CAkE/D;AAED,KAAK,oBA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AG,EACT,YAAY,EAAE,OAAO,KAClB,OAAO,CAAC,GAAG,CAAC,GAChB,OAAO,CAAC,GAAG,CAAC,CAiBd;AAED,iBAAe,iBAAiB,CAAC,CAAC,EAChC,OAAO,EAAE,SAAS,GAAG;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,EAC1C,MAAM,EAAE,CAAC,EACT,gBAAgB,EAAE,gBAAgB,CAAC,CAAC,CAAC,GACpC,OAAO,CAAC,GAAG,CAAC,CAOd;AAED,iBAAe,cAAc,CAAC,CAAC,EAC7B,OAAO,EAAE,SAAS,GAAG;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,EACtC,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,CAAC,EACT,gBAAgB,EAAE,gBAAgB,CAAC,CAAC,CAAC,EACrC,YAAY,EAAE,OAAO,EACrB,QAAQ,EAAE,CACR,OAAO,EAAE,SAAS,EAClB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,CAAC,EACT,YAAY,EAAE,OAAO,KAClB,OAAO,CAAC,GAAG,CAAC,GAChB,OAAO,CAAC,GAAG,CAAC,CAqFd;AAED,OAAO,EACL,0BAA0B,EAC1B,uBAAuB,EACvB,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,KAAK,gBAAgB,GACtB,CAAA"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { type Address, type Chain, type Hex } from 'viem';
|
|
2
|
+
import type { ResolvedSessionSignerSet } from '../../modules/validators/smart-sessions';
|
|
2
3
|
import type { SignerSet } from '../../types';
|
|
3
|
-
|
|
4
|
+
type InternalSignerSet = SignerSet | ResolvedSessionSignerSet;
|
|
5
|
+
declare function sign(signers: InternalSignerSet, chain: Chain, address: Address, hash: Hex, isUserOpHash: boolean): Promise<Hex>;
|
|
4
6
|
export { sign };
|
|
5
7
|
//# sourceMappingURL=message.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../../../accounts/signing/message.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,OAAO,EACZ,KAAK,KAAK,EAEV,KAAK,GAAG,EAGT,MAAM,MAAM,CAAA;AAEb,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAS5C,iBAAe,IAAI,CACjB,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../../../accounts/signing/message.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,OAAO,EACZ,KAAK,KAAK,EAEV,KAAK,GAAG,EAGT,MAAM,MAAM,CAAA;AAEb,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,yCAAyC,CAAA;AACvF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAS5C,KAAK,iBAAiB,GAAG,SAAS,GAAG,wBAAwB,CAAA;AAE7D,iBAAe,IAAI,CACjB,OAAO,EAAE,iBAAiB,EAC1B,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,GAAG,EACT,YAAY,EAAE,OAAO,GACpB,OAAO,CAAC,GAAG,CAAC,CA+Bd;AA4BD,OAAO,EAAE,IAAI,EAAE,CAAA"}
|
|
@@ -2,13 +2,14 @@ import type { Address, Chain, Hex, PublicClient } from 'viem';
|
|
|
2
2
|
import type { Module } from '../modules/common';
|
|
3
3
|
import type { OwnerSet, RhinestoneAccountConfig } from '../types';
|
|
4
4
|
import type { ValidatorConfig } from './utils';
|
|
5
|
+
declare const K1_DEFAULT_VALIDATOR_ADDRESS: Address;
|
|
5
6
|
declare function getDeployArgs(config: RhinestoneAccountConfig): {
|
|
6
7
|
factory: `0x${string}`;
|
|
7
8
|
factoryData: `0x${string}`;
|
|
8
9
|
salt: `0x${string}`;
|
|
9
10
|
implementation: `0x${string}`;
|
|
10
11
|
initializationCallData: `0x${string}`;
|
|
11
|
-
};
|
|
12
|
+
} | null;
|
|
12
13
|
declare function getAddress(config: RhinestoneAccountConfig): `0x${string}`;
|
|
13
14
|
declare function getEip712Domain(config: RhinestoneAccountConfig, chain: Chain): {
|
|
14
15
|
name: string;
|
|
@@ -21,5 +22,5 @@ declare function getInstallData(module: Module): `0x${string}`;
|
|
|
21
22
|
declare function packSignature(signature: Hex, validator: ValidatorConfig, transformSignature?: (signature: Hex) => Hex): Promise<`0x${string}`>;
|
|
22
23
|
declare function getSmartAccount(client: PublicClient, address: Address, owners: OwnerSet, validatorAddress: Address, sign: (hash: Hex) => Promise<Hex>): Promise<import("viem/_types/account-abstraction").SmartAccount<import("viem/_types/account-abstraction").SmartAccountImplementation<import("viem").Abi, "0.7">>>;
|
|
23
24
|
declare function getGuardianSmartAccount(client: PublicClient, address: Address, guardians: OwnerSet, validatorAddress: Address, sign: (hash: Hex) => Promise<Hex>): Promise<import("viem/_types/account-abstraction").SmartAccount<import("viem/_types/account-abstraction").SmartAccountImplementation<import("viem").Abi, "0.7">>>;
|
|
24
|
-
export { getEip712Domain, getInstallData, getAddress, packSignature, getDeployArgs, getSmartAccount, getGuardianSmartAccount, };
|
|
25
|
+
export { K1_DEFAULT_VALIDATOR_ADDRESS, getEip712Domain, getInstallData, getAddress, packSignature, getDeployArgs, getSmartAccount, getGuardianSmartAccount, };
|
|
25
26
|
//# sourceMappingURL=startale.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"startale.d.ts","sourceRoot":"","sources":["../../../accounts/startale.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"startale.d.ts","sourceRoot":"","sources":["../../../accounts/startale.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,MAAM,CAA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1_DEFAULT_VALIDATOR_ADDRESS = void 0;
|
|
3
4
|
exports.getEip712Domain = getEip712Domain;
|
|
4
5
|
exports.getInstallData = getInstallData;
|
|
5
6
|
exports.getAddress = getAddress;
|
|
@@ -9,19 +10,117 @@ exports.getSmartAccount = getSmartAccount;
|
|
|
9
10
|
exports.getGuardianSmartAccount = getGuardianSmartAccount;
|
|
10
11
|
const viem_1 = require("viem");
|
|
11
12
|
const modules_1 = require("../modules");
|
|
13
|
+
const core_1 = require("../modules/validators/core");
|
|
12
14
|
const error_1 = require("./error");
|
|
13
15
|
const nexus_1 = require("./nexus");
|
|
14
16
|
const K1_DEFAULT_VALIDATOR_ADDRESS = '0x00000072f286204bb934ed49d8969e86f7dec7b1';
|
|
17
|
+
exports.K1_DEFAULT_VALIDATOR_ADDRESS = K1_DEFAULT_VALIDATOR_ADDRESS;
|
|
15
18
|
const STARTALE_VERSION = '1.0.0';
|
|
16
19
|
const IMPLEMENTATION_ADDRESS = '0x000000b8f5f723a680d3d7ee624fe0bc84a6e05a';
|
|
17
20
|
const FACTORY_ADDRESS = '0x0000003b3e7b530b4f981ae80d9350392defef90';
|
|
18
21
|
const BOOTSTRAP_ADDRESS = '0x000000552a5fae3db7a8f3917c435448f49ba6a9';
|
|
19
22
|
const CREATION_CODE = '0x608060405261029d803803806100148161018c565b92833981016040828203126101885781516001600160a01b03811692909190838303610188576020810151906001600160401b03821161018857019281601f8501121561018857835161006e610069826101c5565b61018c565b9481865260208601936020838301011161018857815f926020809301865e8601015260017f754fd8b321c4649cb777ae6fdce7e89e9cceaa31a4f639795c7807eb7f1a27005d823b15610176577f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc80546001600160a01b031916821790557fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b5f80a282511561015e575f8091610146945190845af43d15610156573d91610137610069846101c5565b9283523d5f602085013e6101e0565b505b604051605e908161023f8239f35b6060916101e0565b50505034156101485763b398979f60e01b5f5260045ffd5b634c9c8ce360e01b5f5260045260245ffd5b5f80fd5b6040519190601f01601f191682016001600160401b038111838210176101b157604052565b634e487b7160e01b5f52604160045260245ffd5b6001600160401b0381116101b157601f01601f191660200190565b9061020457508051156101f557805190602001fd5b63d6bda27560e01b5f5260045ffd5b81511580610235575b610215575090565b639996b31560e01b5f9081526001600160a01b0391909116600452602490fd5b50803b1561020d56fe60806040523615605c575f8073ffffffffffffffffffffffffffffffffffffffff7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc5416368280378136915af43d5f803e156058573d5ff35b3d5ffd5b00';
|
|
20
23
|
function getDeployArgs(config) {
|
|
24
|
+
if (config.initData) {
|
|
25
|
+
if (!('factory' in config.initData)) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
const { factory, factoryData } = config.initData;
|
|
29
|
+
try {
|
|
30
|
+
const decoded = (0, viem_1.decodeFunctionData)({
|
|
31
|
+
abi: (0, viem_1.parseAbi)(['function createAccount(bytes,bytes32)']),
|
|
32
|
+
data: factoryData,
|
|
33
|
+
});
|
|
34
|
+
const initData = decoded.args[0];
|
|
35
|
+
const salt = decoded.args[1];
|
|
36
|
+
const initializationCallData = (0, viem_1.encodeFunctionData)({
|
|
37
|
+
abi: (0, viem_1.parseAbi)(['function initializeAccount(bytes)']),
|
|
38
|
+
functionName: 'initializeAccount',
|
|
39
|
+
args: [initData],
|
|
40
|
+
});
|
|
41
|
+
return {
|
|
42
|
+
factory,
|
|
43
|
+
factoryData,
|
|
44
|
+
salt,
|
|
45
|
+
implementation: IMPLEMENTATION_ADDRESS,
|
|
46
|
+
initializationCallData,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
21
53
|
const account = config.account;
|
|
22
54
|
const salt = account?.salt ?? viem_1.zeroHash;
|
|
23
55
|
const moduleSetup = (0, modules_1.getSetup)(config);
|
|
24
|
-
const
|
|
56
|
+
const ownerValidator = (0, core_1.getOwnerValidator)(config);
|
|
57
|
+
const isK1 = ownerValidator.address.toLowerCase() ===
|
|
58
|
+
K1_DEFAULT_VALIDATOR_ADDRESS.toLowerCase();
|
|
59
|
+
if (isK1 &&
|
|
60
|
+
config.owners &&
|
|
61
|
+
'accounts' in config.owners &&
|
|
62
|
+
config.owners.accounts.length > 1) {
|
|
63
|
+
throw new error_1.AccountConfigurationNotSupportedError('K1 validator only supports a single owner', 'startale');
|
|
64
|
+
}
|
|
65
|
+
const initData = isK1
|
|
66
|
+
? getK1InitData(config, moduleSetup)
|
|
67
|
+
: getOwnableInitData(moduleSetup);
|
|
68
|
+
const factoryData = (0, viem_1.encodeFunctionData)({
|
|
69
|
+
abi: (0, viem_1.parseAbi)(['function createAccount(bytes,bytes32)']),
|
|
70
|
+
functionName: 'createAccount',
|
|
71
|
+
args: [initData, salt],
|
|
72
|
+
});
|
|
73
|
+
const initializationCallData = (0, viem_1.encodeFunctionData)({
|
|
74
|
+
abi: (0, viem_1.parseAbi)(['function initializeAccount(bytes)']),
|
|
75
|
+
functionName: 'initializeAccount',
|
|
76
|
+
args: [initData],
|
|
77
|
+
});
|
|
78
|
+
return {
|
|
79
|
+
factory: FACTORY_ADDRESS,
|
|
80
|
+
factoryData,
|
|
81
|
+
salt,
|
|
82
|
+
implementation: IMPLEMENTATION_ADDRESS,
|
|
83
|
+
initializationCallData,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function getK1InitData(config, moduleSetup) {
|
|
87
|
+
const ownerAddress = config.owners.accounts[0]
|
|
88
|
+
.address;
|
|
89
|
+
const validators = moduleSetup.validators.filter((v) => v.address.toLowerCase() !== K1_DEFAULT_VALIDATOR_ADDRESS.toLowerCase());
|
|
90
|
+
return (0, viem_1.encodeAbiParameters)([{ type: 'address' }, { type: 'bytes' }], [
|
|
91
|
+
BOOTSTRAP_ADDRESS,
|
|
92
|
+
(0, viem_1.encodeFunctionData)({
|
|
93
|
+
abi: (0, viem_1.parseAbi)([
|
|
94
|
+
'struct BootstrapConfig {address module;bytes initData;}',
|
|
95
|
+
'struct BootstrapPreValidationHookConfig {uint256 hookType;address module;bytes data;}',
|
|
96
|
+
'function initWithDefaultValidatorAndOtherModules(bytes calldata defaultValidatorInitData,BootstrapConfig[] calldata validators,BootstrapConfig[] calldata executors,BootstrapConfig calldata hook,BootstrapConfig[] calldata fallbacks,BootstrapPreValidationHookConfig[] calldata preValidationHooks) external payable',
|
|
97
|
+
]),
|
|
98
|
+
functionName: 'initWithDefaultValidatorAndOtherModules',
|
|
99
|
+
args: [
|
|
100
|
+
ownerAddress,
|
|
101
|
+
validators.map((v) => ({
|
|
102
|
+
module: v.address,
|
|
103
|
+
initData: v.initData,
|
|
104
|
+
})),
|
|
105
|
+
moduleSetup.executors.map((e) => ({
|
|
106
|
+
module: e.address,
|
|
107
|
+
initData: e.initData,
|
|
108
|
+
})),
|
|
109
|
+
{
|
|
110
|
+
module: viem_1.zeroAddress,
|
|
111
|
+
initData: viem_1.zeroHash,
|
|
112
|
+
},
|
|
113
|
+
moduleSetup.fallbacks.map((f) => ({
|
|
114
|
+
module: f.address,
|
|
115
|
+
initData: f.initData,
|
|
116
|
+
})),
|
|
117
|
+
[],
|
|
118
|
+
],
|
|
119
|
+
}),
|
|
120
|
+
]);
|
|
121
|
+
}
|
|
122
|
+
function getOwnableInitData(moduleSetup) {
|
|
123
|
+
return (0, viem_1.encodeAbiParameters)([{ type: 'address' }, { type: 'bytes' }], [
|
|
25
124
|
BOOTSTRAP_ADDRESS,
|
|
26
125
|
(0, viem_1.encodeFunctionData)({
|
|
27
126
|
abi: (0, viem_1.parseAbi)([
|
|
@@ -51,26 +150,16 @@ function getDeployArgs(config) {
|
|
|
51
150
|
],
|
|
52
151
|
}),
|
|
53
152
|
]);
|
|
54
|
-
const factoryData = (0, viem_1.encodeFunctionData)({
|
|
55
|
-
abi: (0, viem_1.parseAbi)(['function createAccount(bytes,bytes32)']),
|
|
56
|
-
functionName: 'createAccount',
|
|
57
|
-
args: [initData, salt],
|
|
58
|
-
});
|
|
59
|
-
const initializationCallData = (0, viem_1.encodeFunctionData)({
|
|
60
|
-
abi: (0, viem_1.parseAbi)(['function initializeAccount(bytes)']),
|
|
61
|
-
functionName: 'initializeAccount',
|
|
62
|
-
args: [initData],
|
|
63
|
-
});
|
|
64
|
-
return {
|
|
65
|
-
factory: FACTORY_ADDRESS,
|
|
66
|
-
factoryData,
|
|
67
|
-
salt,
|
|
68
|
-
implementation: IMPLEMENTATION_ADDRESS,
|
|
69
|
-
initializationCallData,
|
|
70
|
-
};
|
|
71
153
|
}
|
|
72
154
|
function getAddress(config) {
|
|
73
|
-
const
|
|
155
|
+
const deployArgs = getDeployArgs(config);
|
|
156
|
+
if (!deployArgs) {
|
|
157
|
+
if (config.initData?.address) {
|
|
158
|
+
return config.initData.address;
|
|
159
|
+
}
|
|
160
|
+
throw new Error('Cannot derive address: deploy args not available');
|
|
161
|
+
}
|
|
162
|
+
const { factory, salt, initializationCallData } = deployArgs;
|
|
74
163
|
const accountInitData = (0, viem_1.encodeAbiParameters)([
|
|
75
164
|
{
|
|
76
165
|
name: 'address',
|
|
@@ -27,7 +27,7 @@ interface GetAccountNonceParams {
|
|
|
27
27
|
}
|
|
28
28
|
declare function encode7579Calls<callType extends CallType>({ mode, callData, }: EncodeCallDataParams<callType>): Hex;
|
|
29
29
|
declare function getAccountNonce(client: Client, args: GetAccountNonceParams): Promise<bigint>;
|
|
30
|
-
declare function getBundlerClient(config: RhinestoneConfig, client: Client): import("viem/account-abstraction").BundlerClient<import("viem").HttpTransport<undefined, false>, undefined, undefined, Client, undefined>;
|
|
30
|
+
declare function getBundlerClient(config: RhinestoneConfig, client: Client): import("viem/_types/account-abstraction").BundlerClient<import("viem").HttpTransport<undefined, false>, undefined, undefined, Client, undefined>;
|
|
31
31
|
export { encode7579Calls, getAccountNonce, getBundlerClient, createTransport };
|
|
32
32
|
export type { ValidatorConfig };
|
|
33
33
|
//# sourceMappingURL=utils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G,GAAG,CAuFtC;AAED,iBAAe,eAAe,CAC5B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,qBAAqB,GAC1B,OAAO,CAAC,MAAM,CAAC,CAmCjB;AAED,iBAAS,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,oJAuDjE;AAyBD,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,gBAAgB,EAAE,eAAe,EAAE,CAAA;AAC9E,YAAY,EAAE,eAAe,EAAE,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { RhinestoneConfig, RhinestoneSDKConfig } from '../types';
|
|
2
|
+
export interface AuthProvider {
|
|
3
|
+
getHeaders(): Promise<Record<string, string>>;
|
|
4
|
+
getSubmitHeaders(intentInput: unknown, isSponsored: boolean): Promise<Record<string, string>>;
|
|
5
|
+
}
|
|
6
|
+
export declare function createAuthProvider(config: RhinestoneSDKConfig | RhinestoneConfig): AuthProvider;
|
|
7
|
+
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../auth/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,gBAAgB,EAChB,mBAAmB,EACpB,MAAM,UAAU,CAAA;AAEjB,MAAM,WAAW,YAAY;IAC3B,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;IAC7C,gBAAgB,CACd,WAAW,EAAE,OAAO,EACpB,WAAW,EAAE,OAAO,GACnB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;CACnC;AAED,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,mBAAmB,GAAG,gBAAgB,GAC7C,YAAY,CAqCd"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createAuthProvider = createAuthProvider;
|
|
4
|
+
function createAuthProvider(config) {
|
|
5
|
+
const resolved = resolveAuth(config);
|
|
6
|
+
if (resolved.mode === 'apiKey') {
|
|
7
|
+
const headers = { 'x-api-key': resolved.apiKey };
|
|
8
|
+
return {
|
|
9
|
+
getHeaders: async () => headers,
|
|
10
|
+
getSubmitHeaders: async () => headers,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
const { accessToken, getIntentExtensionToken } = resolved;
|
|
14
|
+
const resolveAccessToken = async () => typeof accessToken === 'function' ? await accessToken() : accessToken;
|
|
15
|
+
return {
|
|
16
|
+
async getHeaders() {
|
|
17
|
+
const token = await resolveAccessToken();
|
|
18
|
+
return { Authorization: `Bearer ${token}`, 'x-api-key': 'jwt' };
|
|
19
|
+
},
|
|
20
|
+
async getSubmitHeaders(intentInput, isSponsored) {
|
|
21
|
+
const token = await resolveAccessToken();
|
|
22
|
+
const headers = {
|
|
23
|
+
Authorization: `Bearer ${token}`,
|
|
24
|
+
'x-api-key': 'jwt',
|
|
25
|
+
};
|
|
26
|
+
if (isSponsored && getIntentExtensionToken) {
|
|
27
|
+
const extensionToken = await getIntentExtensionToken(intentInput);
|
|
28
|
+
headers['X-Intent-Extension'] = `Bearer ${extensionToken}`;
|
|
29
|
+
}
|
|
30
|
+
return headers;
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function resolveAuth(config) {
|
|
35
|
+
if ('auth' in config && config.auth)
|
|
36
|
+
return config.auth;
|
|
37
|
+
if ('apiKey' in config && config.apiKey) {
|
|
38
|
+
return { mode: 'apiKey', apiKey: config.apiKey };
|
|
39
|
+
}
|
|
40
|
+
throw new Error('RhinestoneSDK requires either `apiKey` or `auth` in config');
|
|
41
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AccountConfigurationNotSupportedError, AccountError, Eip712DomainNotAvailableError, Eip7702AccountMustHaveEoaError, Eip7702NotSupportedForAccountError, EoaAccountMustHaveAccountError, ExistingEip7702AccountsNotSupportedError, FactoryArgsNotAvailableError, isAccountError, SigningNotSupportedForAccountError, SmartSessionsNotEnabledError, WalletClientNoConnectedAccountError } from '../accounts';
|
|
2
|
-
import { ExecutionError, IntentFailedError, isExecutionError, OrderPathRequiredForIntentsError, SessionChainRequiredError, SignerNotSupportedError } from '../execution';
|
|
2
|
+
import { ExecutionError, IntentFailedError, InvalidSourceCallsError, isExecutionError, OrderPathRequiredForIntentsError, SessionChainRequiredError, SignerNotSupportedError } from '../execution';
|
|
3
3
|
import { AuthenticationRequiredError, BadRequestError, BodyParserError, ConflictError, ForbiddenError, InsufficientBalanceError, InsufficientLiquidityError, IntentNotFoundError, InternalServerError, InvalidApiKeyError, InvalidIntentSignatureError, isAuthError, isOrchestratorError, isRateLimited, isRetryable, isValidationError, NoPathFoundError, OnlyOneTargetTokenAmountCanBeUnsetError, OrchestratorError, RateLimitedError, ResourceNotFoundError, SchemaValidationError, ServiceUnavailableError, SimulationFailedError, TokenNotSupportedError, UnauthorizedError, UnprocessableEntityError, UnsupportedChainError, UnsupportedChainIdError, UnsupportedTokenError } from '../orchestrator';
|
|
4
|
-
export { isAccountError, AccountError, AccountConfigurationNotSupportedError, Eip712DomainNotAvailableError, Eip7702AccountMustHaveEoaError, EoaAccountMustHaveAccountError, ExistingEip7702AccountsNotSupportedError, FactoryArgsNotAvailableError, SmartSessionsNotEnabledError, SigningNotSupportedForAccountError, Eip7702NotSupportedForAccountError, WalletClientNoConnectedAccountError, isExecutionError, ExecutionError, IntentFailedError, OrderPathRequiredForIntentsError, SessionChainRequiredError, SignerNotSupportedError, isOrchestratorError, isRetryable, isAuthError, isValidationError, isRateLimited, AuthenticationRequiredError, BadRequestError, BodyParserError, ConflictError, ForbiddenError, InsufficientBalanceError, InsufficientLiquidityError, InvalidApiKeyError, InvalidIntentSignatureError, NoPathFoundError, OnlyOneTargetTokenAmountCanBeUnsetError, OrchestratorError, IntentNotFoundError, InternalServerError, ResourceNotFoundError, RateLimitedError, SchemaValidationError, ServiceUnavailableError, SimulationFailedError, UnprocessableEntityError, UnauthorizedError, TokenNotSupportedError, UnsupportedChainError, UnsupportedChainIdError, UnsupportedTokenError, };
|
|
4
|
+
export { isAccountError, AccountError, AccountConfigurationNotSupportedError, Eip712DomainNotAvailableError, Eip7702AccountMustHaveEoaError, EoaAccountMustHaveAccountError, ExistingEip7702AccountsNotSupportedError, FactoryArgsNotAvailableError, SmartSessionsNotEnabledError, SigningNotSupportedForAccountError, Eip7702NotSupportedForAccountError, WalletClientNoConnectedAccountError, isExecutionError, ExecutionError, IntentFailedError, InvalidSourceCallsError, OrderPathRequiredForIntentsError, SessionChainRequiredError, SignerNotSupportedError, isOrchestratorError, isRetryable, isAuthError, isValidationError, isRateLimited, AuthenticationRequiredError, BadRequestError, BodyParserError, ConflictError, ForbiddenError, InsufficientBalanceError, InsufficientLiquidityError, InvalidApiKeyError, InvalidIntentSignatureError, NoPathFoundError, OnlyOneTargetTokenAmountCanBeUnsetError, OrchestratorError, IntentNotFoundError, InternalServerError, ResourceNotFoundError, RateLimitedError, SchemaValidationError, ServiceUnavailableError, SimulationFailedError, UnprocessableEntityError, UnauthorizedError, TokenNotSupportedError, UnsupportedChainError, UnsupportedChainIdError, UnsupportedTokenError, };
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qCAAqC,EACrC,YAAY,EACZ,6BAA6B,EAC7B,8BAA8B,EAC9B,kCAAkC,EAClC,8BAA8B,EAC9B,wCAAwC,EACxC,4BAA4B,EAC5B,cAAc,EACd,kCAAkC,EAClC,4BAA4B,EAC5B,mCAAmC,EACpC,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,gCAAgC,EAChC,yBAAyB,EACzB,uBAAuB,EACxB,MAAM,cAAc,CAAA;AACrB,OAAO,EACL,2BAA2B,EAC3B,eAAe,EACf,eAAe,EACf,aAAa,EACb,cAAc,EACd,wBAAwB,EACxB,0BAA0B,EAC1B,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,2BAA2B,EAC3B,WAAW,EACX,mBAAmB,EACnB,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,gBAAgB,EAChB,uCAAuC,EACvC,iBAAiB,EACjB,gBAAgB,EAChB,qBAAqB,EACrB,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,EACjB,wBAAwB,EACxB,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,EACtB,MAAM,iBAAiB,CAAA;AAExB,OAAO,EAEL,cAAc,EACd,YAAY,EACZ,qCAAqC,EACrC,6BAA6B,EAC7B,8BAA8B,EAC9B,8BAA8B,EAC9B,wCAAwC,EACxC,4BAA4B,EAC5B,4BAA4B,EAC5B,kCAAkC,EAClC,kCAAkC,EAClC,mCAAmC,EAEnC,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,gCAAgC,EAChC,yBAAyB,EACzB,uBAAuB,EAEvB,mBAAmB,EACnB,WAAW,EACX,WAAW,EACX,iBAAiB,EACjB,aAAa,EACb,2BAA2B,EAC3B,eAAe,EACf,eAAe,EACf,aAAa,EACb,cAAc,EACd,wBAAwB,EACxB,0BAA0B,EAC1B,kBAAkB,EAClB,2BAA2B,EAC3B,gBAAgB,EAChB,uCAAuC,EACvC,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,gBAAgB,EAChB,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,EACrB,wBAAwB,EACxB,iBAAiB,EACjB,sBAAsB,EACtB,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,GACtB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../errors/index.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0BAA0B,EAC1B,kBAAkB,EAClB,2BAA2B,EAC3B,gBAAgB,EAChB,uCAAuC,EACvC,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,gBAAgB,EAChB,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,EACrB,wBAAwB,EACxB,iBAAiB,EACjB,sBAAsB,EACtB,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,GACtB,CAAA"}
|
package/dist/src/errors/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.UnauthorizedError = exports.UnprocessableEntityError = exports.SimulationFailedError = exports.ServiceUnavailableError = exports.SchemaValidationError = exports.RateLimitedError = exports.ResourceNotFoundError = exports.InternalServerError = exports.IntentNotFoundError = exports.OrchestratorError = exports.OnlyOneTargetTokenAmountCanBeUnsetError = exports.NoPathFoundError = exports.InvalidIntentSignatureError = exports.InvalidApiKeyError = exports.InsufficientLiquidityError = exports.InsufficientBalanceError = exports.ForbiddenError = exports.ConflictError = exports.BodyParserError = exports.BadRequestError = exports.AuthenticationRequiredError = exports.isRateLimited = exports.isValidationError = exports.isAuthError = exports.isRetryable = exports.isOrchestratorError = exports.SignerNotSupportedError = exports.SessionChainRequiredError = exports.OrderPathRequiredForIntentsError = exports.IntentFailedError = exports.ExecutionError = exports.isExecutionError = exports.WalletClientNoConnectedAccountError = exports.Eip7702NotSupportedForAccountError = exports.SigningNotSupportedForAccountError = exports.SmartSessionsNotEnabledError = exports.FactoryArgsNotAvailableError = exports.ExistingEip7702AccountsNotSupportedError = exports.EoaAccountMustHaveAccountError = exports.Eip7702AccountMustHaveEoaError = exports.Eip712DomainNotAvailableError = exports.AccountConfigurationNotSupportedError = exports.AccountError = exports.isAccountError = void 0;
|
|
3
|
+
exports.UnsupportedTokenError = exports.UnsupportedChainIdError = exports.UnsupportedChainError = exports.TokenNotSupportedError = exports.UnauthorizedError = exports.UnprocessableEntityError = exports.SimulationFailedError = exports.ServiceUnavailableError = exports.SchemaValidationError = exports.RateLimitedError = exports.ResourceNotFoundError = exports.InternalServerError = exports.IntentNotFoundError = exports.OrchestratorError = exports.OnlyOneTargetTokenAmountCanBeUnsetError = exports.NoPathFoundError = exports.InvalidIntentSignatureError = exports.InvalidApiKeyError = exports.InsufficientLiquidityError = exports.InsufficientBalanceError = exports.ForbiddenError = exports.ConflictError = exports.BodyParserError = exports.BadRequestError = exports.AuthenticationRequiredError = exports.isRateLimited = exports.isValidationError = exports.isAuthError = exports.isRetryable = exports.isOrchestratorError = exports.SignerNotSupportedError = exports.SessionChainRequiredError = exports.OrderPathRequiredForIntentsError = exports.InvalidSourceCallsError = exports.IntentFailedError = exports.ExecutionError = exports.isExecutionError = exports.WalletClientNoConnectedAccountError = exports.Eip7702NotSupportedForAccountError = exports.SigningNotSupportedForAccountError = exports.SmartSessionsNotEnabledError = exports.FactoryArgsNotAvailableError = exports.ExistingEip7702AccountsNotSupportedError = exports.EoaAccountMustHaveAccountError = exports.Eip7702AccountMustHaveEoaError = exports.Eip712DomainNotAvailableError = exports.AccountConfigurationNotSupportedError = exports.AccountError = exports.isAccountError = void 0;
|
|
4
4
|
const accounts_1 = require("../accounts");
|
|
5
5
|
Object.defineProperty(exports, "AccountConfigurationNotSupportedError", { enumerable: true, get: function () { return accounts_1.AccountConfigurationNotSupportedError; } });
|
|
6
6
|
Object.defineProperty(exports, "AccountError", { enumerable: true, get: function () { return accounts_1.AccountError; } });
|
|
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "WalletClientNoConnectedAccountError", { enumerab
|
|
|
17
17
|
const execution_1 = require("../execution");
|
|
18
18
|
Object.defineProperty(exports, "ExecutionError", { enumerable: true, get: function () { return execution_1.ExecutionError; } });
|
|
19
19
|
Object.defineProperty(exports, "IntentFailedError", { enumerable: true, get: function () { return execution_1.IntentFailedError; } });
|
|
20
|
+
Object.defineProperty(exports, "InvalidSourceCallsError", { enumerable: true, get: function () { return execution_1.InvalidSourceCallsError; } });
|
|
20
21
|
Object.defineProperty(exports, "isExecutionError", { enumerable: true, get: function () { return execution_1.isExecutionError; } });
|
|
21
22
|
Object.defineProperty(exports, "OrderPathRequiredForIntentsError", { enumerable: true, get: function () { return execution_1.OrderPathRequiredForIntentsError; } });
|
|
22
23
|
Object.defineProperty(exports, "SessionChainRequiredError", { enumerable: true, get: function () { return execution_1.SessionChainRequiredError; } });
|