@rhinestone/sdk 0.0.0-dev-20260204114155
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 +83 -0
- package/dist/src/accounts/error.d.ts +114 -0
- package/dist/src/accounts/error.d.ts.map +1 -0
- package/dist/src/accounts/error.js +174 -0
- package/dist/src/accounts/index.d.ts +48 -0
- package/dist/src/accounts/index.d.ts.map +1 -0
- package/dist/src/accounts/index.js +643 -0
- package/dist/src/accounts/index.test.d.ts +2 -0
- package/dist/src/accounts/index.test.d.ts.map +1 -0
- package/dist/src/accounts/index.test.js +33 -0
- package/dist/src/accounts/json-rpc/index.d.ts +5 -0
- package/dist/src/accounts/json-rpc/index.d.ts.map +1 -0
- package/dist/src/accounts/json-rpc/index.js +20 -0
- package/dist/src/accounts/json-rpc/index.test.d.ts +2 -0
- package/dist/src/accounts/json-rpc/index.test.d.ts.map +1 -0
- package/dist/src/accounts/json-rpc/index.test.js +33 -0
- package/dist/src/accounts/json-rpc/providers.d.ts +5 -0
- package/dist/src/accounts/json-rpc/providers.d.ts.map +1 -0
- package/dist/src/accounts/json-rpc/providers.js +22 -0
- package/dist/src/accounts/json-rpc/providers.test.d.ts +2 -0
- package/dist/src/accounts/json-rpc/providers.test.d.ts.map +1 -0
- package/dist/src/accounts/json-rpc/providers.test.js +43 -0
- package/dist/src/accounts/kernel.d.ts +27 -0
- package/dist/src/accounts/kernel.d.ts.map +1 -0
- package/dist/src/accounts/kernel.js +281 -0
- package/dist/src/accounts/kernel.test.d.ts +2 -0
- package/dist/src/accounts/kernel.test.d.ts.map +1 -0
- package/dist/src/accounts/kernel.test.js +132 -0
- package/dist/src/accounts/nexus.d.ts +33 -0
- package/dist/src/accounts/nexus.d.ts.map +1 -0
- package/dist/src/accounts/nexus.js +455 -0
- package/dist/src/accounts/nexus.test.d.ts +2 -0
- package/dist/src/accounts/nexus.test.d.ts.map +1 -0
- package/dist/src/accounts/nexus.test.js +118 -0
- package/dist/src/accounts/passport.d.ts +9 -0
- package/dist/src/accounts/passport.d.ts.map +1 -0
- package/dist/src/accounts/passport.js +82 -0
- package/dist/src/accounts/safe.d.ts +33 -0
- package/dist/src/accounts/safe.d.ts.map +1 -0
- package/dist/src/accounts/safe.js +349 -0
- package/dist/src/accounts/safe.test.d.ts +2 -0
- package/dist/src/accounts/safe.test.d.ts.map +1 -0
- package/dist/src/accounts/safe.test.js +118 -0
- package/dist/src/accounts/signing/common.d.ts +27 -0
- package/dist/src/accounts/signing/common.d.ts.map +1 -0
- package/dist/src/accounts/signing/common.js +190 -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 +47 -0
- package/dist/src/accounts/signing/passkeys.d.ts +36 -0
- package/dist/src/accounts/signing/passkeys.d.ts.map +1 -0
- package/dist/src/accounts/signing/passkeys.js +125 -0
- package/dist/src/accounts/signing/passkeys.test.d.ts +2 -0
- package/dist/src/accounts/signing/passkeys.test.d.ts.map +1 -0
- package/dist/src/accounts/signing/passkeys.test.js +88 -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 +35 -0
- package/dist/src/accounts/startale.d.ts +25 -0
- package/dist/src/accounts/startale.d.ts.map +1 -0
- package/dist/src/accounts/startale.js +112 -0
- package/dist/src/accounts/startale.test.d.ts +2 -0
- package/dist/src/accounts/startale.test.d.ts.map +1 -0
- package/dist/src/accounts/startale.test.js +92 -0
- package/dist/src/accounts/utils.d.ts +33 -0
- package/dist/src/accounts/utils.d.ts.map +1 -0
- package/dist/src/accounts/utils.js +208 -0
- package/dist/src/accounts/utils.test.d.ts +2 -0
- package/dist/src/accounts/utils.test.d.ts.map +1 -0
- package/dist/src/accounts/utils.test.js +49 -0
- package/dist/src/accounts/walletClient.d.ts +34 -0
- package/dist/src/accounts/walletClient.d.ts.map +1 -0
- package/dist/src/accounts/walletClient.js +121 -0
- package/dist/src/actions/compact.d.ts +15 -0
- package/dist/src/actions/compact.d.ts.map +1 -0
- package/dist/src/actions/compact.js +213 -0
- package/dist/src/actions/deployment.d.ts +19 -0
- package/dist/src/actions/deployment.d.ts.map +1 -0
- package/dist/src/actions/deployment.js +78 -0
- package/dist/src/actions/ecdsa.d.ts +35 -0
- package/dist/src/actions/ecdsa.d.ts.map +1 -0
- package/dist/src/actions/ecdsa.js +114 -0
- package/dist/src/actions/ecdsa.test.d.ts +2 -0
- package/dist/src/actions/ecdsa.test.d.ts.map +1 -0
- package/dist/src/actions/ecdsa.test.js +99 -0
- package/dist/src/actions/index.d.ts +17 -0
- package/dist/src/actions/index.d.ts.map +1 -0
- package/dist/src/actions/index.js +53 -0
- package/dist/src/actions/mfa.d.ts +37 -0
- package/dist/src/actions/mfa.d.ts.map +1 -0
- package/dist/src/actions/mfa.js +133 -0
- package/dist/src/actions/passkeys.d.ts +37 -0
- package/dist/src/actions/passkeys.d.ts.map +1 -0
- package/dist/src/actions/passkeys.js +129 -0
- package/dist/src/actions/passkeys.test.d.ts +2 -0
- package/dist/src/actions/passkeys.test.d.ts.map +1 -0
- package/dist/src/actions/passkeys.test.js +54 -0
- package/dist/src/actions/recovery.d.ts +33 -0
- package/dist/src/actions/recovery.d.ts.map +1 -0
- package/dist/src/actions/recovery.js +193 -0
- package/dist/src/actions/recovery.test.d.ts +2 -0
- package/dist/src/actions/recovery.test.d.ts.map +1 -0
- package/dist/src/actions/recovery.test.js +168 -0
- package/dist/src/actions/smart-sessions.d.ts +23 -0
- package/dist/src/actions/smart-sessions.d.ts.map +1 -0
- package/dist/src/actions/smart-sessions.js +52 -0
- package/dist/src/errors/index.d.ts +5 -0
- package/dist/src/errors/index.d.ts.map +1 -0
- package/dist/src/errors/index.js +54 -0
- package/dist/src/execution/compact.d.ts +148 -0
- package/dist/src/execution/compact.d.ts.map +1 -0
- package/dist/src/execution/compact.js +120 -0
- package/dist/src/execution/error.d.ts +55 -0
- package/dist/src/execution/error.d.ts.map +1 -0
- package/dist/src/execution/error.js +78 -0
- package/dist/src/execution/index.d.ts +41 -0
- package/dist/src/execution/index.d.ts.map +1 -0
- package/dist/src/execution/index.js +230 -0
- package/dist/src/execution/permit2.d.ts +143 -0
- package/dist/src/execution/permit2.d.ts.map +1 -0
- package/dist/src/execution/permit2.js +285 -0
- package/dist/src/execution/singleChainOps.d.ts +40 -0
- package/dist/src/execution/singleChainOps.d.ts.map +1 -0
- package/dist/src/execution/singleChainOps.js +46 -0
- package/dist/src/execution/types.d.ts +36 -0
- package/dist/src/execution/types.d.ts.map +1 -0
- package/dist/src/execution/types.js +2 -0
- package/dist/src/execution/utils.d.ts +87 -0
- package/dist/src/execution/utils.d.ts.map +1 -0
- package/dist/src/execution/utils.js +783 -0
- package/dist/src/index.d.ts +76 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +319 -0
- package/dist/src/modules/abi/smart-session-emissary.d.ts +696 -0
- package/dist/src/modules/abi/smart-session-emissary.d.ts.map +1 -0
- package/dist/src/modules/abi/smart-session-emissary.js +565 -0
- package/dist/src/modules/abi/smart-sessions.d.ts +104 -0
- package/dist/src/modules/abi/smart-sessions.d.ts.map +1 -0
- package/dist/src/modules/abi/smart-sessions.js +131 -0
- package/dist/src/modules/chain-abstraction.d.ts +5 -0
- package/dist/src/modules/chain-abstraction.d.ts.map +1 -0
- package/dist/src/modules/chain-abstraction.js +7 -0
- package/dist/src/modules/common.d.ts +30 -0
- package/dist/src/modules/common.d.ts.map +1 -0
- package/dist/src/modules/common.js +42 -0
- package/dist/src/modules/index.d.ts +11 -0
- package/dist/src/modules/index.d.ts.map +1 -0
- package/dist/src/modules/index.js +97 -0
- package/dist/src/modules/index.test.d.ts +2 -0
- package/dist/src/modules/index.test.d.ts.map +1 -0
- package/dist/src/modules/index.test.js +81 -0
- package/dist/src/modules/legacy.d.ts +10 -0
- package/dist/src/modules/legacy.d.ts.map +1 -0
- package/dist/src/modules/legacy.js +65 -0
- package/dist/src/modules/read.d.ts +9 -0
- package/dist/src/modules/read.d.ts.map +1 -0
- package/dist/src/modules/read.js +125 -0
- package/dist/src/modules/validators/core.d.ts +31 -0
- package/dist/src/modules/validators/core.d.ts.map +1 -0
- package/dist/src/modules/validators/core.js +284 -0
- package/dist/src/modules/validators/core.test.d.ts +2 -0
- package/dist/src/modules/validators/core.test.d.ts.map +1 -0
- package/dist/src/modules/validators/core.test.js +101 -0
- package/dist/src/modules/validators/index.d.ts +4 -0
- package/dist/src/modules/validators/index.d.ts.map +1 -0
- package/dist/src/modules/validators/index.js +10 -0
- package/dist/src/modules/validators/smart-sessions.d.ts +185 -0
- package/dist/src/modules/validators/smart-sessions.d.ts.map +1 -0
- package/dist/src/modules/validators/smart-sessions.js +624 -0
- package/dist/src/orchestrator/client.d.ts +22 -0
- package/dist/src/orchestrator/client.d.ts.map +1 -0
- package/dist/src/orchestrator/client.js +360 -0
- package/dist/src/orchestrator/consts.d.ts +5 -0
- package/dist/src/orchestrator/consts.d.ts.map +1 -0
- package/dist/src/orchestrator/consts.js +9 -0
- package/dist/src/orchestrator/error.d.ts +242 -0
- package/dist/src/orchestrator/error.d.ts.map +1 -0
- package/dist/src/orchestrator/error.js +283 -0
- package/dist/src/orchestrator/index.d.ts +10 -0
- package/dist/src/orchestrator/index.d.ts.map +1 -0
- package/dist/src/orchestrator/index.js +58 -0
- package/dist/src/orchestrator/registry.d.ts +22 -0
- package/dist/src/orchestrator/registry.d.ts.map +1 -0
- package/dist/src/orchestrator/registry.js +116 -0
- package/dist/src/orchestrator/registry.test.d.ts +2 -0
- package/dist/src/orchestrator/registry.test.d.ts.map +1 -0
- package/dist/src/orchestrator/registry.test.js +154 -0
- package/dist/src/orchestrator/types.d.ts +322 -0
- package/dist/src/orchestrator/types.d.ts.map +1 -0
- package/dist/src/orchestrator/types.js +31 -0
- package/dist/src/orchestrator/utils.d.ts +3 -0
- package/dist/src/orchestrator/utils.d.ts.map +1 -0
- package/dist/src/orchestrator/utils.js +24 -0
- package/dist/src/types.d.ts +296 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +2 -0
- package/dist/src/utils/index.d.ts +26 -0
- package/dist/src/utils/index.d.ts.map +1 -0
- package/dist/src/utils/index.js +63 -0
- package/dist/test/consts.d.ts +10 -0
- package/dist/test/consts.d.ts.map +1 -0
- package/dist/test/consts.js +22 -0
- package/dist/test/utils/utils.d.ts +5 -0
- package/dist/test/utils/utils.d.ts.map +1 -0
- package/dist/test/utils/utils.js +20 -0
- package/package.json +161 -0
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SimulationFailedError = exports.BodyParserError = exports.InternalServerError = exports.UnprocessableEntityError = exports.BadRequestError = exports.ConflictError = exports.ResourceNotFoundError = exports.ForbiddenError = exports.UnauthorizedError = exports.ServiceUnavailableError = exports.RateLimitedError = exports.SchemaValidationError = exports.IntentNotFoundError = exports.NoPathFoundError = exports.OnlyOneTargetTokenAmountCanBeUnsetError = exports.InvalidIntentSignatureError = exports.InvalidApiKeyError = exports.AuthenticationRequiredError = exports.TokenNotSupportedError = exports.UnsupportedTokenError = exports.UnsupportedChainError = exports.UnsupportedChainIdError = exports.InsufficientBalanceError = exports.InsufficientLiquidityError = exports.OrchestratorError = void 0;
|
|
4
|
+
exports.isOrchestratorError = isOrchestratorError;
|
|
5
|
+
exports.isRetryable = isRetryable;
|
|
6
|
+
exports.isAuthError = isAuthError;
|
|
7
|
+
exports.isValidationError = isValidationError;
|
|
8
|
+
exports.isRateLimited = isRateLimited;
|
|
9
|
+
class OrchestratorError extends Error {
|
|
10
|
+
_message;
|
|
11
|
+
_context;
|
|
12
|
+
_errorType;
|
|
13
|
+
_traceId;
|
|
14
|
+
_statusCode;
|
|
15
|
+
constructor(params) {
|
|
16
|
+
super();
|
|
17
|
+
this._message = params?.message || 'OrchestratorError ';
|
|
18
|
+
this._context = params?.context || {};
|
|
19
|
+
this._errorType = params?.errorType || 'Unknown';
|
|
20
|
+
this._traceId = params?.traceId || '';
|
|
21
|
+
this._statusCode = params?.statusCode;
|
|
22
|
+
}
|
|
23
|
+
get message() {
|
|
24
|
+
return this._message;
|
|
25
|
+
}
|
|
26
|
+
get context() {
|
|
27
|
+
return this._context;
|
|
28
|
+
}
|
|
29
|
+
get errorType() {
|
|
30
|
+
return this._errorType;
|
|
31
|
+
}
|
|
32
|
+
get traceId() {
|
|
33
|
+
return this._traceId;
|
|
34
|
+
}
|
|
35
|
+
get statusCode() {
|
|
36
|
+
return this._statusCode;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.OrchestratorError = OrchestratorError;
|
|
40
|
+
class InsufficientBalanceError extends OrchestratorError {
|
|
41
|
+
constructor(params) {
|
|
42
|
+
super({
|
|
43
|
+
message: 'Insufficient balance',
|
|
44
|
+
...params,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.InsufficientBalanceError = InsufficientBalanceError;
|
|
49
|
+
class UnsupportedChainIdError extends OrchestratorError {
|
|
50
|
+
constructor(params) {
|
|
51
|
+
super({
|
|
52
|
+
message: 'Unsupported chain id',
|
|
53
|
+
...params,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.UnsupportedChainIdError = UnsupportedChainIdError;
|
|
58
|
+
class UnsupportedChainError extends OrchestratorError {
|
|
59
|
+
constructor(chainId, params) {
|
|
60
|
+
super({
|
|
61
|
+
message: `Unsupported chain ${chainId}`,
|
|
62
|
+
...params,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.UnsupportedChainError = UnsupportedChainError;
|
|
67
|
+
class UnsupportedTokenError extends OrchestratorError {
|
|
68
|
+
constructor(tokenSymbol, chainId, params) {
|
|
69
|
+
super({
|
|
70
|
+
message: `Unsupported token ${tokenSymbol} for chain ${chainId}`,
|
|
71
|
+
...params,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.UnsupportedTokenError = UnsupportedTokenError;
|
|
76
|
+
class TokenNotSupportedError extends OrchestratorError {
|
|
77
|
+
constructor(tokenAddress, chainId, params) {
|
|
78
|
+
super({
|
|
79
|
+
message: `Token ${tokenAddress} not supported on chain ${chainId}`,
|
|
80
|
+
...params,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
exports.TokenNotSupportedError = TokenNotSupportedError;
|
|
85
|
+
class AuthenticationRequiredError extends OrchestratorError {
|
|
86
|
+
constructor(params) {
|
|
87
|
+
super({
|
|
88
|
+
message: 'Authentication is required',
|
|
89
|
+
...params,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
exports.AuthenticationRequiredError = AuthenticationRequiredError;
|
|
94
|
+
class InvalidApiKeyError extends OrchestratorError {
|
|
95
|
+
constructor(params) {
|
|
96
|
+
super({
|
|
97
|
+
message: 'Invalid API key',
|
|
98
|
+
...params,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
exports.InvalidApiKeyError = InvalidApiKeyError;
|
|
103
|
+
class InvalidIntentSignatureError extends OrchestratorError {
|
|
104
|
+
constructor(params) {
|
|
105
|
+
super({
|
|
106
|
+
message: 'Invalid intent signature',
|
|
107
|
+
...params,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
exports.InvalidIntentSignatureError = InvalidIntentSignatureError;
|
|
112
|
+
class OnlyOneTargetTokenAmountCanBeUnsetError extends OrchestratorError {
|
|
113
|
+
constructor(params) {
|
|
114
|
+
super({
|
|
115
|
+
message: 'Only one target token amount can be unset',
|
|
116
|
+
...params,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
exports.OnlyOneTargetTokenAmountCanBeUnsetError = OnlyOneTargetTokenAmountCanBeUnsetError;
|
|
121
|
+
class NoPathFoundError extends OrchestratorError {
|
|
122
|
+
constructor(params) {
|
|
123
|
+
super({
|
|
124
|
+
message: 'No Path Found',
|
|
125
|
+
...params,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
exports.NoPathFoundError = NoPathFoundError;
|
|
130
|
+
class IntentNotFoundError extends OrchestratorError {
|
|
131
|
+
constructor(params) {
|
|
132
|
+
super({
|
|
133
|
+
message: 'Intent not found',
|
|
134
|
+
...params,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
exports.IntentNotFoundError = IntentNotFoundError;
|
|
139
|
+
class SchemaValidationError extends OrchestratorError {
|
|
140
|
+
constructor(params) {
|
|
141
|
+
super({
|
|
142
|
+
message: params?.message || 'Schema validation error',
|
|
143
|
+
...params,
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
exports.SchemaValidationError = SchemaValidationError;
|
|
148
|
+
class RateLimitedError extends OrchestratorError {
|
|
149
|
+
constructor(params) {
|
|
150
|
+
super({
|
|
151
|
+
message: 'Too Many Requests',
|
|
152
|
+
...params,
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
exports.RateLimitedError = RateLimitedError;
|
|
157
|
+
class ServiceUnavailableError extends OrchestratorError {
|
|
158
|
+
constructor(params) {
|
|
159
|
+
super({
|
|
160
|
+
message: 'Service Unavailable',
|
|
161
|
+
...params,
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
exports.ServiceUnavailableError = ServiceUnavailableError;
|
|
166
|
+
class UnauthorizedError extends OrchestratorError {
|
|
167
|
+
constructor(params) {
|
|
168
|
+
super({
|
|
169
|
+
message: 'Unauthorized',
|
|
170
|
+
...params,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
exports.UnauthorizedError = UnauthorizedError;
|
|
175
|
+
class ForbiddenError extends OrchestratorError {
|
|
176
|
+
constructor(params) {
|
|
177
|
+
super({
|
|
178
|
+
message: 'Forbidden',
|
|
179
|
+
...params,
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
exports.ForbiddenError = ForbiddenError;
|
|
184
|
+
class ResourceNotFoundError extends OrchestratorError {
|
|
185
|
+
constructor(params) {
|
|
186
|
+
super({
|
|
187
|
+
message: 'Not Found',
|
|
188
|
+
...params,
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
exports.ResourceNotFoundError = ResourceNotFoundError;
|
|
193
|
+
class ConflictError extends OrchestratorError {
|
|
194
|
+
constructor(params) {
|
|
195
|
+
super({
|
|
196
|
+
message: 'Conflict',
|
|
197
|
+
...params,
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
exports.ConflictError = ConflictError;
|
|
202
|
+
class BadRequestError extends OrchestratorError {
|
|
203
|
+
constructor(params) {
|
|
204
|
+
super({
|
|
205
|
+
message: params?.message || 'Bad Request',
|
|
206
|
+
...params,
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
exports.BadRequestError = BadRequestError;
|
|
211
|
+
class UnprocessableEntityError extends OrchestratorError {
|
|
212
|
+
constructor(params) {
|
|
213
|
+
super({
|
|
214
|
+
message: params?.message || 'Unprocessable Entity',
|
|
215
|
+
...params,
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
exports.UnprocessableEntityError = UnprocessableEntityError;
|
|
220
|
+
class InternalServerError extends OrchestratorError {
|
|
221
|
+
constructor(params) {
|
|
222
|
+
super({
|
|
223
|
+
message: 'Internal Server Error',
|
|
224
|
+
...params,
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
exports.InternalServerError = InternalServerError;
|
|
229
|
+
class BodyParserError extends OrchestratorError {
|
|
230
|
+
constructor(params) {
|
|
231
|
+
super({
|
|
232
|
+
message: params?.message || 'Body parser error',
|
|
233
|
+
...params,
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
exports.BodyParserError = BodyParserError;
|
|
238
|
+
class SimulationFailedError extends OrchestratorError {
|
|
239
|
+
constructor(params) {
|
|
240
|
+
super({
|
|
241
|
+
message: params?.message || 'Simulation failed',
|
|
242
|
+
...params,
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
exports.SimulationFailedError = SimulationFailedError;
|
|
247
|
+
class InsufficientLiquidityError extends OrchestratorError {
|
|
248
|
+
availableIntents;
|
|
249
|
+
unfillable;
|
|
250
|
+
constructor(params) {
|
|
251
|
+
super({
|
|
252
|
+
message: 'Insufficient liquidity to fill the requested amounts. Partial splits available.',
|
|
253
|
+
statusCode: params.statusCode ?? 422,
|
|
254
|
+
traceId: params.traceId,
|
|
255
|
+
errorType: 'Unprocessable Entity',
|
|
256
|
+
});
|
|
257
|
+
this.availableIntents = params.availableIntents;
|
|
258
|
+
this.unfillable = params.unfillable;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
exports.InsufficientLiquidityError = InsufficientLiquidityError;
|
|
262
|
+
function isOrchestratorError(error) {
|
|
263
|
+
return error instanceof OrchestratorError;
|
|
264
|
+
}
|
|
265
|
+
function isRateLimited(error) {
|
|
266
|
+
return (error instanceof RateLimitedError ||
|
|
267
|
+
(error instanceof OrchestratorError && error.statusCode === 429));
|
|
268
|
+
}
|
|
269
|
+
function isValidationError(error) {
|
|
270
|
+
if (!(error instanceof OrchestratorError))
|
|
271
|
+
return false;
|
|
272
|
+
return error.statusCode === 400 || error.statusCode === 422;
|
|
273
|
+
}
|
|
274
|
+
function isAuthError(error) {
|
|
275
|
+
if (!(error instanceof OrchestratorError))
|
|
276
|
+
return false;
|
|
277
|
+
return (error.statusCode === 401 || error instanceof AuthenticationRequiredError);
|
|
278
|
+
}
|
|
279
|
+
function isRetryable(error) {
|
|
280
|
+
if (!(error instanceof OrchestratorError))
|
|
281
|
+
return false;
|
|
282
|
+
return error.statusCode === 500 || error.statusCode === 503;
|
|
283
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Orchestrator } from './client';
|
|
2
|
+
import { RHINESTONE_SPOKE_POOL_ADDRESS } from './consts';
|
|
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 './error';
|
|
4
|
+
import { getAllSupportedChainsAndTokens, getSupportedTokens, getTokenAddress, getTokenDecimals, getTokenSymbol, getWethAddress, isTokenAddressSupported } from './registry';
|
|
5
|
+
import type { ApprovalRequired, IntentInput, IntentOp, IntentOpStatus, IntentResult, IntentRoute, Portfolio, SettlementLayer, SignedIntentOp, SplitIntentsInput, SplitIntentsResult, SupportedChain, TokenConfig, TokenRequirements, WrapRequired } from './types';
|
|
6
|
+
import { INTENT_STATUS_CLAIMED, INTENT_STATUS_COMPLETED, INTENT_STATUS_EXPIRED, INTENT_STATUS_FAILED, INTENT_STATUS_FILLED, INTENT_STATUS_PENDING, INTENT_STATUS_PRECONFIRMED } from './types';
|
|
7
|
+
declare function getOrchestrator(apiKey?: string, orchestratorUrl?: string): Orchestrator;
|
|
8
|
+
export type { IntentInput, IntentOp, IntentOpStatus, IntentResult, IntentRoute, SettlementLayer, SignedIntentOp, SplitIntentsInput, SplitIntentsResult, SupportedChain, TokenConfig, Portfolio, TokenRequirements, WrapRequired, ApprovalRequired, };
|
|
9
|
+
export { INTENT_STATUS_PENDING, INTENT_STATUS_EXPIRED, INTENT_STATUS_COMPLETED, INTENT_STATUS_FILLED, INTENT_STATUS_FAILED, INTENT_STATUS_PRECONFIRMED, INTENT_STATUS_CLAIMED, RHINESTONE_SPOKE_POOL_ADDRESS, Orchestrator, 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, getOrchestrator, getWethAddress, getTokenSymbol, getTokenAddress, getTokenDecimals, getSupportedTokens, getAllSupportedChainsAndTokens, isOrchestratorError, isRetryable, isAuthError, isValidationError, isRateLimited, isTokenAddressSupported, };
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../orchestrator/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AACvC,OAAO,EAAyB,6BAA6B,EAAE,MAAM,UAAU,CAAA;AAC/E,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,SAAS,CAAA;AAChB,OAAO,EACL,8BAA8B,EAC9B,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,uBAAuB,EACxB,MAAM,YAAY,CAAA;AACnB,OAAO,KAAK,EACV,gBAAgB,EAChB,WAAW,EACX,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,WAAW,EACX,SAAS,EACT,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,YAAY,EACb,MAAM,SAAS,CAAA;AAChB,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,0BAA0B,EAC3B,MAAM,SAAS,CAAA;AAEhB,iBAAS,eAAe,CACtB,MAAM,CAAC,EAAE,MAAM,EACf,eAAe,CAAC,EAAE,MAAM,GACvB,YAAY,CAEd;AAED,YAAY,EACV,WAAW,EACX,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,WAAW,EACX,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,WAAW,EACX,SAAS,EACT,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,GACjB,CAAA;AACD,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,uBAAuB,EACvB,oBAAoB,EACpB,oBAAoB,EACpB,0BAA0B,EAC1B,qBAAqB,EACrB,6BAA6B,EAC7B,YAAY,EACZ,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,EACrB,eAAe,EACf,cAAc,EACd,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,8BAA8B,EAC9B,mBAAmB,EACnB,WAAW,EACX,WAAW,EACX,iBAAiB,EACjB,aAAa,EACb,uBAAuB,GACxB,CAAA"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isTokenAddressSupported = exports.isRateLimited = exports.isValidationError = exports.isAuthError = exports.isRetryable = exports.isOrchestratorError = exports.getAllSupportedChainsAndTokens = exports.getSupportedTokens = exports.getTokenDecimals = exports.getTokenAddress = exports.getTokenSymbol = exports.getWethAddress = 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.Orchestrator = exports.RHINESTONE_SPOKE_POOL_ADDRESS = exports.INTENT_STATUS_CLAIMED = exports.INTENT_STATUS_PRECONFIRMED = exports.INTENT_STATUS_FAILED = exports.INTENT_STATUS_FILLED = exports.INTENT_STATUS_COMPLETED = exports.INTENT_STATUS_EXPIRED = exports.INTENT_STATUS_PENDING = void 0;
|
|
4
|
+
exports.getOrchestrator = getOrchestrator;
|
|
5
|
+
const client_1 = require("./client");
|
|
6
|
+
Object.defineProperty(exports, "Orchestrator", { enumerable: true, get: function () { return client_1.Orchestrator; } });
|
|
7
|
+
const consts_1 = require("./consts");
|
|
8
|
+
Object.defineProperty(exports, "RHINESTONE_SPOKE_POOL_ADDRESS", { enumerable: true, get: function () { return consts_1.RHINESTONE_SPOKE_POOL_ADDRESS; } });
|
|
9
|
+
const error_1 = require("./error");
|
|
10
|
+
Object.defineProperty(exports, "AuthenticationRequiredError", { enumerable: true, get: function () { return error_1.AuthenticationRequiredError; } });
|
|
11
|
+
Object.defineProperty(exports, "BadRequestError", { enumerable: true, get: function () { return error_1.BadRequestError; } });
|
|
12
|
+
Object.defineProperty(exports, "BodyParserError", { enumerable: true, get: function () { return error_1.BodyParserError; } });
|
|
13
|
+
Object.defineProperty(exports, "ConflictError", { enumerable: true, get: function () { return error_1.ConflictError; } });
|
|
14
|
+
Object.defineProperty(exports, "ForbiddenError", { enumerable: true, get: function () { return error_1.ForbiddenError; } });
|
|
15
|
+
Object.defineProperty(exports, "InsufficientBalanceError", { enumerable: true, get: function () { return error_1.InsufficientBalanceError; } });
|
|
16
|
+
Object.defineProperty(exports, "InsufficientLiquidityError", { enumerable: true, get: function () { return error_1.InsufficientLiquidityError; } });
|
|
17
|
+
Object.defineProperty(exports, "IntentNotFoundError", { enumerable: true, get: function () { return error_1.IntentNotFoundError; } });
|
|
18
|
+
Object.defineProperty(exports, "InternalServerError", { enumerable: true, get: function () { return error_1.InternalServerError; } });
|
|
19
|
+
Object.defineProperty(exports, "InvalidApiKeyError", { enumerable: true, get: function () { return error_1.InvalidApiKeyError; } });
|
|
20
|
+
Object.defineProperty(exports, "InvalidIntentSignatureError", { enumerable: true, get: function () { return error_1.InvalidIntentSignatureError; } });
|
|
21
|
+
Object.defineProperty(exports, "isAuthError", { enumerable: true, get: function () { return error_1.isAuthError; } });
|
|
22
|
+
Object.defineProperty(exports, "isOrchestratorError", { enumerable: true, get: function () { return error_1.isOrchestratorError; } });
|
|
23
|
+
Object.defineProperty(exports, "isRateLimited", { enumerable: true, get: function () { return error_1.isRateLimited; } });
|
|
24
|
+
Object.defineProperty(exports, "isRetryable", { enumerable: true, get: function () { return error_1.isRetryable; } });
|
|
25
|
+
Object.defineProperty(exports, "isValidationError", { enumerable: true, get: function () { return error_1.isValidationError; } });
|
|
26
|
+
Object.defineProperty(exports, "NoPathFoundError", { enumerable: true, get: function () { return error_1.NoPathFoundError; } });
|
|
27
|
+
Object.defineProperty(exports, "OnlyOneTargetTokenAmountCanBeUnsetError", { enumerable: true, get: function () { return error_1.OnlyOneTargetTokenAmountCanBeUnsetError; } });
|
|
28
|
+
Object.defineProperty(exports, "OrchestratorError", { enumerable: true, get: function () { return error_1.OrchestratorError; } });
|
|
29
|
+
Object.defineProperty(exports, "RateLimitedError", { enumerable: true, get: function () { return error_1.RateLimitedError; } });
|
|
30
|
+
Object.defineProperty(exports, "ResourceNotFoundError", { enumerable: true, get: function () { return error_1.ResourceNotFoundError; } });
|
|
31
|
+
Object.defineProperty(exports, "SchemaValidationError", { enumerable: true, get: function () { return error_1.SchemaValidationError; } });
|
|
32
|
+
Object.defineProperty(exports, "ServiceUnavailableError", { enumerable: true, get: function () { return error_1.ServiceUnavailableError; } });
|
|
33
|
+
Object.defineProperty(exports, "SimulationFailedError", { enumerable: true, get: function () { return error_1.SimulationFailedError; } });
|
|
34
|
+
Object.defineProperty(exports, "TokenNotSupportedError", { enumerable: true, get: function () { return error_1.TokenNotSupportedError; } });
|
|
35
|
+
Object.defineProperty(exports, "UnauthorizedError", { enumerable: true, get: function () { return error_1.UnauthorizedError; } });
|
|
36
|
+
Object.defineProperty(exports, "UnprocessableEntityError", { enumerable: true, get: function () { return error_1.UnprocessableEntityError; } });
|
|
37
|
+
Object.defineProperty(exports, "UnsupportedChainError", { enumerable: true, get: function () { return error_1.UnsupportedChainError; } });
|
|
38
|
+
Object.defineProperty(exports, "UnsupportedChainIdError", { enumerable: true, get: function () { return error_1.UnsupportedChainIdError; } });
|
|
39
|
+
Object.defineProperty(exports, "UnsupportedTokenError", { enumerable: true, get: function () { return error_1.UnsupportedTokenError; } });
|
|
40
|
+
const registry_1 = require("./registry");
|
|
41
|
+
Object.defineProperty(exports, "getAllSupportedChainsAndTokens", { enumerable: true, get: function () { return registry_1.getAllSupportedChainsAndTokens; } });
|
|
42
|
+
Object.defineProperty(exports, "getSupportedTokens", { enumerable: true, get: function () { return registry_1.getSupportedTokens; } });
|
|
43
|
+
Object.defineProperty(exports, "getTokenAddress", { enumerable: true, get: function () { return registry_1.getTokenAddress; } });
|
|
44
|
+
Object.defineProperty(exports, "getTokenDecimals", { enumerable: true, get: function () { return registry_1.getTokenDecimals; } });
|
|
45
|
+
Object.defineProperty(exports, "getTokenSymbol", { enumerable: true, get: function () { return registry_1.getTokenSymbol; } });
|
|
46
|
+
Object.defineProperty(exports, "getWethAddress", { enumerable: true, get: function () { return registry_1.getWethAddress; } });
|
|
47
|
+
Object.defineProperty(exports, "isTokenAddressSupported", { enumerable: true, get: function () { return registry_1.isTokenAddressSupported; } });
|
|
48
|
+
const types_1 = require("./types");
|
|
49
|
+
Object.defineProperty(exports, "INTENT_STATUS_CLAIMED", { enumerable: true, get: function () { return types_1.INTENT_STATUS_CLAIMED; } });
|
|
50
|
+
Object.defineProperty(exports, "INTENT_STATUS_COMPLETED", { enumerable: true, get: function () { return types_1.INTENT_STATUS_COMPLETED; } });
|
|
51
|
+
Object.defineProperty(exports, "INTENT_STATUS_EXPIRED", { enumerable: true, get: function () { return types_1.INTENT_STATUS_EXPIRED; } });
|
|
52
|
+
Object.defineProperty(exports, "INTENT_STATUS_FAILED", { enumerable: true, get: function () { return types_1.INTENT_STATUS_FAILED; } });
|
|
53
|
+
Object.defineProperty(exports, "INTENT_STATUS_FILLED", { enumerable: true, get: function () { return types_1.INTENT_STATUS_FILLED; } });
|
|
54
|
+
Object.defineProperty(exports, "INTENT_STATUS_PENDING", { enumerable: true, get: function () { return types_1.INTENT_STATUS_PENDING; } });
|
|
55
|
+
Object.defineProperty(exports, "INTENT_STATUS_PRECONFIRMED", { enumerable: true, get: function () { return types_1.INTENT_STATUS_PRECONFIRMED; } });
|
|
56
|
+
function getOrchestrator(apiKey, orchestratorUrl) {
|
|
57
|
+
return new client_1.Orchestrator(orchestratorUrl ?? consts_1.PROD_ORCHESTRATOR_URL, apiKey);
|
|
58
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type Address, type Chain } from 'viem';
|
|
2
|
+
import type { TokenSymbol } from '../types';
|
|
3
|
+
import type { TokenConfig } from './types';
|
|
4
|
+
declare function getSupportedChainIds(): number[];
|
|
5
|
+
declare function getWethAddress(chain: Chain): Address;
|
|
6
|
+
declare function getTokenSymbol(tokenAddress: Address, chainId: number): string | undefined;
|
|
7
|
+
declare function getTokenAddress(tokenSymbol: TokenSymbol, chainId: number): Address;
|
|
8
|
+
declare function getTokenDecimals(tokenSymbol: TokenSymbol, chainId: number): number;
|
|
9
|
+
declare function getChainById(chainId: number): Chain;
|
|
10
|
+
declare function isTestnet(chainId: number): boolean;
|
|
11
|
+
declare function isTokenAddressSupported(address: Address, chainId: number): boolean;
|
|
12
|
+
declare function getSupportedTokens(chainId: number): TokenConfig[];
|
|
13
|
+
declare function getDefaultAccountAccessList(onTestnets?: boolean): {
|
|
14
|
+
chainIds: number[];
|
|
15
|
+
};
|
|
16
|
+
declare function resolveTokenAddress(token: TokenSymbol | Address, chainId: number): Address;
|
|
17
|
+
declare function getAllSupportedChainsAndTokens(): {
|
|
18
|
+
chainId: number;
|
|
19
|
+
tokens: TokenConfig[];
|
|
20
|
+
}[];
|
|
21
|
+
export { getTokenSymbol, getTokenAddress, getTokenDecimals, getWethAddress, getChainById, getSupportedTokens, getSupportedChainIds, isTestnet, isTokenAddressSupported, getDefaultAccountAccessList, resolveTokenAddress, getAllSupportedChainsAndTokens, };
|
|
22
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../orchestrator/registry.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,KAAK,EAAa,MAAM,MAAM,CAAA;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAE3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE1C,iBAAS,oBAAoB,IAAI,MAAM,EAAE,CAExC;AAMD,iBAAS,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAY7C;AAED,iBAAS,cAAc,CACrB,YAAY,EAAE,OAAO,EACrB,OAAO,EAAE,MAAM,GACd,MAAM,GAAG,SAAS,CAWpB;AAED,iBAAS,eAAe,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAY3E;AAED,iBAAS,gBAAgB,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAY3E;AAED,iBAAS,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK,CAM5C;AAED,iBAAS,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAG3C;AAED,iBAAS,uBAAuB,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAS3E;AAED,iBAAS,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,EAAE,CAO1D;AAED,iBAAS,2BAA2B,CAAC,UAAU,CAAC,EAAE,OAAO;;EAaxD;AAED,iBAAS,mBAAmB,CAC1B,KAAK,EAAE,WAAW,GAAG,OAAO,EAC5B,OAAO,EAAE,MAAM,GACd,OAAO,CAKT;AAED,iBAAS,8BAA8B,IAAI;IACzC,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,WAAW,EAAE,CAAA;CACtB,EAAE,CAMF;AAED,OAAO,EACL,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,kBAAkB,EAClB,oBAAoB,EACpB,SAAS,EACT,uBAAuB,EACvB,2BAA2B,EAC3B,mBAAmB,EACnB,8BAA8B,GAC/B,CAAA"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getTokenSymbol = getTokenSymbol;
|
|
4
|
+
exports.getTokenAddress = getTokenAddress;
|
|
5
|
+
exports.getTokenDecimals = getTokenDecimals;
|
|
6
|
+
exports.getWethAddress = getWethAddress;
|
|
7
|
+
exports.getChainById = getChainById;
|
|
8
|
+
exports.getSupportedTokens = getSupportedTokens;
|
|
9
|
+
exports.getSupportedChainIds = getSupportedChainIds;
|
|
10
|
+
exports.isTestnet = isTestnet;
|
|
11
|
+
exports.isTokenAddressSupported = isTokenAddressSupported;
|
|
12
|
+
exports.getDefaultAccountAccessList = getDefaultAccountAccessList;
|
|
13
|
+
exports.resolveTokenAddress = resolveTokenAddress;
|
|
14
|
+
exports.getAllSupportedChainsAndTokens = getAllSupportedChainsAndTokens;
|
|
15
|
+
const shared_configs_1 = require("@rhinestone/shared-configs");
|
|
16
|
+
const viem_1 = require("viem");
|
|
17
|
+
const error_1 = require("./error");
|
|
18
|
+
function getSupportedChainIds() {
|
|
19
|
+
return shared_configs_1.chains.map((chain) => chain.id);
|
|
20
|
+
}
|
|
21
|
+
function getChainEntry(chainId) {
|
|
22
|
+
return shared_configs_1.chainRegistry[chainId.toString()];
|
|
23
|
+
}
|
|
24
|
+
function getWethAddress(chain) {
|
|
25
|
+
const chainEntry = getChainEntry(chain.id);
|
|
26
|
+
if (!chainEntry) {
|
|
27
|
+
throw new error_1.UnsupportedChainError(chain.id);
|
|
28
|
+
}
|
|
29
|
+
const wethToken = chainEntry.tokens.find((token) => token.symbol === 'WETH');
|
|
30
|
+
if (!wethToken) {
|
|
31
|
+
throw new error_1.UnsupportedTokenError('WETH', chain.id);
|
|
32
|
+
}
|
|
33
|
+
return wethToken.address;
|
|
34
|
+
}
|
|
35
|
+
function getTokenSymbol(tokenAddress, chainId) {
|
|
36
|
+
const chainEntry = getChainEntry(chainId);
|
|
37
|
+
if (!chainEntry) {
|
|
38
|
+
throw new error_1.UnsupportedChainError(chainId);
|
|
39
|
+
}
|
|
40
|
+
const token = chainEntry.tokens.find((t) => t.address.toLowerCase() === tokenAddress.toLowerCase());
|
|
41
|
+
return token?.symbol;
|
|
42
|
+
}
|
|
43
|
+
function getTokenAddress(tokenSymbol, chainId) {
|
|
44
|
+
const chainEntry = getChainEntry(chainId);
|
|
45
|
+
if (!chainEntry) {
|
|
46
|
+
throw new error_1.UnsupportedChainError(chainId);
|
|
47
|
+
}
|
|
48
|
+
const token = chainEntry.tokens.find((t) => t.symbol === tokenSymbol);
|
|
49
|
+
if (!token) {
|
|
50
|
+
throw new error_1.UnsupportedTokenError(tokenSymbol, chainId);
|
|
51
|
+
}
|
|
52
|
+
return token.address;
|
|
53
|
+
}
|
|
54
|
+
function getTokenDecimals(tokenSymbol, chainId) {
|
|
55
|
+
const chainEntry = getChainEntry(chainId);
|
|
56
|
+
if (!chainEntry) {
|
|
57
|
+
throw new error_1.UnsupportedChainError(chainId);
|
|
58
|
+
}
|
|
59
|
+
const token = chainEntry.tokens.find((t) => t.symbol === tokenSymbol);
|
|
60
|
+
if (!token) {
|
|
61
|
+
throw new error_1.UnsupportedTokenError(tokenSymbol, chainId);
|
|
62
|
+
}
|
|
63
|
+
return token.decimals;
|
|
64
|
+
}
|
|
65
|
+
function getChainById(chainId) {
|
|
66
|
+
const chain = shared_configs_1.chains.find((chain) => chain.id === chainId);
|
|
67
|
+
if (!chain) {
|
|
68
|
+
throw new error_1.UnsupportedChainError(chainId);
|
|
69
|
+
}
|
|
70
|
+
return chain;
|
|
71
|
+
}
|
|
72
|
+
function isTestnet(chainId) {
|
|
73
|
+
const chain = getChainById(chainId);
|
|
74
|
+
return chain.testnet ?? false;
|
|
75
|
+
}
|
|
76
|
+
function isTokenAddressSupported(address, chainId) {
|
|
77
|
+
const chainEntry = getChainEntry(chainId);
|
|
78
|
+
if (!chainEntry) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
return chainEntry.tokens.some((token) => token.address.toLowerCase() === address.toLowerCase());
|
|
82
|
+
}
|
|
83
|
+
function getSupportedTokens(chainId) {
|
|
84
|
+
const chainEntry = getChainEntry(chainId);
|
|
85
|
+
if (!chainEntry) {
|
|
86
|
+
throw new error_1.UnsupportedChainError(chainId);
|
|
87
|
+
}
|
|
88
|
+
return chainEntry.tokens;
|
|
89
|
+
}
|
|
90
|
+
function getDefaultAccountAccessList(onTestnets) {
|
|
91
|
+
const supportedChainIds = getSupportedChainIds();
|
|
92
|
+
const filteredChainIds = supportedChainIds.filter((chainId) => {
|
|
93
|
+
try {
|
|
94
|
+
return isTestnet(chainId) === !!onTestnets;
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
return {
|
|
101
|
+
chainIds: filteredChainIds,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function resolveTokenAddress(token, chainId) {
|
|
105
|
+
if ((0, viem_1.isAddress)(token)) {
|
|
106
|
+
return token;
|
|
107
|
+
}
|
|
108
|
+
return getTokenAddress(token, chainId);
|
|
109
|
+
}
|
|
110
|
+
function getAllSupportedChainsAndTokens() {
|
|
111
|
+
const supportedChainIds = getSupportedChainIds();
|
|
112
|
+
return supportedChainIds.map((chainId) => ({
|
|
113
|
+
chainId,
|
|
114
|
+
tokens: getSupportedTokens(chainId),
|
|
115
|
+
}));
|
|
116
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.test.d.ts","sourceRoot":"","sources":["../../../orchestrator/registry.test.ts"],"names":[],"mappings":""}
|