@rhinestone/sdk 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/README.md +7 -19
  2. package/dist/accounts/index.d.ts +15535 -0
  3. package/dist/accounts/index.d.ts.map +1 -0
  4. package/dist/accounts/index.js +242 -0
  5. package/dist/accounts/nexus.d.ts +23281 -0
  6. package/dist/accounts/nexus.d.ts.map +1 -0
  7. package/dist/accounts/nexus.js +230 -0
  8. package/dist/accounts/safe.d.ts +15 -0
  9. package/dist/accounts/safe.d.ts.map +1 -0
  10. package/dist/{services/account → accounts}/safe.js +36 -37
  11. package/dist/accounts/utils.d.ts +27 -0
  12. package/dist/accounts/utils.d.ts.map +1 -0
  13. package/dist/accounts/utils.js +155 -0
  14. package/dist/examples/abi/weth.d.ts +214 -0
  15. package/dist/examples/abi/weth.d.ts.map +1 -0
  16. package/dist/examples/abi/weth.js +279 -0
  17. package/dist/examples/cross-chain-ss.d.ts +1 -0
  18. package/dist/examples/cross-chain-ss.d.ts.map +1 -0
  19. package/dist/{example.js → examples/cross-chain-ss.js} +70 -44
  20. package/dist/examples/omni-account.d.ts +1 -0
  21. package/dist/examples/omni-account.d.ts.map +1 -0
  22. package/dist/examples/omni-account.js +169 -0
  23. package/dist/examples/smart-sessions.d.ts +1 -0
  24. package/dist/examples/smart-sessions.d.ts.map +1 -0
  25. package/dist/examples/smart-sessions.js +216 -0
  26. package/dist/execution/index.d.ts +31 -0
  27. package/dist/execution/index.d.ts.map +1 -0
  28. package/dist/execution/index.js +222 -0
  29. package/dist/execution/smart-session.d.ts +14 -0
  30. package/dist/execution/smart-session.d.ts.map +1 -0
  31. package/dist/execution/smart-session.js +83 -0
  32. package/dist/index.d.ts +15 -4
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +11 -11
  35. package/dist/modules/abi/smart-sessions.d.ts +42 -0
  36. package/dist/modules/abi/smart-sessions.d.ts.map +1 -0
  37. package/dist/modules/abi/smart-sessions.js +128 -0
  38. package/dist/modules/common.d.ts +16 -0
  39. package/dist/modules/common.d.ts.map +1 -0
  40. package/dist/modules/common.js +5 -0
  41. package/dist/modules/index.d.ts +33 -0
  42. package/dist/modules/index.d.ts.map +1 -0
  43. package/dist/modules/index.js +129 -0
  44. package/dist/modules/omni-account.d.ts +9 -0
  45. package/dist/modules/omni-account.d.ts.map +1 -0
  46. package/dist/modules/omni-account.js +7 -0
  47. package/dist/modules/validators.d.ts +31 -0
  48. package/dist/modules/validators.d.ts.map +1 -0
  49. package/dist/modules/validators.js +518 -0
  50. package/dist/{services/orchestrator → orchestrator}/client.d.ts +2 -5
  51. package/dist/orchestrator/client.d.ts.map +1 -0
  52. package/dist/orchestrator/consts.d.ts +4 -0
  53. package/dist/orchestrator/consts.d.ts.map +1 -0
  54. package/dist/orchestrator/consts.js +3 -0
  55. package/dist/orchestrator/error.d.ts.map +1 -0
  56. package/dist/orchestrator/index.d.ts +9 -0
  57. package/dist/orchestrator/index.d.ts.map +1 -0
  58. package/dist/orchestrator/index.js +10 -0
  59. package/dist/orchestrator/registry.d.ts +5 -0
  60. package/dist/orchestrator/registry.d.ts.map +1 -0
  61. package/dist/orchestrator/registry.js +187 -0
  62. package/dist/{services/orchestrator → orchestrator}/types.d.ts +39 -23
  63. package/dist/orchestrator/types.d.ts.map +1 -0
  64. package/dist/orchestrator/types.js +7 -0
  65. package/dist/orchestrator/utils.d.ts +11 -0
  66. package/dist/orchestrator/utils.d.ts.map +1 -0
  67. package/dist/{services/orchestrator → orchestrator}/utils.js +20 -6
  68. package/dist/types.d.ts +70 -8
  69. package/dist/types.d.ts.map +1 -1
  70. package/package.json +3 -3
  71. package/dist/example.d.ts +0 -1
  72. package/dist/example.d.ts.map +0 -1
  73. package/dist/services/account/index.d.ts +0 -13
  74. package/dist/services/account/index.d.ts.map +0 -1
  75. package/dist/services/account/index.js +0 -54
  76. package/dist/services/account/nexus.d.ts +0 -9
  77. package/dist/services/account/nexus.d.ts.map +0 -1
  78. package/dist/services/account/nexus.js +0 -67
  79. package/dist/services/account/safe.d.ts +0 -9
  80. package/dist/services/account/safe.d.ts.map +0 -1
  81. package/dist/services/modules.d.ts +0 -32
  82. package/dist/services/modules.d.ts.map +0 -1
  83. package/dist/services/modules.js +0 -166
  84. package/dist/services/orchestrator/client.d.ts.map +0 -1
  85. package/dist/services/orchestrator/consts.d.ts +0 -6
  86. package/dist/services/orchestrator/consts.d.ts.map +0 -1
  87. package/dist/services/orchestrator/consts.js +0 -4
  88. package/dist/services/orchestrator/error.d.ts.map +0 -1
  89. package/dist/services/orchestrator/index.d.ts +0 -8
  90. package/dist/services/orchestrator/index.d.ts.map +0 -1
  91. package/dist/services/orchestrator/index.js +0 -9
  92. package/dist/services/orchestrator/types.d.ts.map +0 -1
  93. package/dist/services/orchestrator/types.js +0 -6
  94. package/dist/services/orchestrator/utils.d.ts +0 -7
  95. package/dist/services/orchestrator/utils.d.ts.map +0 -1
  96. package/dist/services/transaction.d.ts +0 -6
  97. package/dist/services/transaction.d.ts.map +0 -1
  98. package/dist/services/transaction.js +0 -93
  99. /package/dist/{services/orchestrator → orchestrator}/client.js +0 -0
  100. /package/dist/{services/orchestrator → orchestrator}/error.d.ts +0 -0
  101. /package/dist/{services/orchestrator → orchestrator}/error.js +0 -0
@@ -1,67 +0,0 @@
1
- import { concat, encodeAbiParameters, encodeFunctionData, keccak256, parseAbi, encodePacked, zeroAddress, } from 'viem';
2
- import { getValidator, OMNI_ACCOUNT_MOCK_ATTESTER_ADDRESS, RHINESTONE_ATTESTER_ADDRESS, RHINESTONE_MODULE_REGISTRY_ADDRESS, } from '../modules';
3
- import { HOOK_ADDRESS, SAME_CHAIN_MODULE_ADDRESS, TARGET_MODULE_ADDRESS, } from '../orchestrator';
4
- const NEXUS_FACTORY_ADDRESS = '0x000000c3A93d2c5E02Cb053AC675665b1c4217F9';
5
- const NEXUS_BOOTSTRAP_ADDRESS = '0x879fa30248eeb693dcCE3eA94a743622170a3658';
6
- async function getDeployArgs(config) {
7
- const salt = keccak256('0x');
8
- const initData = encodeAbiParameters([{ type: 'address' }, { type: 'bytes' }], [
9
- NEXUS_BOOTSTRAP_ADDRESS,
10
- encodeFunctionData({
11
- abi: parseAbi([
12
- 'struct BootstrapConfig {address module;bytes initData;}',
13
- 'function initNexus(BootstrapConfig[] calldata validators,BootstrapConfig[] calldata executors,BootstrapConfig calldata hook,BootstrapConfig[] calldata fallbacks,address registry,address[] calldata attesters,uint8 threshold) external',
14
- ]),
15
- functionName: 'initNexus',
16
- args: [
17
- [
18
- {
19
- module: getValidator(config).address,
20
- initData: getValidator(config).initData,
21
- },
22
- ],
23
- [
24
- {
25
- module: SAME_CHAIN_MODULE_ADDRESS,
26
- initData: '0x',
27
- },
28
- {
29
- module: TARGET_MODULE_ADDRESS,
30
- initData: '0x',
31
- },
32
- {
33
- module: HOOK_ADDRESS,
34
- initData: '0x',
35
- },
36
- ],
37
- {
38
- module: zeroAddress,
39
- initData: '0x',
40
- },
41
- [
42
- {
43
- module: TARGET_MODULE_ADDRESS,
44
- initData: encodePacked(['bytes4', 'bytes1', 'bytes'], ['0x3a5be8cb', '0x00', '0x']),
45
- },
46
- ],
47
- RHINESTONE_MODULE_REGISTRY_ADDRESS,
48
- [RHINESTONE_ATTESTER_ADDRESS, OMNI_ACCOUNT_MOCK_ATTESTER_ADDRESS],
49
- 1,
50
- ],
51
- }),
52
- ]);
53
- const factoryData = encodeFunctionData({
54
- abi: parseAbi(['function createAccount(bytes,bytes32)']),
55
- functionName: 'createAccount',
56
- args: [initData, salt],
57
- });
58
- const actualSalt = keccak256(concat([initData, salt]));
59
- const hashedInitcode = '0xbf5658acdb0d71e91f2e2ac658b87c63b81f244ccb8c0aef176c5e397e08c2ba';
60
- return {
61
- factory: NEXUS_FACTORY_ADDRESS,
62
- factoryData,
63
- salt: actualSalt,
64
- hashedInitcode,
65
- };
66
- }
67
- export { getDeployArgs };
@@ -1,9 +0,0 @@
1
- import { RhinestoneAccountConfig } from '../../types';
2
- declare function getDeployArgs(config: RhinestoneAccountConfig): Promise<{
3
- factory: `0x${string}`;
4
- factoryData: `0x${string}`;
5
- salt: `0x${string}`;
6
- hashedInitcode: `0x${string}`;
7
- }>;
8
- export { getDeployArgs };
9
- //# sourceMappingURL=safe.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"safe.d.ts","sourceRoot":"","sources":["../../../services/account/safe.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAmBrD,iBAAe,aAAa,CAAC,MAAM,EAAE,uBAAuB;;;;;GAyF3D;AAsBD,OAAO,EAAE,aAAa,EAAE,CAAA"}
@@ -1,32 +0,0 @@
1
- import { Address, Chain, Hex } from 'viem';
2
- import { RhinestoneAccountConfig } from '../types';
3
- type ModuleType = 'validator' | 'executor' | 'fallback' | 'hook';
4
- interface Module {
5
- address: Address;
6
- initData: Hex;
7
- deInitData: Hex;
8
- additionalContext: Hex;
9
- type: ModuleType;
10
- }
11
- interface WebAuthnData {
12
- authenticatorData: Hex;
13
- clientDataJSON: string;
14
- typeIndex: number | bigint;
15
- }
16
- interface WebauthnValidatorSignature {
17
- webauthn: WebAuthnData;
18
- signature: WebauthnSignature | Hex | Uint8Array;
19
- usePrecompiled?: boolean;
20
- }
21
- interface WebauthnSignature {
22
- r: bigint;
23
- s: bigint;
24
- }
25
- declare const OMNI_ACCOUNT_MOCK_ATTESTER_ADDRESS: Address;
26
- declare const RHINESTONE_MODULE_REGISTRY_ADDRESS: Address;
27
- declare const RHINESTONE_ATTESTER_ADDRESS: Address;
28
- declare function getValidator(config: RhinestoneAccountConfig): Module;
29
- export declare function getWebauthnValidatorSignature({ webauthn, signature, usePrecompiled, }: WebauthnValidatorSignature): `0x${string}`;
30
- export declare function isRip7212SupportedNetwork(chain: Chain): boolean;
31
- export { getValidator, OMNI_ACCOUNT_MOCK_ATTESTER_ADDRESS, RHINESTONE_MODULE_REGISTRY_ADDRESS, RHINESTONE_ATTESTER_ADDRESS, };
32
- //# sourceMappingURL=modules.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"modules.d.ts","sourceRoot":"","sources":["../../services/modules.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAEP,KAAK,EAEL,GAAG,EAIJ,MAAM,MAAM,CAAA;AAYb,OAAO,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAA;AAElD,KAAK,UAAU,GAAG,WAAW,GAAG,UAAU,GAAG,UAAU,GAAG,MAAM,CAAA;AAEhE,UAAU,MAAM;IACd,OAAO,EAAE,OAAO,CAAA;IAChB,QAAQ,EAAE,GAAG,CAAA;IACb,UAAU,EAAE,GAAG,CAAA;IACf,iBAAiB,EAAE,GAAG,CAAA;IACtB,IAAI,EAAE,UAAU,CAAA;CACjB;AAcD,UAAU,YAAY;IACpB,iBAAiB,EAAE,GAAG,CAAA;IACtB,cAAc,EAAE,MAAM,CAAA;IACtB,SAAS,EAAE,MAAM,GAAG,MAAM,CAAA;CAC3B;AAED,UAAU,0BAA0B;IAClC,QAAQ,EAAE,YAAY,CAAA;IACtB,SAAS,EAAE,iBAAiB,GAAG,GAAG,GAAG,UAAU,CAAA;IAC/C,cAAc,CAAC,EAAE,OAAO,CAAA;CACzB;AAED,UAAU,iBAAiB;IACzB,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV;AAED,QAAA,MAAM,kCAAkC,EAAE,OACI,CAAA;AAE9C,QAAA,MAAM,kCAAkC,EAAE,OACI,CAAA;AAC9C,QAAA,MAAM,2BAA2B,EAAE,OACW,CAAA;AAM9C,iBAAS,YAAY,CAAC,MAAM,EAAE,uBAAuB,UAcpD;AAqFD,wBAAgB,6BAA6B,CAAC,EAC5C,QAAQ,EACR,SAAS,EACT,cAAsB,GACvB,EAAE,0BAA0B,iBA6C5B;AAED,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,KAAK,WAarD;AA0BD,OAAO,EACL,YAAY,EACZ,kCAAkC,EAClC,kCAAkC,EAClC,2BAA2B,GAC5B,CAAA"}
@@ -1,166 +0,0 @@
1
- import { bytesToHex, encodeAbiParameters, hexToBytes, keccak256, toHex, } from 'viem';
2
- import { arbitrum, arbitrumSepolia, base, baseSepolia, optimism, optimismSepolia, polygon, polygonAmoy, } from 'viem/chains';
3
- const OMNI_ACCOUNT_MOCK_ATTESTER_ADDRESS = '0x6D0515e8E499468DCe9583626f0cA15b887f9d03';
4
- const RHINESTONE_MODULE_REGISTRY_ADDRESS = '0x000000000069e2a187aeffb852bf3ccdc95151b2';
5
- const RHINESTONE_ATTESTER_ADDRESS = '0x000000333034E9f539ce08819E12c1b8Cb29084d';
6
- const OWNABLE_VALIDATOR_ADDRESS = '0x2483DA3A338895199E5e538530213157e931Bf06';
7
- const WEBAUTHN_VALIDATOR_ADDRESS = '0x2f167e55d42584f65e2e30a748f41ee75a311414';
8
- function getValidator(config) {
9
- const ownerSet = config.owners;
10
- switch (ownerSet.type) {
11
- case 'ecdsa':
12
- return getOwnableValidator({
13
- threshold: ownerSet.threshold ?? 1,
14
- owners: ownerSet.accounts.map((account) => account.address),
15
- });
16
- case 'passkey':
17
- return getWebAuthnValidator({
18
- pubKey: ownerSet.account.publicKey,
19
- authenticatorId: ownerSet.account.id,
20
- });
21
- }
22
- }
23
- function getOwnableValidator({ threshold, owners, }) {
24
- return {
25
- address: OWNABLE_VALIDATOR_ADDRESS,
26
- initData: encodeAbiParameters([
27
- { name: 'threshold', type: 'uint256' },
28
- { name: 'owners', type: 'address[]' },
29
- ], [
30
- BigInt(threshold),
31
- owners.map((owner) => owner.toLowerCase()).sort(),
32
- ]),
33
- deInitData: '0x',
34
- additionalContext: '0x',
35
- type: 'validator',
36
- };
37
- }
38
- function getWebAuthnValidator(webAuthnCredential) {
39
- let pubKeyX;
40
- let pubKeyY;
41
- // Distinguish between PublicKey and Hex / byte encoded public key
42
- if (typeof webAuthnCredential.pubKey === 'string' ||
43
- webAuthnCredential.pubKey instanceof Uint8Array) {
44
- // It's a P256Credential
45
- const { x, y, prefix } = parsePublicKey(webAuthnCredential.pubKey);
46
- pubKeyX = x;
47
- pubKeyY = y;
48
- if (prefix && prefix !== 4) {
49
- throw new Error('Only uncompressed public keys are supported');
50
- }
51
- }
52
- else {
53
- // It's already a PublicKey
54
- pubKeyX = webAuthnCredential.pubKey.x;
55
- pubKeyY = webAuthnCredential.pubKey.y;
56
- }
57
- return {
58
- address: WEBAUTHN_VALIDATOR_ADDRESS,
59
- initData: encodeAbiParameters([
60
- {
61
- components: [
62
- {
63
- name: 'pubKeyX',
64
- type: 'uint256',
65
- },
66
- {
67
- name: 'pubKeyY',
68
- type: 'uint256',
69
- },
70
- ],
71
- type: 'tuple',
72
- },
73
- {
74
- type: 'bytes32',
75
- name: 'authenticatorIdHash',
76
- },
77
- ], [
78
- {
79
- pubKeyX,
80
- pubKeyY,
81
- },
82
- keccak256(toHex(webAuthnCredential.authenticatorId)),
83
- ]),
84
- deInitData: '0x',
85
- additionalContext: '0x',
86
- type: 'validator',
87
- };
88
- }
89
- export function getWebauthnValidatorSignature({ webauthn, signature, usePrecompiled = false, }) {
90
- const { authenticatorData, clientDataJSON, typeIndex } = webauthn;
91
- let r;
92
- let s;
93
- if (typeof signature === 'string' || signature instanceof Uint8Array) {
94
- const parsedSignature = parseSignature(signature);
95
- r = parsedSignature.r;
96
- s = parsedSignature.s;
97
- }
98
- else {
99
- r = signature.r;
100
- s = signature.s;
101
- }
102
- return encodeAbiParameters([
103
- { type: 'bytes', name: 'authenticatorData' },
104
- {
105
- type: 'string',
106
- name: 'clientDataJSON',
107
- },
108
- {
109
- type: 'uint256',
110
- name: 'responseTypeLocation',
111
- },
112
- {
113
- type: 'uint256',
114
- name: 'r',
115
- },
116
- {
117
- type: 'uint256',
118
- name: 's',
119
- },
120
- {
121
- type: 'bool',
122
- name: 'usePrecompiled',
123
- },
124
- ], [
125
- authenticatorData,
126
- clientDataJSON,
127
- typeof typeIndex === 'bigint' ? typeIndex : BigInt(typeIndex),
128
- r,
129
- s,
130
- usePrecompiled,
131
- ]);
132
- }
133
- export function isRip7212SupportedNetwork(chain) {
134
- const supportedChains = [
135
- optimism,
136
- optimismSepolia,
137
- polygon,
138
- polygonAmoy,
139
- base,
140
- baseSepolia,
141
- arbitrum,
142
- arbitrumSepolia,
143
- ];
144
- return supportedChains.includes(chain);
145
- }
146
- function parseSignature(signature) {
147
- const bytes = typeof signature === 'string' ? hexToBytes(signature) : signature;
148
- const r = bytes.slice(0, 32);
149
- const s = bytes.slice(32, 64);
150
- return {
151
- r: BigInt(bytesToHex(r)),
152
- s: BigInt(bytesToHex(s)),
153
- };
154
- }
155
- function parsePublicKey(publicKey) {
156
- const bytes = typeof publicKey === 'string' ? hexToBytes(publicKey) : publicKey;
157
- const offset = bytes.length === 65 ? 1 : 0;
158
- const x = bytes.slice(offset, 32 + offset);
159
- const y = bytes.slice(32 + offset, 64 + offset);
160
- return {
161
- prefix: bytes.length === 65 ? bytes[0] : undefined,
162
- x: BigInt(bytesToHex(x)),
163
- y: BigInt(bytesToHex(y)),
164
- };
165
- }
166
- export { getValidator, OMNI_ACCOUNT_MOCK_ATTESTER_ADDRESS, RHINESTONE_MODULE_REGISTRY_ADDRESS, RHINESTONE_ATTESTER_ADDRESS, };
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../services/orchestrator/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,GAAG,EAAU,MAAM,MAAM,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAExD,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACd,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,EAC1B,KAAK,YAAY,EACjB,KAAK,WAAW,EACjB,MAAM,SAAS,CAAA;AAQhB,qBAAa,YAAY;IACvB,OAAO,CAAC,SAAS,CAAQ;IACzB,OAAO,CAAC,MAAM,CAAQ;gBAEV,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAKvC,YAAY,CAChB,WAAW,EAAE,OAAO,EACpB,MAAM,CAAC,EAAE;QACP,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;QACnB,MAAM,CAAC,EAAE;YACP,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,EAAE,CAAA;SAC7B,CAAA;KACF,GACA,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAwCxB,YAAY,CAChB,MAAM,EAAE,UAAU,EAClB,WAAW,EAAE,OAAO,GACnB,OAAO,CACR;QACE,WAAW,EAAE,iBAAiB,CAAA;QAC9B,kBAAkB,EAAE,SAAS,EAAE,CAAA;KAChC,EAAE,CACJ;IA+BK,qBAAqB,CACzB,kBAAkB,EAAE;QAClB,iBAAiB,EAAE,uBAAuB,CAAA;QAC1C,QAAQ,CAAC,EAAE,GAAG,CAAA;QACd,MAAM,CAAC,EAAE,aAAa,CAAA;KACvB,EAAE,GACF,OAAO,CAAC,qBAAqB,CAAC;IA2C3B,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAyBxD,iBAAiB,CACrB,KAAK,GAAE,MAAW,EAClB,MAAM,GAAE,MAAU,GACjB,OAAO,CAAC;QAAE,cAAc,EAAE,WAAW,EAAE,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAuBlE,OAAO,CAAC,UAAU;CA6DnB"}
@@ -1,6 +0,0 @@
1
- import { Address } from 'viem';
2
- export declare const ORCHESTRATOR_URL = "https://orchestrator.rhinestone.wtf";
3
- export declare const HOOK_ADDRESS: Address;
4
- export declare const TARGET_MODULE_ADDRESS: Address;
5
- export declare const SAME_CHAIN_MODULE_ADDRESS: Address;
6
- //# sourceMappingURL=consts.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../../../services/orchestrator/consts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAE9B,eAAO,MAAM,gBAAgB,wCAAwC,CAAA;AAErE,eAAO,MAAM,YAAY,EAAE,OACmB,CAAA;AAC9C,eAAO,MAAM,qBAAqB,EAAE,OACU,CAAA;AAC9C,eAAO,MAAM,yBAAyB,EAAE,OACM,CAAA"}
@@ -1,4 +0,0 @@
1
- export const ORCHESTRATOR_URL = 'https://orchestrator.rhinestone.wtf';
2
- export const HOOK_ADDRESS = '0x0000000000f6Ed8Be424d673c63eeFF8b9267420';
3
- export const TARGET_MODULE_ADDRESS = '0x0000000000E5a37279A001301A837a91b5de1D5E';
4
- export const SAME_CHAIN_MODULE_ADDRESS = '0x000000000043ff16d5776c7F0f65Ec485C17Ca04';
@@ -1 +0,0 @@
1
- {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../../services/orchestrator/error.ts"],"names":[],"mappings":"AAAA,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAQ;IACjC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAK;IAC9B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAQ;IACnC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAQ;gBAErB,MAAM,CAAC,EAAE;QACnB,OAAO,CAAC,EAAE,MAAM,CAAA;QAChB,OAAO,CAAC,EAAE,GAAG,CAAA;QACb,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB,OAAO,CAAC,EAAE,MAAM,CAAA;KACjB;IAQD,IAAI,OAAO,WAEV;IAED,IAAI,OAAO,QAEV;IAED,IAAI,SAAS,WAEZ;IAED,IAAI,OAAO,WAEV;CACF"}
@@ -1,8 +0,0 @@
1
- import { OrchestratorError } from './error';
2
- import { HOOK_ADDRESS, TARGET_MODULE_ADDRESS, SAME_CHAIN_MODULE_ADDRESS } from './consts';
3
- import { Orchestrator } from './client';
4
- import { getOrderBundleHash } from './utils';
5
- export declare function getOrchestrator(apiKey: string, orchestratorUrl?: string): Orchestrator;
6
- export * from './types';
7
- export { HOOK_ADDRESS, TARGET_MODULE_ADDRESS, SAME_CHAIN_MODULE_ADDRESS, Orchestrator, OrchestratorError, getOrderBundleHash, };
8
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../services/orchestrator/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAC3C,OAAO,EAEL,YAAY,EACZ,qBAAqB,EACrB,yBAAyB,EAC1B,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAE5C,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,EACd,eAAe,CAAC,EAAE,MAAM,GACvB,YAAY,CAEd;AAED,cAAc,SAAS,CAAA;AACvB,OAAO,EACL,YAAY,EACZ,qBAAqB,EACrB,yBAAyB,EACzB,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,GACnB,CAAA"}
@@ -1,9 +0,0 @@
1
- import { OrchestratorError } from './error';
2
- import { ORCHESTRATOR_URL, HOOK_ADDRESS, TARGET_MODULE_ADDRESS, SAME_CHAIN_MODULE_ADDRESS, } from './consts';
3
- import { Orchestrator } from './client';
4
- import { getOrderBundleHash } from './utils';
5
- export function getOrchestrator(apiKey, orchestratorUrl) {
6
- return new Orchestrator(orchestratorUrl ?? ORCHESTRATOR_URL, apiKey);
7
- }
8
- export * from './types';
9
- export { HOOK_ADDRESS, TARGET_MODULE_ADDRESS, SAME_CHAIN_MODULE_ADDRESS, Orchestrator, OrchestratorError, getOrderBundleHash, };
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../services/orchestrator/types.ts"],"names":[],"m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FAILED = 'FAILED';
3
- export const BUNDLE_STATUS_EXPIRED = 'EXPIRED';
4
- export const BUNDLE_STATUS_PARTIALLY_COMPLETED = 'PARTIALLY_COMPLETED';
5
- export const BUNDLE_STATUS_COMPLETED = 'COMPLETED';
6
- export const BUNDLE_STATUS_UNKNOWN = 'UNKNOWN';
@@ -1,7 +0,0 @@
1
- import { Hex } from 'viem';
2
- import { BundleEvent, MultiChainCompact } from './types';
3
- export declare function getOrderBundleHash(orderBundle: MultiChainCompact): Hex;
4
- export declare function convertBigIntFields(obj: any): any;
5
- export declare function parseCompactResponse(response: any): MultiChainCompact;
6
- export declare function parsePendingBundleEvent(response: any): BundleEvent;
7
- //# sourceMappingURL=utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../services/orchestrator/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,GAAG,EAGJ,MAAM,MAAM,CAAA;AAEb,OAAO,EACL,WAAW,EAEX,iBAAiB,EAIlB,MAAM,SAAS,CAAA;AAYhB,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,iBAAiB,GAAG,GAAG,CAMtE;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,CAwBjD;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,GAAG,GAAG,iBAAiB,CAiCrE;AAED,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,GAAG,GAAG,WAAW,CAkClE"}
@@ -1,6 +0,0 @@
1
- import { type BundleResult } from './orchestrator';
2
- import { RhinestoneAccountConfig, Transaction } from '../types';
3
- declare function sendTransactions(config: RhinestoneAccountConfig, transaction: Transaction): Promise<bigint>;
4
- declare function waitForExecution(config: RhinestoneAccountConfig, id: bigint): Promise<BundleResult>;
5
- export { sendTransactions, waitForExecution };
6
- //# sourceMappingURL=transaction.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../services/transaction.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,YAAY,EAQlB,MAAM,gBAAgB,CAAA;AAOvB,OAAO,EAAE,uBAAuB,EAAE,WAAW,EAAY,MAAM,UAAU,CAAA;AAEzE,iBAAe,gBAAgB,CAC7B,MAAM,EAAE,uBAAuB,EAC/B,WAAW,EAAE,WAAW,mBAiEzB;AAED,iBAAe,gBAAgB,CAAC,MAAM,EAAE,uBAAuB,EAAE,EAAE,EAAE,MAAM,yBAa1E;AAmCD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,CAAA"}
@@ -1,93 +0,0 @@
1
- import { concat, encodePacked } from 'viem';
2
- import { BUNDLE_STATUS_PENDING, BUNDLE_STATUS_FAILED, getOrchestrator, getOrderBundleHash, } from './orchestrator';
3
- import { getAddress, getDeployArgs, isDeployed, deploy } from './account';
4
- import { getValidator, getWebauthnValidatorSignature, isRip7212SupportedNetwork, } from './modules';
5
- async function sendTransactions(config, transaction) {
6
- const { sourceChain, targetChain, calls, tokenRequests } = transaction;
7
- const isAccountDeployed = await isDeployed(sourceChain, config);
8
- if (!isAccountDeployed) {
9
- await deploy(config.deployerAccount, sourceChain, config);
10
- }
11
- const accountAddress = await getAddress(config);
12
- const metaIntent = {
13
- targetChainId: targetChain.id,
14
- tokenTransfers: tokenRequests.map((tokenRequest) => ({
15
- tokenAddress: tokenRequest.address,
16
- amount: tokenRequest.amount,
17
- })),
18
- targetAccount: accountAddress,
19
- targetExecutions: calls.map((call) => ({
20
- value: call.value ?? 0n,
21
- to: call.to,
22
- data: call.data ?? '0x',
23
- })),
24
- };
25
- const orchestrator = getOrchestrator(config.rhinestoneApiKey);
26
- const orderPath = await orchestrator.getOrderPath(metaIntent, accountAddress);
27
- orderPath[0].orderBundle.segments[0].witness.execs = [
28
- ...orderPath[0].injectedExecutions,
29
- ...metaIntent.targetExecutions,
30
- ];
31
- const orderBundleHash = getOrderBundleHash(orderPath[0].orderBundle);
32
- const bundleSignature = await sign(config.owners, sourceChain, orderBundleHash);
33
- const validatorModule = getValidator(config);
34
- const packedSig = encodePacked(['address', 'bytes'], [validatorModule.address, bundleSignature]);
35
- const signedOrderBundle = {
36
- ...orderPath[0].orderBundle,
37
- originSignatures: Array(orderPath[0].orderBundle.segments.length).fill(packedSig),
38
- targetSignature: packedSig,
39
- };
40
- const { factory, factoryData } = await getDeployArgs(config);
41
- if (!factory || !factoryData) {
42
- throw new Error('Factory args not available');
43
- }
44
- const initCode = encodePacked(['address', 'bytes'], [factory, factoryData]);
45
- const bundleResults = await orchestrator.postSignedOrderBundle([
46
- {
47
- signedOrderBundle,
48
- initCode,
49
- },
50
- ]);
51
- return bundleResults[0].bundleId;
52
- }
53
- async function waitForExecution(config, id) {
54
- let bundleResult = null;
55
- while (bundleResult === null ||
56
- bundleResult.status === BUNDLE_STATUS_PENDING) {
57
- const orchestrator = getOrchestrator(config.rhinestoneApiKey);
58
- bundleResult = await orchestrator.getBundleStatus(id);
59
- }
60
- if (bundleResult.status === BUNDLE_STATUS_FAILED) {
61
- throw new Error('Bundle failed');
62
- }
63
- return bundleResult;
64
- }
65
- async function sign(validators, chain, hash) {
66
- switch (validators.type) {
67
- case 'ecdsa': {
68
- const signatures = await Promise.all(validators.accounts.map((account) => signEcdsa(account, hash)));
69
- return concat(signatures);
70
- }
71
- case 'passkey': {
72
- return await signPasskey(validators.account, chain, hash);
73
- }
74
- }
75
- }
76
- async function signEcdsa(account, hash) {
77
- const sign = account.signMessage;
78
- if (!sign) {
79
- throw new Error('Signing not supported for the account');
80
- }
81
- return await sign({ message: { raw: hash } });
82
- }
83
- async function signPasskey(account, chain, hash) {
84
- const { webauthn, signature } = await account.sign({ hash });
85
- const usePrecompiled = isRip7212SupportedNetwork(chain);
86
- const encodedSignature = getWebauthnValidatorSignature({
87
- webauthn,
88
- signature,
89
- usePrecompiled,
90
- });
91
- return encodedSignature;
92
- }
93
- export { sendTransactions, waitForExecution };