@charterlabs/rhinestone-sdk 0.1.1 → 0.1.2
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 +74 -181
- package/dist/src/accounts/error.d.ts +69 -0
- package/dist/src/accounts/error.d.ts.map +1 -0
- package/dist/src/accounts/error.js +109 -0
- package/dist/{accounts → src/accounts}/index.d.ts +14 -21
- package/dist/src/accounts/index.d.ts.map +1 -0
- package/dist/src/accounts/index.js +469 -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 +36 -0
- package/dist/{accounts → src/accounts}/kernel.d.ts +7 -9
- package/dist/src/accounts/kernel.d.ts.map +1 -0
- package/dist/{accounts → src/accounts}/kernel.js +0 -8
- 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 +105 -0
- package/dist/{accounts → src/accounts}/nexus.d.ts +14 -13
- package/dist/src/accounts/nexus.d.ts.map +1 -0
- package/dist/{accounts → src/accounts}/nexus.js +92 -88
- 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 +87 -0
- package/dist/{accounts → src/accounts}/safe.d.ts +4 -6
- package/dist/src/accounts/safe.d.ts.map +1 -0
- package/dist/{accounts → src/accounts}/safe.js +20 -29
- 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 +87 -0
- package/dist/src/accounts/startale.d.ts +20 -0
- package/dist/src/accounts/startale.d.ts.map +1 -0
- package/dist/src/accounts/startale.js +100 -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 +99 -0
- package/dist/{accounts → src/accounts}/utils.d.ts +4 -3
- package/dist/src/accounts/utils.d.ts.map +1 -0
- package/dist/{accounts → src/accounts}/utils.js +44 -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/actions/index.d.ts +39 -0
- package/dist/src/actions/index.d.ts.map +1 -0
- package/dist/{actions → src/actions}/index.js +108 -15
- package/dist/src/actions/index.test.d.ts +2 -0
- package/dist/src/actions/index.test.d.ts.map +1 -0
- package/dist/src/actions/index.test.js +302 -0
- package/dist/{actions → src/actions}/smart-session.d.ts +2 -2
- package/dist/src/actions/smart-session.d.ts.map +1 -0
- package/dist/src/execution/compact.d.ts +8 -0
- package/dist/src/execution/compact.d.ts.map +1 -0
- package/dist/src/execution/compact.js +105 -0
- package/dist/src/execution/error.d.ts +54 -0
- package/dist/src/execution/error.d.ts.map +1 -0
- package/dist/src/execution/error.js +78 -0
- package/dist/{execution → src/execution}/index.d.ts +7 -6
- package/dist/src/execution/index.d.ts.map +1 -0
- package/dist/src/execution/index.js +150 -0
- package/dist/src/execution/smart-session.d.ts +15 -0
- package/dist/src/execution/smart-session.d.ts.map +1 -0
- package/dist/{execution → src/execution}/smart-session.js +16 -77
- package/dist/src/execution/smart-session.test.d.ts +2 -0
- package/dist/src/execution/smart-session.test.d.ts.map +1 -0
- package/dist/src/execution/smart-session.test.js +34 -0
- package/dist/src/execution/utils.d.ts +45 -0
- package/dist/src/execution/utils.d.ts.map +1 -0
- package/dist/src/execution/utils.js +433 -0
- package/dist/src/index.d.ts +41 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +154 -0
- package/dist/src/modules/abi/smart-sessions.d.ts.map +1 -0
- package/dist/src/modules/common.d.ts.map +1 -0
- package/dist/{modules → src/modules}/index.d.ts +3 -11
- package/dist/src/modules/index.d.ts.map +1 -0
- package/dist/{modules → src/modules}/index.js +3 -45
- 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 +107 -0
- package/dist/src/modules/omni-account.d.ts +7 -0
- package/dist/src/modules/omni-account.d.ts.map +1 -0
- package/dist/src/modules/omni-account.js +11 -0
- package/dist/src/modules/read.d.ts +9 -0
- package/dist/src/modules/read.d.ts.map +1 -0
- package/dist/{modules → src/modules}/read.js +6 -37
- package/dist/{modules → src/modules}/validators/core.d.ts +6 -7
- package/dist/src/modules/validators/core.d.ts.map +1 -0
- package/dist/{modules → src/modules}/validators/core.js +83 -8
- 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 +108 -0
- package/dist/src/modules/validators/index.d.ts +4 -0
- package/dist/src/modules/validators/index.d.ts.map +1 -0
- package/dist/{modules → src/modules}/validators/index.js +1 -3
- package/dist/{modules → src/modules}/validators/smart-sessions.d.ts +4 -15
- package/dist/src/modules/validators/smart-sessions.d.ts.map +1 -0
- package/dist/{modules → src/modules}/validators/smart-sessions.js +7 -61
- package/dist/src/modules/validators/smart-sessions.test.d.ts +2 -0
- package/dist/src/modules/validators/smart-sessions.test.d.ts.map +1 -0
- package/dist/src/modules/validators/smart-sessions.test.js +226 -0
- package/dist/src/orchestrator/client.d.ts +21 -0
- package/dist/src/orchestrator/client.d.ts.map +1 -0
- package/dist/src/orchestrator/client.js +284 -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 +96 -0
- package/dist/src/orchestrator/error.d.ts.map +1 -0
- package/dist/src/orchestrator/error.js +132 -0
- package/dist/src/orchestrator/index.d.ts +11 -0
- package/dist/src/orchestrator/index.d.ts.map +1 -0
- package/dist/src/orchestrator/index.js +42 -0
- package/dist/src/orchestrator/registry.d.ts +39 -0
- package/dist/src/orchestrator/registry.d.ts.map +1 -0
- package/dist/src/orchestrator/registry.js +121 -0
- package/dist/src/orchestrator/registry.json +365 -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 +137 -0
- package/dist/src/orchestrator/types.d.ts +275 -0
- package/dist/src/orchestrator/types.d.ts.map +1 -0
- package/dist/src/orchestrator/types.js +19 -0
- package/dist/src/orchestrator/utils.d.ts +5 -0
- package/dist/src/orchestrator/utils.d.ts.map +1 -0
- package/dist/src/orchestrator/utils.js +126 -0
- package/dist/{types.d.ts → src/types.d.ts} +42 -21
- package/dist/src/types.d.ts.map +1 -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/package.json +11 -20
- package/dist/accounts/index.d.ts.map +0 -1
- package/dist/accounts/index.js +0 -419
- package/dist/accounts/kernel.d.ts.map +0 -1
- package/dist/accounts/nexus.d.ts.map +0 -1
- package/dist/accounts/safe.d.ts.map +0 -1
- package/dist/accounts/utils.d.ts.map +0 -1
- package/dist/actions/index.d.ts +0 -29
- package/dist/actions/index.d.ts.map +0 -1
- package/dist/actions/registry.d.ts +0 -7
- package/dist/actions/registry.d.ts.map +0 -1
- package/dist/actions/registry.js +0 -7
- package/dist/actions/smart-session.d.ts.map +0 -1
- package/dist/execution/index.d.ts.map +0 -1
- package/dist/execution/index.js +0 -149
- package/dist/execution/smart-session.d.ts +0 -23
- package/dist/execution/smart-session.d.ts.map +0 -1
- package/dist/execution/utils.d.ts +0 -68
- package/dist/execution/utils.d.ts.map +0 -1
- package/dist/execution/utils.js +0 -482
- package/dist/index.d.ts +0 -38
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -119
- package/dist/modules/abi/smart-sessions.d.ts.map +0 -1
- package/dist/modules/common.d.ts.map +0 -1
- package/dist/modules/index.d.ts.map +0 -1
- package/dist/modules/omni-account.d.ts +0 -9
- package/dist/modules/omni-account.d.ts.map +0 -1
- package/dist/modules/omni-account.js +0 -15
- package/dist/modules/read.d.ts +0 -10
- package/dist/modules/read.d.ts.map +0 -1
- package/dist/modules/registry.d.ts +0 -9
- package/dist/modules/registry.d.ts.map +0 -1
- package/dist/modules/registry.js +0 -60
- package/dist/modules/validators/core.d.ts.map +0 -1
- package/dist/modules/validators/index.d.ts +0 -4
- package/dist/modules/validators/index.d.ts.map +0 -1
- package/dist/modules/validators/smart-sessions.d.ts.map +0 -1
- package/dist/orchestrator/client.d.ts +0 -29
- package/dist/orchestrator/client.d.ts.map +0 -1
- package/dist/orchestrator/client.js +0 -250
- package/dist/orchestrator/consts.d.ts +0 -5
- package/dist/orchestrator/consts.d.ts.map +0 -1
- package/dist/orchestrator/consts.js +0 -9
- package/dist/orchestrator/error.d.ts +0 -18
- package/dist/orchestrator/error.d.ts.map +0 -1
- package/dist/orchestrator/error.js +0 -33
- package/dist/orchestrator/index.d.ts +0 -11
- package/dist/orchestrator/index.d.ts.map +0 -1
- package/dist/orchestrator/index.js +0 -40
- package/dist/orchestrator/registry.d.ts +0 -20
- package/dist/orchestrator/registry.d.ts.map +0 -1
- package/dist/orchestrator/registry.js +0 -444
- package/dist/orchestrator/types.d.ts +0 -242
- package/dist/orchestrator/types.d.ts.map +0 -1
- package/dist/orchestrator/types.js +0 -19
- package/dist/orchestrator/utils.d.ts +0 -29
- package/dist/orchestrator/utils.d.ts.map +0 -1
- package/dist/orchestrator/utils.js +0 -319
- package/dist/types.d.ts.map +0 -1
- /package/dist/{actions → src/actions}/smart-session.js +0 -0
- /package/dist/{modules → src/modules}/abi/smart-sessions.d.ts +0 -0
- /package/dist/{modules → src/modules}/abi/smart-sessions.js +0 -0
- /package/dist/{modules → src/modules}/common.d.ts +0 -0
- /package/dist/{modules → src/modules}/common.js +0 -0
- /package/dist/{types.js → src/types.js} +0 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IntentNotFoundError = exports.NoPathFoundError = exports.OnlyOneTargetTokenAmountCanBeUnsetError = exports.InvalidIntentSignatureError = exports.InvalidApiKeyError = exports.AuthenticationRequiredError = exports.TokenNotSupportedError = exports.UnsupportedTokenError = exports.UnsupportedChainError = exports.UnsupportedChainIdError = exports.InsufficientBalanceError = exports.OrchestratorError = void 0;
|
|
4
|
+
exports.isOrchestratorError = isOrchestratorError;
|
|
5
|
+
class OrchestratorError extends Error {
|
|
6
|
+
_message;
|
|
7
|
+
_context;
|
|
8
|
+
_errorType;
|
|
9
|
+
_traceId;
|
|
10
|
+
constructor(params) {
|
|
11
|
+
super();
|
|
12
|
+
this._message = params?.message || 'OrchestratorError ';
|
|
13
|
+
this._context = params?.context || {};
|
|
14
|
+
this._errorType = params?.errorType || 'Unknown';
|
|
15
|
+
this._traceId = params?.traceId || '';
|
|
16
|
+
}
|
|
17
|
+
get message() {
|
|
18
|
+
return this._message;
|
|
19
|
+
}
|
|
20
|
+
get context() {
|
|
21
|
+
return this._context;
|
|
22
|
+
}
|
|
23
|
+
get errorType() {
|
|
24
|
+
return this._errorType;
|
|
25
|
+
}
|
|
26
|
+
get traceId() {
|
|
27
|
+
return this._traceId;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.OrchestratorError = OrchestratorError;
|
|
31
|
+
class InsufficientBalanceError extends OrchestratorError {
|
|
32
|
+
constructor(params) {
|
|
33
|
+
super({
|
|
34
|
+
message: 'Insufficient balance',
|
|
35
|
+
...params,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.InsufficientBalanceError = InsufficientBalanceError;
|
|
40
|
+
class UnsupportedChainIdError extends OrchestratorError {
|
|
41
|
+
constructor(params) {
|
|
42
|
+
super({
|
|
43
|
+
message: 'Unsupported chain id',
|
|
44
|
+
...params,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.UnsupportedChainIdError = UnsupportedChainIdError;
|
|
49
|
+
class UnsupportedChainError extends OrchestratorError {
|
|
50
|
+
constructor(chainId, params) {
|
|
51
|
+
super({
|
|
52
|
+
message: `Unsupported chain ${chainId}`,
|
|
53
|
+
...params,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.UnsupportedChainError = UnsupportedChainError;
|
|
58
|
+
class UnsupportedTokenError extends OrchestratorError {
|
|
59
|
+
constructor(tokenSymbol, chainId, params) {
|
|
60
|
+
super({
|
|
61
|
+
message: `Unsupported token ${tokenSymbol} for chain ${chainId}`,
|
|
62
|
+
...params,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.UnsupportedTokenError = UnsupportedTokenError;
|
|
67
|
+
class TokenNotSupportedError extends OrchestratorError {
|
|
68
|
+
constructor(tokenAddress, chainId, params) {
|
|
69
|
+
super({
|
|
70
|
+
message: `Token ${tokenAddress} not supported on chain ${chainId}`,
|
|
71
|
+
...params,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.TokenNotSupportedError = TokenNotSupportedError;
|
|
76
|
+
class AuthenticationRequiredError extends OrchestratorError {
|
|
77
|
+
constructor(params) {
|
|
78
|
+
super({
|
|
79
|
+
message: 'Authentication is required',
|
|
80
|
+
...params,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
exports.AuthenticationRequiredError = AuthenticationRequiredError;
|
|
85
|
+
class InvalidApiKeyError extends OrchestratorError {
|
|
86
|
+
constructor(params) {
|
|
87
|
+
super({
|
|
88
|
+
message: 'Invalid API key',
|
|
89
|
+
...params,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
exports.InvalidApiKeyError = InvalidApiKeyError;
|
|
94
|
+
class InvalidIntentSignatureError extends OrchestratorError {
|
|
95
|
+
constructor(params) {
|
|
96
|
+
super({
|
|
97
|
+
message: 'Invalid intent signature',
|
|
98
|
+
...params,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
exports.InvalidIntentSignatureError = InvalidIntentSignatureError;
|
|
103
|
+
class OnlyOneTargetTokenAmountCanBeUnsetError extends OrchestratorError {
|
|
104
|
+
constructor(params) {
|
|
105
|
+
super({
|
|
106
|
+
message: 'Only one target token amount can be unset',
|
|
107
|
+
...params,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
exports.OnlyOneTargetTokenAmountCanBeUnsetError = OnlyOneTargetTokenAmountCanBeUnsetError;
|
|
112
|
+
class NoPathFoundError extends OrchestratorError {
|
|
113
|
+
constructor(params) {
|
|
114
|
+
super({
|
|
115
|
+
message: 'No Path Found',
|
|
116
|
+
...params,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
exports.NoPathFoundError = NoPathFoundError;
|
|
121
|
+
class IntentNotFoundError extends OrchestratorError {
|
|
122
|
+
constructor(params) {
|
|
123
|
+
super({
|
|
124
|
+
message: 'Intent not found',
|
|
125
|
+
...params,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
exports.IntentNotFoundError = IntentNotFoundError;
|
|
130
|
+
function isOrchestratorError(error) {
|
|
131
|
+
return error instanceof OrchestratorError;
|
|
132
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Orchestrator } from './client';
|
|
2
|
+
import { RHINESTONE_SPOKE_POOL_ADDRESS } from './consts';
|
|
3
|
+
import { AuthenticationRequiredError, InsufficientBalanceError, IntentNotFoundError, InvalidApiKeyError, InvalidIntentSignatureError, isOrchestratorError, NoPathFoundError, OnlyOneTargetTokenAmountCanBeUnsetError, OrchestratorError, TokenNotSupportedError, UnsupportedChainError, UnsupportedChainIdError, UnsupportedTokenError } from './error';
|
|
4
|
+
import { getSupportedTokens, getTokenAddress, getTokenSymbol, getWethAddress, isTokenAddressSupported } from './registry';
|
|
5
|
+
import type { IntentCost, IntentInput, IntentOp, IntentOpStatus, IntentResult, IntentRoute, Portfolio, SettlementSystem, SignedIntentOp, SupportedChain, TokenConfig } from './types';
|
|
6
|
+
import { INTENT_STATUS_COMPLETED, INTENT_STATUS_EXPIRED, INTENT_STATUS_FAILED, INTENT_STATUS_FILLED, INTENT_STATUS_PARTIALLY_COMPLETED, INTENT_STATUS_PENDING, INTENT_STATUS_PRECONFIRMED, INTENT_STATUS_UNKNOWN } from './types';
|
|
7
|
+
import { getIntentOpHash } from './utils';
|
|
8
|
+
declare function getOrchestrator(apiKey: string, orchestratorUrl?: string): Orchestrator;
|
|
9
|
+
export type { IntentCost, IntentInput, IntentOp, IntentOpStatus, IntentResult, IntentRoute, SettlementSystem, SignedIntentOp, SupportedChain, TokenConfig, Portfolio, };
|
|
10
|
+
export { INTENT_STATUS_PENDING, INTENT_STATUS_EXPIRED, INTENT_STATUS_PARTIALLY_COMPLETED, INTENT_STATUS_COMPLETED, INTENT_STATUS_FILLED, INTENT_STATUS_FAILED, INTENT_STATUS_PRECONFIRMED, INTENT_STATUS_UNKNOWN, RHINESTONE_SPOKE_POOL_ADDRESS, Orchestrator, AuthenticationRequiredError, InsufficientBalanceError, InvalidApiKeyError, InvalidIntentSignatureError, NoPathFoundError, OnlyOneTargetTokenAmountCanBeUnsetError, OrchestratorError, IntentNotFoundError, TokenNotSupportedError, UnsupportedChainError, UnsupportedChainIdError, UnsupportedTokenError, getOrchestrator, getIntentOpHash, getWethAddress, getTokenSymbol, getTokenAddress, getSupportedTokens, isOrchestratorError, isTokenAddressSupported, };
|
|
11
|
+
//# 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,EAC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,eAAe,EACf,eAAe,EACf,cAAc,EACd,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,GACxB,CAAA"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isTokenAddressSupported = exports.isOrchestratorError = exports.getSupportedTokens = exports.getTokenAddress = exports.getTokenSymbol = exports.getWethAddress = exports.getIntentOpHash = exports.UnsupportedTokenError = exports.UnsupportedChainIdError = exports.UnsupportedChainError = exports.TokenNotSupportedError = exports.IntentNotFoundError = exports.OrchestratorError = exports.OnlyOneTargetTokenAmountCanBeUnsetError = exports.NoPathFoundError = exports.InvalidIntentSignatureError = exports.InvalidApiKeyError = exports.InsufficientBalanceError = exports.AuthenticationRequiredError = exports.Orchestrator = exports.RHINESTONE_SPOKE_POOL_ADDRESS = exports.INTENT_STATUS_UNKNOWN = exports.INTENT_STATUS_PRECONFIRMED = exports.INTENT_STATUS_FAILED = exports.INTENT_STATUS_FILLED = exports.INTENT_STATUS_COMPLETED = exports.INTENT_STATUS_PARTIALLY_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, "InsufficientBalanceError", { enumerable: true, get: function () { return error_1.InsufficientBalanceError; } });
|
|
12
|
+
Object.defineProperty(exports, "IntentNotFoundError", { enumerable: true, get: function () { return error_1.IntentNotFoundError; } });
|
|
13
|
+
Object.defineProperty(exports, "InvalidApiKeyError", { enumerable: true, get: function () { return error_1.InvalidApiKeyError; } });
|
|
14
|
+
Object.defineProperty(exports, "InvalidIntentSignatureError", { enumerable: true, get: function () { return error_1.InvalidIntentSignatureError; } });
|
|
15
|
+
Object.defineProperty(exports, "isOrchestratorError", { enumerable: true, get: function () { return error_1.isOrchestratorError; } });
|
|
16
|
+
Object.defineProperty(exports, "NoPathFoundError", { enumerable: true, get: function () { return error_1.NoPathFoundError; } });
|
|
17
|
+
Object.defineProperty(exports, "OnlyOneTargetTokenAmountCanBeUnsetError", { enumerable: true, get: function () { return error_1.OnlyOneTargetTokenAmountCanBeUnsetError; } });
|
|
18
|
+
Object.defineProperty(exports, "OrchestratorError", { enumerable: true, get: function () { return error_1.OrchestratorError; } });
|
|
19
|
+
Object.defineProperty(exports, "TokenNotSupportedError", { enumerable: true, get: function () { return error_1.TokenNotSupportedError; } });
|
|
20
|
+
Object.defineProperty(exports, "UnsupportedChainError", { enumerable: true, get: function () { return error_1.UnsupportedChainError; } });
|
|
21
|
+
Object.defineProperty(exports, "UnsupportedChainIdError", { enumerable: true, get: function () { return error_1.UnsupportedChainIdError; } });
|
|
22
|
+
Object.defineProperty(exports, "UnsupportedTokenError", { enumerable: true, get: function () { return error_1.UnsupportedTokenError; } });
|
|
23
|
+
const registry_1 = require("./registry");
|
|
24
|
+
Object.defineProperty(exports, "getSupportedTokens", { enumerable: true, get: function () { return registry_1.getSupportedTokens; } });
|
|
25
|
+
Object.defineProperty(exports, "getTokenAddress", { enumerable: true, get: function () { return registry_1.getTokenAddress; } });
|
|
26
|
+
Object.defineProperty(exports, "getTokenSymbol", { enumerable: true, get: function () { return registry_1.getTokenSymbol; } });
|
|
27
|
+
Object.defineProperty(exports, "getWethAddress", { enumerable: true, get: function () { return registry_1.getWethAddress; } });
|
|
28
|
+
Object.defineProperty(exports, "isTokenAddressSupported", { enumerable: true, get: function () { return registry_1.isTokenAddressSupported; } });
|
|
29
|
+
const types_1 = require("./types");
|
|
30
|
+
Object.defineProperty(exports, "INTENT_STATUS_COMPLETED", { enumerable: true, get: function () { return types_1.INTENT_STATUS_COMPLETED; } });
|
|
31
|
+
Object.defineProperty(exports, "INTENT_STATUS_EXPIRED", { enumerable: true, get: function () { return types_1.INTENT_STATUS_EXPIRED; } });
|
|
32
|
+
Object.defineProperty(exports, "INTENT_STATUS_FAILED", { enumerable: true, get: function () { return types_1.INTENT_STATUS_FAILED; } });
|
|
33
|
+
Object.defineProperty(exports, "INTENT_STATUS_FILLED", { enumerable: true, get: function () { return types_1.INTENT_STATUS_FILLED; } });
|
|
34
|
+
Object.defineProperty(exports, "INTENT_STATUS_PARTIALLY_COMPLETED", { enumerable: true, get: function () { return types_1.INTENT_STATUS_PARTIALLY_COMPLETED; } });
|
|
35
|
+
Object.defineProperty(exports, "INTENT_STATUS_PENDING", { enumerable: true, get: function () { return types_1.INTENT_STATUS_PENDING; } });
|
|
36
|
+
Object.defineProperty(exports, "INTENT_STATUS_PRECONFIRMED", { enumerable: true, get: function () { return types_1.INTENT_STATUS_PRECONFIRMED; } });
|
|
37
|
+
Object.defineProperty(exports, "INTENT_STATUS_UNKNOWN", { enumerable: true, get: function () { return types_1.INTENT_STATUS_UNKNOWN; } });
|
|
38
|
+
const utils_1 = require("./utils");
|
|
39
|
+
Object.defineProperty(exports, "getIntentOpHash", { enumerable: true, get: function () { return utils_1.getIntentOpHash; } });
|
|
40
|
+
function getOrchestrator(apiKey, orchestratorUrl) {
|
|
41
|
+
return new client_1.Orchestrator(orchestratorUrl ?? consts_1.PROD_ORCHESTRATOR_URL, apiKey);
|
|
42
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type Address, type Chain } from 'viem';
|
|
2
|
+
import type { TokenSymbol } from '../types';
|
|
3
|
+
import type { TokenConfig } from './types';
|
|
4
|
+
interface TokenEntry {
|
|
5
|
+
symbol: string;
|
|
6
|
+
address: Address;
|
|
7
|
+
decimals: number;
|
|
8
|
+
balanceSlot: number | null;
|
|
9
|
+
}
|
|
10
|
+
interface ChainContracts {
|
|
11
|
+
spokepool: Address;
|
|
12
|
+
hook: Address;
|
|
13
|
+
originModule: Address;
|
|
14
|
+
targetModule: Address;
|
|
15
|
+
sameChainModule: Address;
|
|
16
|
+
}
|
|
17
|
+
interface ChainEntry {
|
|
18
|
+
name: string;
|
|
19
|
+
contracts: ChainContracts;
|
|
20
|
+
tokens: TokenEntry[];
|
|
21
|
+
}
|
|
22
|
+
interface Registry {
|
|
23
|
+
[chainId: string]: ChainEntry;
|
|
24
|
+
}
|
|
25
|
+
declare function getSupportedChainIds(): number[];
|
|
26
|
+
declare function getWethAddress(chain: Chain): Address;
|
|
27
|
+
declare function getTokenSymbol(tokenAddress: Address, chainId: number): string;
|
|
28
|
+
declare function getTokenAddress(tokenSymbol: TokenSymbol, chainId: number): Address;
|
|
29
|
+
declare function getChainById(chainId: number): Chain | undefined;
|
|
30
|
+
declare function isTestnet(chainId: number): boolean;
|
|
31
|
+
declare function isTokenAddressSupported(address: Address, chainId: number): boolean;
|
|
32
|
+
declare function getSupportedTokens(chainId: number): TokenConfig[];
|
|
33
|
+
declare function getDefaultAccountAccessList(onTestnets?: boolean): {
|
|
34
|
+
chainIds: number[];
|
|
35
|
+
};
|
|
36
|
+
declare function resolveTokenAddress(token: TokenSymbol | Address, chainId: number): Address;
|
|
37
|
+
export { getTokenSymbol, getTokenAddress, getWethAddress, getChainById, getSupportedTokens, getSupportedChainIds, isTestnet, isTokenAddressSupported, getDefaultAccountAccessList, resolveTokenAddress, };
|
|
38
|
+
export type { TokenEntry, ChainContracts, ChainEntry, Registry };
|
|
39
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../orchestrator/registry.ts"],"names":[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AAkB,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,OAAO,EACL,cAAc,EACd,eAAe,EACf,cAAc,EACd,YAAY,EACZ,kBAAkB,EAClB,oBAAoB,EACpB,SAAS,EACT,uBAAuB,EACvB,2BAA2B,EAC3B,mBAAmB,GACpB,CAAA;AAGD,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAA"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getTokenSymbol = getTokenSymbol;
|
|
7
|
+
exports.getTokenAddress = getTokenAddress;
|
|
8
|
+
exports.getWethAddress = getWethAddress;
|
|
9
|
+
exports.getChainById = getChainById;
|
|
10
|
+
exports.getSupportedTokens = getSupportedTokens;
|
|
11
|
+
exports.getSupportedChainIds = getSupportedChainIds;
|
|
12
|
+
exports.isTestnet = isTestnet;
|
|
13
|
+
exports.isTokenAddressSupported = isTokenAddressSupported;
|
|
14
|
+
exports.getDefaultAccountAccessList = getDefaultAccountAccessList;
|
|
15
|
+
exports.resolveTokenAddress = resolveTokenAddress;
|
|
16
|
+
const viem_1 = require("viem");
|
|
17
|
+
const chains_1 = require("viem/chains");
|
|
18
|
+
const registry_json_1 = __importDefault(require("./registry.json"));
|
|
19
|
+
const registry = registry_json_1.default;
|
|
20
|
+
function getSupportedChainIds() {
|
|
21
|
+
return Object.keys(registry).map((chainId) => parseInt(chainId, 10));
|
|
22
|
+
}
|
|
23
|
+
function getChainEntry(chainId) {
|
|
24
|
+
return registry[chainId.toString()];
|
|
25
|
+
}
|
|
26
|
+
function getWethAddress(chain) {
|
|
27
|
+
const chainEntry = getChainEntry(chain.id);
|
|
28
|
+
if (!chainEntry) {
|
|
29
|
+
throw new Error(`Unsupported chain ${chain.id}`);
|
|
30
|
+
}
|
|
31
|
+
const wethToken = chainEntry.tokens.find((token) => token.symbol === 'WETH');
|
|
32
|
+
if (!wethToken) {
|
|
33
|
+
throw new Error(`WETH not found for chain ${chain.id}`);
|
|
34
|
+
}
|
|
35
|
+
return wethToken.address;
|
|
36
|
+
}
|
|
37
|
+
function getTokenSymbol(tokenAddress, chainId) {
|
|
38
|
+
const chainEntry = getChainEntry(chainId);
|
|
39
|
+
if (!chainEntry) {
|
|
40
|
+
throw new Error(`Unsupported chain ${chainId}`);
|
|
41
|
+
}
|
|
42
|
+
const token = chainEntry.tokens.find((t) => t.address.toLowerCase() === tokenAddress.toLowerCase());
|
|
43
|
+
if (!token) {
|
|
44
|
+
throw new Error(`Unsupported token address ${tokenAddress} for chain ${chainId}`);
|
|
45
|
+
}
|
|
46
|
+
return token.symbol;
|
|
47
|
+
}
|
|
48
|
+
function getTokenAddress(tokenSymbol, chainId) {
|
|
49
|
+
if (chainId === 137 && tokenSymbol === 'ETH') {
|
|
50
|
+
throw new Error(`Chain ${chainId} does not allow for ETH to be used`);
|
|
51
|
+
}
|
|
52
|
+
if (tokenSymbol === 'ETH') {
|
|
53
|
+
return viem_1.zeroAddress;
|
|
54
|
+
}
|
|
55
|
+
const chainEntry = getChainEntry(chainId);
|
|
56
|
+
if (!chainEntry) {
|
|
57
|
+
throw new Error(`Unsupported chain ${chainId}`);
|
|
58
|
+
}
|
|
59
|
+
const token = chainEntry.tokens.find((t) => t.symbol === tokenSymbol);
|
|
60
|
+
if (!token) {
|
|
61
|
+
throw new Error(`Unsupported token symbol ${tokenSymbol}`);
|
|
62
|
+
}
|
|
63
|
+
return token.address;
|
|
64
|
+
}
|
|
65
|
+
function getChainById(chainId) {
|
|
66
|
+
const supportedChains = [
|
|
67
|
+
chains_1.mainnet,
|
|
68
|
+
chains_1.sepolia,
|
|
69
|
+
chains_1.base,
|
|
70
|
+
chains_1.baseSepolia,
|
|
71
|
+
chains_1.arbitrum,
|
|
72
|
+
chains_1.arbitrumSepolia,
|
|
73
|
+
chains_1.optimism,
|
|
74
|
+
chains_1.optimismSepolia,
|
|
75
|
+
chains_1.polygon,
|
|
76
|
+
chains_1.zksync,
|
|
77
|
+
chains_1.soneium,
|
|
78
|
+
];
|
|
79
|
+
return supportedChains.find((chain) => chain.id === chainId);
|
|
80
|
+
}
|
|
81
|
+
function isTestnet(chainId) {
|
|
82
|
+
const chain = getChainById(chainId);
|
|
83
|
+
if (!chain) {
|
|
84
|
+
throw new Error(`Chain not supported: ${chainId}`);
|
|
85
|
+
}
|
|
86
|
+
return chain.testnet ?? false;
|
|
87
|
+
}
|
|
88
|
+
function isTokenAddressSupported(address, chainId) {
|
|
89
|
+
const chainEntry = getChainEntry(chainId);
|
|
90
|
+
if (!chainEntry) {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
return chainEntry.tokens.some((token) => token.address.toLowerCase() === address.toLowerCase());
|
|
94
|
+
}
|
|
95
|
+
function getSupportedTokens(chainId) {
|
|
96
|
+
const chainEntry = getChainEntry(chainId);
|
|
97
|
+
if (!chainEntry) {
|
|
98
|
+
throw new Error(`Chain not supported: ${chainId}`);
|
|
99
|
+
}
|
|
100
|
+
return chainEntry.tokens;
|
|
101
|
+
}
|
|
102
|
+
function getDefaultAccountAccessList(onTestnets) {
|
|
103
|
+
const supportedChainIds = getSupportedChainIds();
|
|
104
|
+
const filteredChainIds = supportedChainIds.filter((chainId) => {
|
|
105
|
+
try {
|
|
106
|
+
return isTestnet(chainId) === !!onTestnets;
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
return {
|
|
113
|
+
chainIds: filteredChainIds,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
function resolveTokenAddress(token, chainId) {
|
|
117
|
+
if ((0, viem_1.isAddress)(token)) {
|
|
118
|
+
return token;
|
|
119
|
+
}
|
|
120
|
+
return getTokenAddress(token, chainId);
|
|
121
|
+
}
|