@rhinestone/sdk 2.0.0-beta.43 → 2.0.0-beta.44
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 +2 -2
- package/dist/src/accounts/json-rpc/index.d.ts.map +1 -1
- package/dist/src/accounts/json-rpc/index.js +6 -12
- package/dist/src/accounts/json-rpc/providers.d.ts +1 -3
- package/dist/src/accounts/json-rpc/providers.d.ts.map +1 -1
- package/dist/src/accounts/json-rpc/providers.js +1 -13
- package/dist/src/accounts/nexus.d.ts +2 -2
- package/dist/src/accounts/nexus.d.ts.map +1 -1
- package/dist/src/accounts/nexus.js +61 -10
- package/dist/src/execution/index.d.ts.map +1 -1
- package/dist/src/execution/index.js +9 -10
- package/dist/src/execution/utils.d.ts.map +1 -1
- package/dist/src/execution/utils.js +16 -19
- package/dist/src/index.d.ts +11 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +27 -1
- package/dist/src/modules/validators/cross-chain-permits.d.ts +3 -2
- package/dist/src/modules/validators/cross-chain-permits.d.ts.map +1 -1
- package/dist/src/modules/validators/cross-chain-permits.js +5 -9
- package/dist/src/modules/validators/policies/claim/arbiters.d.ts +8 -11
- package/dist/src/modules/validators/policies/claim/arbiters.d.ts.map +1 -1
- package/dist/src/modules/validators/policies/claim/arbiters.js +50 -27
- package/dist/src/modules/validators/smart-sessions.d.ts +1 -0
- package/dist/src/modules/validators/smart-sessions.d.ts.map +1 -1
- package/dist/src/modules/validators/smart-sessions.js +22 -14
- package/dist/src/orchestrator/caip2.d.ts +1 -3
- package/dist/src/orchestrator/caip2.d.ts.map +1 -1
- package/dist/src/orchestrator/caip2.js +30 -21
- package/dist/src/orchestrator/chain-catalog.d.ts +34 -0
- package/dist/src/orchestrator/chain-catalog.d.ts.map +1 -0
- package/dist/src/orchestrator/chain-catalog.js +46 -0
- package/dist/src/orchestrator/client.d.ts +14 -0
- package/dist/src/orchestrator/client.d.ts.map +1 -1
- package/dist/src/orchestrator/client.js +46 -0
- package/dist/src/orchestrator/consts.d.ts +1 -1
- package/dist/src/orchestrator/consts.js +1 -1
- package/dist/src/orchestrator/index.d.ts +1 -2
- package/dist/src/orchestrator/index.d.ts.map +1 -1
- package/dist/src/orchestrator/index.js +1 -2
- package/dist/src/orchestrator/registry.d.ts +2 -12
- package/dist/src/orchestrator/registry.d.ts.map +1 -1
- package/dist/src/orchestrator/registry.js +26 -83
- package/dist/src/orchestrator/types.d.ts +9 -12
- package/dist/src/orchestrator/types.d.ts.map +1 -1
- package/dist/src/orchestrator/wire.d.ts +1 -0
- package/dist/src/orchestrator/wire.d.ts.map +1 -1
- package/dist/src/orchestrator/wire.gen.d.ts +26 -6
- package/dist/src/orchestrator/wire.gen.d.ts.map +1 -1
- package/dist/src/types.d.ts +15 -19
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +1 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arbiters.d.ts","sourceRoot":"","sources":["../../../../../../modules/validators/policies/claim/arbiters.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"arbiters.d.ts","sourceRoot":"","sources":["../../../../../../modules/validators/policies/claim/arbiters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AACnC,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAA;AAoDlE;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,SAAS,yBAAyB,EAAE,GAAG,SAAS,EACxD,eAAe,CAAC,EAAE,OAAO,GACxB,OAAO,EAAE,GAAG,SAAS,CA2BvB"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { contractAddresses, contractAddressesDev, } from '@rhinestone/shared-configs';
|
|
2
1
|
/**
|
|
3
|
-
* The contract
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* regardless of which one the orchestrator picks at intent time.
|
|
2
|
+
* The arbiter contract keys that each settlement layer expands to. `ACROSS`
|
|
3
|
+
* whitelists both arbiter impls so a session is permissioned for the 7579 and
|
|
4
|
+
* multicall paths regardless of which one the orchestrator picks at intent time.
|
|
7
5
|
*/
|
|
8
6
|
const SETTLEMENT_LAYER_CONTRACT_KEYS = {
|
|
9
7
|
SAME_CHAIN: ['samechainArbiter'],
|
|
@@ -11,18 +9,47 @@ const SETTLEMENT_LAYER_CONTRACT_KEYS = {
|
|
|
11
9
|
ACROSS: ['across7579Arbiter', 'acrossMulticallArbiter'],
|
|
12
10
|
};
|
|
13
11
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* is what the Permit2 claim policy enforces on-chain — a session signed
|
|
17
|
-
* once with this whitelist is valid against any of those arbiters.
|
|
12
|
+
* Bundled arbiter allow-set — the deployed arbiter addresses per key, per
|
|
13
|
+
* environment (the union across chains).
|
|
18
14
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
15
|
+
* v2: this is a small, signed-path **constant** bundled in the SDK rather than
|
|
16
|
+
* read from `@rhinestone/shared-configs`. The arbiter is baked into the user's
|
|
17
|
+
* Permit2 session signature, so it must stay **client-trusted** — never sourced
|
|
18
|
+
* from the orchestrator you transact against. Rhinestone's arbiters are CREATE2
|
|
19
|
+
* and near-uniform across chains, so this is a handful of addresses per key
|
|
20
|
+
* (e.g. `ecoArbiter` has a mainnet and a testnet address). A new *chain* reuses
|
|
21
|
+
* these; only a contract redeploy or a new settlement layer changes them.
|
|
22
|
+
*/
|
|
23
|
+
const ARBITER_ADDRESSES = {
|
|
24
|
+
prod: {
|
|
25
|
+
samechainArbiter: ['0x000000000006e2569CaF8Ff021810790e0A0D740'],
|
|
26
|
+
ecoArbiter: [
|
|
27
|
+
'0x2e7627CCfAe4eDb336eEb5a70f08415B0F1a2b8C',
|
|
28
|
+
'0xA212A6ACCC8db0e4cdf4394D0A851c70Fc27A8F0',
|
|
29
|
+
],
|
|
30
|
+
across7579Arbiter: ['0x28a4D41776968c1201A807ec51fFB405362B8882'],
|
|
31
|
+
acrossMulticallArbiter: ['0xA162fabb9a0EeF2736485A587aAAB3d015e14224'],
|
|
32
|
+
},
|
|
33
|
+
dev: {
|
|
34
|
+
samechainArbiter: ['0x8fA7720Eee299223f25De8DC03C68A28541dCD10'],
|
|
35
|
+
ecoArbiter: [
|
|
36
|
+
'0x1BeBAfb3D05d84A5Bfd94800c88d1342f755d8AB',
|
|
37
|
+
'0x8A061029AE4c5Cf69b5368119B3b0C80B31F55fE',
|
|
38
|
+
],
|
|
39
|
+
across7579Arbiter: ['0x1b19973F7a29E950ad4FaF8872745B6378005517'],
|
|
40
|
+
acrossMulticallArbiter: ['0x8343FBBA0526deC1c952A098057021027648bcf9'],
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Collects every distinct arbiter address for the given settlement layers. The
|
|
45
|
+
* resulting whitelist is what the Permit2 claim policy enforces on-chain — a
|
|
46
|
+
* session signed once with this whitelist is valid against any of those
|
|
47
|
+
* arbiters.
|
|
48
|
+
*
|
|
49
|
+
* **"Any" means any of the *supported* settlement layers**, not any address on
|
|
50
|
+
* earth. When `layers` is empty or undefined, this expands to the union of
|
|
51
|
+
* every layer in {@link SETTLEMENT_LAYER_CONTRACT_KEYS}, so the on-chain arbiter
|
|
52
|
+
* check stays meaningful (the worst case is still a Rhinestone-blessed arbiter).
|
|
26
53
|
*
|
|
27
54
|
* @param layers Settlement layers the session is permitted to use.
|
|
28
55
|
* Empty/undefined ⇒ all supported layers.
|
|
@@ -32,20 +59,16 @@ export function getArbitersForSettlementLayers(layers, useDevContracts) {
|
|
|
32
59
|
const effectiveLayers = !layers || layers.length === 0
|
|
33
60
|
? Object.keys(SETTLEMENT_LAYER_CONTRACT_KEYS)
|
|
34
61
|
: layers;
|
|
35
|
-
const
|
|
62
|
+
const book = ARBITER_ADDRESSES[useDevContracts ? 'dev' : 'prod'];
|
|
36
63
|
const keys = effectiveLayers.flatMap((l) => SETTLEMENT_LAYER_CONTRACT_KEYS[l]);
|
|
37
64
|
const seen = new Set();
|
|
38
65
|
const addresses = [];
|
|
39
|
-
//
|
|
40
|
-
//
|
|
41
|
-
//
|
|
42
|
-
//
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
for (const key of keys) {
|
|
46
|
-
const addr = chainContracts[key];
|
|
47
|
-
if (!addr)
|
|
48
|
-
continue;
|
|
66
|
+
// The same logical arbiter often shares an address across chains, but a given
|
|
67
|
+
// key may have multiple addresses live (e.g. a mainnet + testnet deployment).
|
|
68
|
+
// Collect every unique address for the requested keys, deduped
|
|
69
|
+
// case-insensitively.
|
|
70
|
+
for (const key of keys) {
|
|
71
|
+
for (const addr of book[key] ?? []) {
|
|
49
72
|
const norm = addr.toLowerCase();
|
|
50
73
|
if (seen.has(norm))
|
|
51
74
|
continue;
|
|
@@ -190,6 +190,7 @@ declare function getDisableSessionCall(account: Address, session: Session, expir
|
|
|
190
190
|
}>;
|
|
191
191
|
declare function toSession<const TAbis extends readonly Abi[]>(definition: SessionDefinition<TAbis>, options?: {
|
|
192
192
|
useDevContracts?: boolean;
|
|
193
|
+
wrappedNativeToken?: Address;
|
|
193
194
|
}): Session;
|
|
194
195
|
/**
|
|
195
196
|
* Selects the claim policy whose constraints the given Permit2 message
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smart-sessions.d.ts","sourceRoot":"","sources":["../../../../modules/validators/smart-sessions.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,GAAG,EACR,KAAK,OAAO,EAMZ,KAAK,GAAG,EAQR,KAAK,mBAAmB,EAKzB,MAAM,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"smart-sessions.d.ts","sourceRoot":"","sources":["../../../../modules/validators/smart-sessions.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,GAAG,EACR,KAAK,OA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AQ,GAAG,KAAK,GAAG,SAAS,CAAA;AAEzD,iBAAS,kBAAkB,CACzB,OAAO,EAAE,OAAO,EAChB,eAAe,CAAC,EAAE,OAAO,EACzB,UAAU,GAAE,MAAU,EACtB,aAAa,CAAC,EAAE,MAAM,EAEtB,KAAK,GAAE,qBAAgC,GACtC,GAAG,CAiDL;AASD,OAAO,EACL,8BAA8B,EAC9B,kCAAkC,EAClC,mCAAmC,EACnC,4CAA4C,EAC5C,2EAA2E,EAC3E,uBAAuB,EACvB,yBAAyB,EACzB,8BAA8B,EAC9B,yBAAyB,EACzB,mBAAmB,EACnB,+BAA+B,EAC/B,kBAAkB,EAClB,0BAA0B,EAC1B,0BAA0B,EAC1B,+BAA+B,EAC/B,aAAa,EACb,SAAS,EACT,yBAAyB,EACzB,kCAAkC,EAClC,cAAc,EACd,aAAa,EACb,oBAAoB,EACpB,qBAAqB,EACrB,eAAe,EACf,wBAAwB,EACxB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,GACnB,CAAA;AACD,YAAY,EACV,YAAY,EACZ,WAAW,EACX,wBAAwB,EACxB,WAAW,EACX,oBAAoB,EACpB,cAAc,GACf,CAAA"}
|
|
@@ -6,7 +6,7 @@ import { K1_DEFAULT_VALIDATOR_ADDRESS } from '../../accounts/startale.js';
|
|
|
6
6
|
import { createTransport } from '../../accounts/utils.js';
|
|
7
7
|
import { RESET_PERIOD_ONE_WEEK, SCOPE_MULTICHAIN, } from '../../execution/compact.js';
|
|
8
8
|
import { signTypedData } from '../../execution/utils.js';
|
|
9
|
-
import { getChainById
|
|
9
|
+
import { getChainById } from '../../orchestrator/registry.js';
|
|
10
10
|
import smartSessionEmissaryAbi from '../abi/smart-session-emissary.js';
|
|
11
11
|
import { MODULE_TYPE_ID_VALIDATOR } from '../common.js';
|
|
12
12
|
import { getOwnerValidator, getValidator, ownerSetUsesEns, SMART_SESSION_EMISSARY_ADDRESS, SMART_SESSION_EMISSARY_ADDRESS_DEV, } from './core.js';
|
|
@@ -494,7 +494,7 @@ async function getDisableSessionCall(account, session, expires, provider, useDev
|
|
|
494
494
|
}
|
|
495
495
|
function toSession(definition, options = {}) {
|
|
496
496
|
const addresses = resolvePolicyAddresses(definition.policyAddresses);
|
|
497
|
-
const sessionData = resolveSessionData(definition, options.useDevContracts, addresses);
|
|
497
|
+
const sessionData = resolveSessionData(definition, options.useDevContracts, addresses, options.wrappedNativeToken);
|
|
498
498
|
// Cross-chain permits add synthesized claim policies that must appear
|
|
499
499
|
// on the returned `Session` too — `getSessionData(session)` re-encodes
|
|
500
500
|
// from `session.claimPolicies` at signing time, so missing entries
|
|
@@ -705,7 +705,7 @@ function resolvePermit2ClaimPolicy(policy) {
|
|
|
705
705
|
})),
|
|
706
706
|
};
|
|
707
707
|
}
|
|
708
|
-
function resolveSessionData(session, useDevContracts, addresses = DEFAULT_POLICY_ADDRESSES) {
|
|
708
|
+
function resolveSessionData(session, useDevContracts, addresses = DEFAULT_POLICY_ADDRESSES, wrappedNativeToken) {
|
|
709
709
|
// ENS validation is HCA-only, and HCA accounts cannot install the smart
|
|
710
710
|
// session validator, so an ENS session owner would silently resolve to the
|
|
711
711
|
// HCA module and sign/enable against a validator the account does not have.
|
|
@@ -749,18 +749,26 @@ function resolveSessionData(session, useDevContracts, addresses = DEFAULT_POLICY
|
|
|
749
749
|
const expandedPermits = (session.crossChainPermits ?? []).map((p) => expandCrossChainPermit(p, useDevContracts));
|
|
750
750
|
const extraClaimPolicies = expandedPermits.map((e) => e.claim);
|
|
751
751
|
const permitFallbackPolicies = expandedPermits.flatMap((e) => e.fallbackPolicies);
|
|
752
|
+
// Native-token wrapping: permit `deposit()` on the chain's wrapped-native
|
|
753
|
+
// token. Only injected when the wrapped-native address is known — supplied by
|
|
754
|
+
// `RhinestoneSDK.createSession` (resolved from `/chains`). Direct `toSession`
|
|
755
|
+
// callers pass `wrappedNativeToken` to opt in.
|
|
756
|
+
const nativeWrapActions = wrappedNativeToken
|
|
757
|
+
? [
|
|
758
|
+
{
|
|
759
|
+
target: wrappedNativeToken,
|
|
760
|
+
selector: toFunctionSelector({
|
|
761
|
+
type: 'function',
|
|
762
|
+
name: 'deposit',
|
|
763
|
+
inputs: [],
|
|
764
|
+
outputs: [],
|
|
765
|
+
stateMutability: 'payable',
|
|
766
|
+
}),
|
|
767
|
+
},
|
|
768
|
+
]
|
|
769
|
+
: [];
|
|
752
770
|
const injectedActions = [
|
|
753
|
-
|
|
754
|
-
{
|
|
755
|
-
target: getWrappedTokenAddress(session.chain),
|
|
756
|
-
selector: toFunctionSelector({
|
|
757
|
-
type: 'function',
|
|
758
|
-
name: 'deposit',
|
|
759
|
-
inputs: [],
|
|
760
|
-
outputs: [],
|
|
761
|
-
stateMutability: 'payable',
|
|
762
|
-
}),
|
|
763
|
-
},
|
|
771
|
+
...nativeWrapActions,
|
|
764
772
|
// Intent-execution fallback for any non-scoped call. Cross-chain
|
|
765
773
|
// permits attach their synthesized SpendingLimits / TimeFrame
|
|
766
774
|
// guardrails to this same fallback so the on-chain emissary applies
|
|
@@ -10,9 +10,7 @@ declare function isEvmCaip2(chainId: string): chainId is EvmCaip2ChainId;
|
|
|
10
10
|
/**
|
|
11
11
|
* True when a numeric chain id is genuinely non-EVM (Solana / Tron). HyperCore
|
|
12
12
|
* (1337) is EVM-settled, so this is `false` for it even though its wire id is
|
|
13
|
-
* the non
|
|
14
|
-
* `execution/utils.ts` rely on HyperCore being EVM-classified here. Sourced
|
|
15
|
-
* from the shared-configs registry `vmType`.
|
|
13
|
+
* the non-`eip155` `hypercore:mainnet` namespace.
|
|
16
14
|
*/
|
|
17
15
|
declare function isNonEvmChainId(chainId: number): boolean;
|
|
18
16
|
export type { Caip2ChainId, EvmCaip2ChainId, SolanaCaip2ChainId, TronCaip2ChainId, HyperCoreCaip2ChainId, };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"caip2.d.ts","sourceRoot":"","sources":["../../../orchestrator/caip2.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"caip2.d.ts","sourceRoot":"","sources":["../../../orchestrator/caip2.ts"],"names":[],"mappings":"AAWA,KAAK,eAAe,GAAG,UAAU,MAAM,EAAE,CAAA;AACzC,KAAK,kBAAkB,GAAG,UAAU,MAAM,EAAE,CAAA;AAC5C,KAAK,gBAAgB,GAAG,QAAQ,MAAM,EAAE,CAAA;AACxC,KAAK,qBAAqB,GAAG,mBAAmB,CAAA;AAChD,KAAK,YAAY,GACb,eAAe,GACf,kBAAkB,GAClB,gBAAgB,GAChB,qBAAqB,CAAA;AAqBzB,iBAAS,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,CAM9C;AAED,iBAAS,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAS1C;AAED,iBAAS,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,IAAI,YAAY,CAGzD;AAED,iBAAS,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,IAAI,eAAe,CAE/D;AAED;;;;GAIG;AACH,iBAAS,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAEjD;AAED,YAAY,EACV,YAAY,EACZ,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,GACtB,CAAA;AACD,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,OAAO,EAAE,CAAA"}
|
|
@@ -1,37 +1,48 @@
|
|
|
1
|
-
// CAIP-2 wire format.
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
1
|
+
// CAIP-2 wire format. EVM chains map programmatically (`eip155:<id>`); the
|
|
2
|
+
// handful of non-EVM / virtual chains carry an explicit id ↔ caip2 mapping.
|
|
3
|
+
//
|
|
4
|
+
// v2: this small table is bundled here rather than read from
|
|
5
|
+
// `@rhinestone/shared-configs`. EVM is the common case and needs no table, so a
|
|
6
|
+
// new EVM chain needs no SDK change; a new non-EVM chain is rare and adds one
|
|
7
|
+
// entry below. HyperCore is EVM-settled (id 1337) so `isNonEvmChainId` is
|
|
8
|
+
// `false` for it even though its wire id is the non-`eip155` `hypercore:mainnet`.
|
|
7
9
|
//
|
|
8
10
|
// Spec: https://chainagnostic.org/CAIPs/caip-2
|
|
9
|
-
|
|
11
|
+
// Non-`eip155` chains. `nonEvm` distinguishes genuinely non-EVM VMs
|
|
12
|
+
// (Solana/Tron) from EVM-settled virtual chains (HyperCore) — see
|
|
13
|
+
// `isNonEvmChainId`.
|
|
14
|
+
const NON_EVM_CHAINS = [
|
|
15
|
+
{ id: 1337, caip2: 'hypercore:mainnet', nonEvm: false },
|
|
16
|
+
{ id: 728126428, caip2: 'tron:mainnet', nonEvm: true },
|
|
17
|
+
{
|
|
18
|
+
id: 792703809,
|
|
19
|
+
caip2: 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp',
|
|
20
|
+
nonEvm: true,
|
|
21
|
+
},
|
|
22
|
+
];
|
|
10
23
|
const EIP155_CAIP2_REGEX = /^eip155:\d+$/;
|
|
11
24
|
function toCaip2(chainId) {
|
|
12
25
|
if (!Number.isInteger(chainId) || chainId < 0) {
|
|
13
26
|
throw new Error(`Invalid chain id: ${chainId}`);
|
|
14
27
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return getCaip2(chainId);
|
|
28
|
+
const nonEvm = NON_EVM_CHAINS.find((c) => c.id === chainId);
|
|
29
|
+
return nonEvm ? nonEvm.caip2 : `eip155:${chainId}`;
|
|
18
30
|
}
|
|
19
31
|
function fromCaip2(chainId) {
|
|
20
|
-
// eip155 references
|
|
21
|
-
//
|
|
22
|
-
// `eip155:1337` HyperCore id for back-compat.
|
|
32
|
+
// eip155 references compose programmatically. This also keeps accepting the
|
|
33
|
+
// legacy `eip155:1337` HyperCore id for back-compat.
|
|
23
34
|
if (EIP155_CAIP2_REGEX.test(chainId)) {
|
|
24
35
|
return Number(chainId.slice('eip155:'.length));
|
|
25
36
|
}
|
|
26
|
-
const
|
|
27
|
-
if (
|
|
28
|
-
return id;
|
|
37
|
+
const entry = NON_EVM_CHAINS.find((c) => c.caip2 === chainId);
|
|
38
|
+
if (entry)
|
|
39
|
+
return entry.id;
|
|
29
40
|
throw new Error(`Invalid CAIP-2 chain id: ${chainId}`);
|
|
30
41
|
}
|
|
31
42
|
function isCaip2(chainId) {
|
|
32
43
|
if (EIP155_CAIP2_REGEX.test(chainId))
|
|
33
44
|
return true;
|
|
34
|
-
return
|
|
45
|
+
return NON_EVM_CHAINS.some((c) => c.caip2 === chainId);
|
|
35
46
|
}
|
|
36
47
|
function isEvmCaip2(chainId) {
|
|
37
48
|
return EIP155_CAIP2_REGEX.test(chainId);
|
|
@@ -39,11 +50,9 @@ function isEvmCaip2(chainId) {
|
|
|
39
50
|
/**
|
|
40
51
|
* True when a numeric chain id is genuinely non-EVM (Solana / Tron). HyperCore
|
|
41
52
|
* (1337) is EVM-settled, so this is `false` for it even though its wire id is
|
|
42
|
-
* the non
|
|
43
|
-
* `execution/utils.ts` rely on HyperCore being EVM-classified here. Sourced
|
|
44
|
-
* from the shared-configs registry `vmType`.
|
|
53
|
+
* the non-`eip155` `hypercore:mainnet` namespace.
|
|
45
54
|
*/
|
|
46
55
|
function isNonEvmChainId(chainId) {
|
|
47
|
-
return
|
|
56
|
+
return NON_EVM_CHAINS.some((c) => c.id === chainId && c.nonEvm);
|
|
48
57
|
}
|
|
49
58
|
export { fromCaip2, isCaip2, isEvmCaip2, isNonEvmChainId, toCaip2 };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export type CatalogToken = {
|
|
2
|
+
symbol: string;
|
|
3
|
+
address: string;
|
|
4
|
+
decimals: number;
|
|
5
|
+
};
|
|
6
|
+
export type ChainInfo = {
|
|
7
|
+
name: string;
|
|
8
|
+
testnet: boolean;
|
|
9
|
+
supportedTokens: 'all' | CatalogToken[];
|
|
10
|
+
wrappedNativeToken?: CatalogToken;
|
|
11
|
+
};
|
|
12
|
+
export type ChainInfoMap = Record<number, ChainInfo>;
|
|
13
|
+
/**
|
|
14
|
+
* Read-only view over the chain facts returned by `GET /chains`. Built once
|
|
15
|
+
* (prefetched at account construction) and read synchronously thereafter.
|
|
16
|
+
*/
|
|
17
|
+
export declare class ChainCatalog {
|
|
18
|
+
private readonly chains;
|
|
19
|
+
constructor(chains: ChainInfoMap);
|
|
20
|
+
getSupportedChainIds(): number[];
|
|
21
|
+
isSupported(chainId: number): boolean;
|
|
22
|
+
getChainInfo(chainId: number): ChainInfo | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Whether the chain is a testnet, per the orchestrator's `/chains`. Uses the
|
|
25
|
+
* catalog's own flag so it is authoritative for every supported chain
|
|
26
|
+
* (including non-EVM and chains newer than the SDK's viem), rather than
|
|
27
|
+
* viem's local chain list.
|
|
28
|
+
*/
|
|
29
|
+
isTestnet(chainId: number): boolean;
|
|
30
|
+
/** The wrapped-native (e.g. WETH) token for the chain, if the orchestrator advertises it. */
|
|
31
|
+
getWrappedNativeToken(chainId: number): CatalogToken | undefined;
|
|
32
|
+
getSupportedTokens(chainId: number): 'all' | CatalogToken[] | undefined;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=chain-catalog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chain-catalog.d.ts","sourceRoot":"","sources":["../../../orchestrator/chain-catalog.ts"],"names":[],"mappings":"AAYA,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,OAAO,CAAA;IAGhB,eAAe,EAAE,KAAK,GAAG,YAAY,EAAE,CAAA;IAIvC,kBAAkB,CAAC,EAAE,YAAY,CAAA;CAClC,CAAA;AAED,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;AAEpD;;;GAGG;AACH,qBAAa,YAAY;IACX,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,YAAY;IAEjD,oBAAoB,IAAI,MAAM,EAAE;IAIhC,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;IAIrC,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS;IAIpD;;;;;OAKG;IACH,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;IAInC,6FAA6F;IAC7F,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS;IAIhE,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK,GAAG,YAAY,EAAE,GAAG,SAAS;CAGxE"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Runtime chain catalog, sourced from the orchestrator's `GET /chains`.
|
|
2
|
+
//
|
|
3
|
+
// This replaces the SDK's bundled `@rhinestone/shared-configs` chain data: the
|
|
4
|
+
// orchestrator is authoritative for chain *facts* (which chains are supported,
|
|
5
|
+
// their tokens, and the wrapped-native token), so the SDK reads them at runtime
|
|
6
|
+
// instead of baking them in at build time. That's what lets a new chain go live
|
|
7
|
+
// without an SDK release.
|
|
8
|
+
//
|
|
9
|
+
// `Chain` objects themselves (rpc/nativeCurrency/formatters, needed for signing
|
|
10
|
+
// and `createPublicClient`) still come from viem — `/chains` can't carry those.
|
|
11
|
+
// The catalog only owns the chain *facts*.
|
|
12
|
+
/**
|
|
13
|
+
* Read-only view over the chain facts returned by `GET /chains`. Built once
|
|
14
|
+
* (prefetched at account construction) and read synchronously thereafter.
|
|
15
|
+
*/
|
|
16
|
+
export class ChainCatalog {
|
|
17
|
+
chains;
|
|
18
|
+
constructor(chains) {
|
|
19
|
+
this.chains = chains;
|
|
20
|
+
}
|
|
21
|
+
getSupportedChainIds() {
|
|
22
|
+
return Object.keys(this.chains).map(Number);
|
|
23
|
+
}
|
|
24
|
+
isSupported(chainId) {
|
|
25
|
+
return chainId in this.chains;
|
|
26
|
+
}
|
|
27
|
+
getChainInfo(chainId) {
|
|
28
|
+
return this.chains[chainId];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Whether the chain is a testnet, per the orchestrator's `/chains`. Uses the
|
|
32
|
+
* catalog's own flag so it is authoritative for every supported chain
|
|
33
|
+
* (including non-EVM and chains newer than the SDK's viem), rather than
|
|
34
|
+
* viem's local chain list.
|
|
35
|
+
*/
|
|
36
|
+
isTestnet(chainId) {
|
|
37
|
+
return this.chains[chainId]?.testnet ?? false;
|
|
38
|
+
}
|
|
39
|
+
/** The wrapped-native (e.g. WETH) token for the chain, if the orchestrator advertises it. */
|
|
40
|
+
getWrappedNativeToken(chainId) {
|
|
41
|
+
return this.chains[chainId]?.wrappedNativeToken;
|
|
42
|
+
}
|
|
43
|
+
getSupportedTokens(chainId) {
|
|
44
|
+
return this.chains[chainId]?.supportedTokens;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Address } from 'viem';
|
|
2
2
|
import type { AuthProvider } from '../auth/provider.js';
|
|
3
|
+
import { ChainCatalog, type ChainInfoMap } from './chain-catalog.js';
|
|
3
4
|
import type { AppFeeBalances, IntentInput, IntentOpStatus, IntentSubmitRequestInternal, IntentSubmitResponse, Portfolio, QuoteResponse, SplitIntentsInput, SplitIntentsResult } from './types.js';
|
|
4
5
|
interface PolicyContext {
|
|
5
6
|
intentInput: unknown;
|
|
@@ -9,6 +10,7 @@ export declare class Orchestrator {
|
|
|
9
10
|
private serverUrl;
|
|
10
11
|
private authProvider;
|
|
11
12
|
private extraHeaders?;
|
|
13
|
+
private chainCatalogPromise?;
|
|
12
14
|
constructor(serverUrl: string, authProvider: AuthProvider, headers?: Record<string, string>);
|
|
13
15
|
getPortfolio(accountAddress: Address, filter?: {
|
|
14
16
|
chainIds?: number[];
|
|
@@ -16,6 +18,18 @@ export declare class Orchestrator {
|
|
|
16
18
|
[chainId: number]: Address[];
|
|
17
19
|
};
|
|
18
20
|
}): Promise<Portfolio>;
|
|
21
|
+
/**
|
|
22
|
+
* Fetch the supported chains and their facts (tokens, wrapped-native token)
|
|
23
|
+
* from the orchestrator's public `/chains` endpoint. Returns a map keyed by
|
|
24
|
+
* numeric chain id (CAIP-2 keys on the wire are decoded).
|
|
25
|
+
*/
|
|
26
|
+
getChains(): Promise<ChainInfoMap>;
|
|
27
|
+
/**
|
|
28
|
+
* Lazily fetch (once) the runtime chain catalog from `/chains`. Cached for the
|
|
29
|
+
* lifetime of this client; callers that need chain facts await this instead of
|
|
30
|
+
* relying on bundled chain data.
|
|
31
|
+
*/
|
|
32
|
+
getChainCatalog(): Promise<ChainCatalog>;
|
|
19
33
|
getAppFeeBalances(): Promise<AppFeeBalances>;
|
|
20
34
|
createQuote(input: IntentInput): Promise<QuoteResponse>;
|
|
21
35
|
getSplit(input: SplitIntentsInput): Promise<SplitIntentsResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../orchestrator/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AACnC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../orchestrator/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AACnC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAEpD,OAAO,EAAE,YAAY,EAAE,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAOjE,OAAO,KAAK,EAEV,cAAc,EAMd,WAAW,EACX,cAAc,EAEd,2BAA2B,EAC3B,oBAAoB,EACpB,SAAS,EAET,aAAa,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aip2 } from './caip2.js';
|
|
2
|
+
import { ChainCatalog } from './chain-catalog.js';
|
|
2
3
|
import { API_VERSION, SDK_VERSION } from './consts.js';
|
|
3
4
|
import { OrchestratorError, parseErrorEnvelope, } from './error.js';
|
|
4
5
|
import { convertBigIntFields } from './utils.js';
|
|
@@ -6,6 +7,9 @@ export class Orchestrator {
|
|
|
6
7
|
serverUrl;
|
|
7
8
|
authProvider;
|
|
8
9
|
extraHeaders;
|
|
10
|
+
// Memoized so the chain catalog is fetched at most once per client, lazily on
|
|
11
|
+
// first use — never at account construction.
|
|
12
|
+
chainCatalogPromise;
|
|
9
13
|
constructor(serverUrl, authProvider, headers) {
|
|
10
14
|
this.serverUrl = serverUrl;
|
|
11
15
|
this.authProvider = authProvider;
|
|
@@ -41,6 +45,48 @@ export class Orchestrator {
|
|
|
41
45
|
})),
|
|
42
46
|
}));
|
|
43
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Fetch the supported chains and their facts (tokens, wrapped-native token)
|
|
50
|
+
* from the orchestrator's public `/chains` endpoint. Returns a map keyed by
|
|
51
|
+
* numeric chain id (CAIP-2 keys on the wire are decoded).
|
|
52
|
+
*/
|
|
53
|
+
async getChains() {
|
|
54
|
+
const json = (await this.fetch(`${this.serverUrl}/chains`, {
|
|
55
|
+
headers: await this.getHeaders(),
|
|
56
|
+
}));
|
|
57
|
+
const out = {};
|
|
58
|
+
for (const [key, entry] of Object.entries(json)) {
|
|
59
|
+
let id;
|
|
60
|
+
try {
|
|
61
|
+
id = isCaip2(key) ? fromCaip2(key) : Number(key);
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
// Skip chains whose CAIP-2 id we can't map to a numeric id.
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
if (!Number.isFinite(id))
|
|
68
|
+
continue;
|
|
69
|
+
// Adapter boundary: map the generated wire shape → the domain `ChainInfo`.
|
|
70
|
+
// If the orchestrator renames or drops a field, `wire.gen.ts` regenerates
|
|
71
|
+
// and this mapping fails to typecheck instead of drifting silently.
|
|
72
|
+
out[id] = {
|
|
73
|
+
name: entry.name,
|
|
74
|
+
testnet: entry.testnet,
|
|
75
|
+
supportedTokens: entry.supportedTokens,
|
|
76
|
+
wrappedNativeToken: entry.wrappedNativeToken,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
return out;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Lazily fetch (once) the runtime chain catalog from `/chains`. Cached for the
|
|
83
|
+
* lifetime of this client; callers that need chain facts await this instead of
|
|
84
|
+
* relying on bundled chain data.
|
|
85
|
+
*/
|
|
86
|
+
getChainCatalog() {
|
|
87
|
+
this.chainCatalogPromise ??= this.getChains().then((chains) => new ChainCatalog(chains));
|
|
88
|
+
return this.chainCatalogPromise;
|
|
89
|
+
}
|
|
44
90
|
async getAppFeeBalances() {
|
|
45
91
|
const json = await this.fetch(`${this.serverUrl}/app-fees/balances`, { headers: await this.getHeaders() });
|
|
46
92
|
return {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
declare const PROD_ORCHESTRATOR_URL = "https://v1.orchestrator.rhinestone.dev";
|
|
2
2
|
declare const RHINESTONE_SPOKE_POOL_ADDRESS = "0x000000000060f6e853447881951574cdd0663530";
|
|
3
|
-
declare const SDK_VERSION = "2.0.0-beta.
|
|
3
|
+
declare const SDK_VERSION = "2.0.0-beta.44";
|
|
4
4
|
declare const API_VERSION = "2026-04.blanc";
|
|
5
5
|
export { PROD_ORCHESTRATOR_URL, RHINESTONE_SPOKE_POOL_ADDRESS, SDK_VERSION, API_VERSION, };
|
|
6
6
|
//# sourceMappingURL=consts.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const PROD_ORCHESTRATOR_URL = 'https://v1.orchestrator.rhinestone.dev';
|
|
2
2
|
const RHINESTONE_SPOKE_POOL_ADDRESS = '0x000000000060f6e853447881951574cdd0663530';
|
|
3
|
-
const SDK_VERSION = '2.0.0-beta.
|
|
3
|
+
const SDK_VERSION = '2.0.0-beta.44';
|
|
4
4
|
const API_VERSION = '2026-04.blanc';
|
|
5
5
|
export { PROD_ORCHESTRATOR_URL, RHINESTONE_SPOKE_POOL_ADDRESS, SDK_VERSION, API_VERSION, };
|
|
@@ -4,10 +4,9 @@ import { RHINESTONE_SPOKE_POOL_ADDRESS } from './consts.js';
|
|
|
4
4
|
import { type DestinationChain, hyperCoreMainnet, isNonEvmChain, type NonEvmAddress, type NonEvmChain, solanaMainnet, tronMainnet } from './destinations.js';
|
|
5
5
|
import type { ErrorDetail, SponsorLimitKey } from './error.js';
|
|
6
6
|
import { ConflictError, ExternalServiceTimeoutError, ForbiddenError, InsufficientLiquidityError, InsufficientSponsorBalanceError, InternalServerError, isAuthError, isConnectionError, isInsufficientSponsorBalance, isOrchestratorError, isRateLimited, isRetryable, isSimulationFailed, isSponsorError, isSponsorLimitExceeded, isValidationError, KeyScopeDeniedError, NotFoundError, OrchestratorError, RateLimitedError, RelayerMarketUnavailableError, SettlementExecutionError, SettlementQuoteError, SimulationFailedError, SponsorLimitExceededError, UnauthorizedError, UnprocessableContentError, UnsupportedChainError, UnsupportedTokenError, ValidationError } from './error.js';
|
|
7
|
-
import { getTokenSymbol, getWethAddress, isTokenAddressSupported } from './registry.js';
|
|
8
7
|
import type { AppFeeBalances, AppFeeRate, ApprovalRequired, AuxiliaryFunds, BridgeFill, ChainOperation, Cost, CostTokenEntry, EstimatedFillTime, Execution, FailureReason, FeeBreakdown, Fees, IntentInput, IntentOpStatus, IntentOptions, IntentSubmitRequest, IntentSubmitResponse, OperationStatus, OriginSignature, Portfolio, Price, Quote, QuoteResponse, SettlementLayer, SettlementLayerFilter, SignatureMode, SignData, SignedAuthorization, SplitIntentsInput, SplitIntentsResult, SponsorSettings, SupportedChain, TokenConfig, TokenRequirements, TypedDataDefinition, UsdAmount, WrapRequired } from './types.js';
|
|
9
8
|
import { INTENT_STATUS_COMPLETED, INTENT_STATUS_FAILED, INTENT_STATUS_PENDING } from './types.js';
|
|
10
9
|
declare function getOrchestrator(authProvider: AuthProvider, orchestratorUrl?: string, headers?: Record<string, string>): Orchestrator;
|
|
11
10
|
export type { ApprovalRequired, AppFeeBalances, AppFeeRate, AuxiliaryFunds, BridgeFill, ChainOperation, Cost, CostTokenEntry, DestinationChain, ErrorDetail, SponsorLimitKey, NonEvmAddress, NonEvmChain, EstimatedFillTime, Execution, FailureReason, FeeBreakdown, Fees, IntentInput, IntentOpStatus, IntentOptions, IntentSubmitRequest, IntentSubmitResponse, OperationStatus, OriginSignature, Portfolio, Price, Quote, QuoteResponse, SettlementLayer, SettlementLayerFilter, SignatureMode, SignData, SignedAuthorization, SplitIntentsInput, SplitIntentsResult, SponsorSettings, SupportedChain, TokenConfig, TokenRequirements, TypedDataDefinition, UsdAmount, WrapRequired, };
|
|
12
|
-
export { hyperCoreMainnet, isNonEvmChain, solanaMainnet, tronMainnet, INTENT_STATUS_PENDING, INTENT_STATUS_COMPLETED, INTENT_STATUS_FAILED, RHINESTONE_SPOKE_POOL_ADDRESS, Orchestrator, ConflictError, ExternalServiceTimeoutError, ForbiddenError, InsufficientLiquidityError, InsufficientSponsorBalanceError, InternalServerError, KeyScopeDeniedError, NotFoundError, OrchestratorError, RateLimitedError, RelayerMarketUnavailableError, SimulationFailedError, SettlementExecutionError, SettlementQuoteError, SponsorLimitExceededError, UnauthorizedError, UnprocessableContentError, UnsupportedChainError, UnsupportedTokenError, ValidationError, getOrchestrator,
|
|
11
|
+
export { hyperCoreMainnet, isNonEvmChain, solanaMainnet, tronMainnet, INTENT_STATUS_PENDING, INTENT_STATUS_COMPLETED, INTENT_STATUS_FAILED, RHINESTONE_SPOKE_POOL_ADDRESS, Orchestrator, ConflictError, ExternalServiceTimeoutError, ForbiddenError, InsufficientLiquidityError, InsufficientSponsorBalanceError, InternalServerError, KeyScopeDeniedError, NotFoundError, OrchestratorError, RateLimitedError, RelayerMarketUnavailableError, SimulationFailedError, SettlementExecutionError, SettlementQuoteError, SponsorLimitExceededError, UnauthorizedError, UnprocessableContentError, UnsupportedChainError, UnsupportedTokenError, ValidationError, getOrchestrator, isOrchestratorError, isRetryable, isConnectionError, isAuthError, isValidationError, isRateLimited, isSimulationFailed, isSponsorLimitExceeded, isInsufficientSponsorBalance, isSponsorError, };
|
|
13
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../orchestrator/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AACvC,OAAO,EAAyB,6BAA6B,EAAE,MAAM,UAAU,CAAA;AAC/E,OAAO,EACL,KAAK,gBAAgB,EACrB,gBAAgB,EAChB,aAAa,EACb,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,aAAa,EACb,WAAW,EACZ,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAC3D,OAAO,EACL,aAAa,EACb,2BAA2B,EAC3B,cAAc,EACd,0BAA0B,EAC1B,+BAA+B,EAC/B,mBAAmB,EACnB,WAAW,EACX,iBAAiB,EACjB,4BAA4B,EAC5B,mBAAmB,EACnB,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,cAAc,EACd,sBAAsB,EACtB,iBAAiB,EACjB,mBAAmB,EACnB,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,6BAA6B,EAC7B,wBAAwB,EACxB,oBAAoB,EACpB,qBAAqB,EACrB,yBAAyB,EACzB,iBAAiB,EACjB,yBAAyB,EACzB,qBAAqB,EACrB,qBAAqB,EACrB,eAAe,EAChB,MAAM,SAAS,CAAA;AAChB,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../orchestrator/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,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f,eAAe,EACf,mBAAmB,EACnB,WAAW,EACX,iBAAiB,EACjB,WAAW,EACX,iBAAiB,EACjB,aAAa,EACb,kBAAkB,EAClB,sBAAsB,EACtB,4BAA4B,EAC5B,cAAc,GACf,CAAA"}
|
|
@@ -2,9 +2,8 @@ import { Orchestrator } from './client.js';
|
|
|
2
2
|
import { PROD_ORCHESTRATOR_URL, RHINESTONE_SPOKE_POOL_ADDRESS } from './consts.js';
|
|
3
3
|
import { hyperCoreMainnet, isNonEvmChain, solanaMainnet, tronMainnet, } from './destinations.js';
|
|
4
4
|
import { ConflictError, ExternalServiceTimeoutError, ForbiddenError, InsufficientLiquidityError, InsufficientSponsorBalanceError, InternalServerError, isAuthError, isConnectionError, isInsufficientSponsorBalance, isOrchestratorError, isRateLimited, isRetryable, isSimulationFailed, isSponsorError, isSponsorLimitExceeded, isValidationError, KeyScopeDeniedError, NotFoundError, OrchestratorError, RateLimitedError, RelayerMarketUnavailableError, SettlementExecutionError, SettlementQuoteError, SimulationFailedError, SponsorLimitExceededError, UnauthorizedError, UnprocessableContentError, UnsupportedChainError, UnsupportedTokenError, ValidationError, } from './error.js';
|
|
5
|
-
import { getTokenSymbol, getWethAddress, isTokenAddressSupported, } from './registry.js';
|
|
6
5
|
import { INTENT_STATUS_COMPLETED, INTENT_STATUS_FAILED, INTENT_STATUS_PENDING, } from './types.js';
|
|
7
6
|
function getOrchestrator(authProvider, orchestratorUrl, headers) {
|
|
8
7
|
return new Orchestrator(orchestratorUrl ?? PROD_ORCHESTRATOR_URL, authProvider, headers);
|
|
9
8
|
}
|
|
10
|
-
export { hyperCoreMainnet, isNonEvmChain, solanaMainnet, tronMainnet, INTENT_STATUS_PENDING, INTENT_STATUS_COMPLETED, INTENT_STATUS_FAILED, RHINESTONE_SPOKE_POOL_ADDRESS, Orchestrator, ConflictError, ExternalServiceTimeoutError, ForbiddenError, InsufficientLiquidityError, InsufficientSponsorBalanceError, InternalServerError, KeyScopeDeniedError, NotFoundError, OrchestratorError, RateLimitedError, RelayerMarketUnavailableError, SimulationFailedError, SettlementExecutionError, SettlementQuoteError, SponsorLimitExceededError, UnauthorizedError, UnprocessableContentError, UnsupportedChainError, UnsupportedTokenError, ValidationError, getOrchestrator,
|
|
9
|
+
export { hyperCoreMainnet, isNonEvmChain, solanaMainnet, tronMainnet, INTENT_STATUS_PENDING, INTENT_STATUS_COMPLETED, INTENT_STATUS_FAILED, RHINESTONE_SPOKE_POOL_ADDRESS, Orchestrator, ConflictError, ExternalServiceTimeoutError, ForbiddenError, InsufficientLiquidityError, InsufficientSponsorBalanceError, InternalServerError, KeyScopeDeniedError, NotFoundError, OrchestratorError, RateLimitedError, RelayerMarketUnavailableError, SimulationFailedError, SettlementExecutionError, SettlementQuoteError, SponsorLimitExceededError, UnauthorizedError, UnprocessableContentError, UnsupportedChainError, UnsupportedTokenError, ValidationError, getOrchestrator, isOrchestratorError, isRetryable, isConnectionError, isAuthError, isValidationError, isRateLimited, isSimulationFailed, isSponsorLimitExceeded, isInsufficientSponsorBalance, isSponsorError, };
|
|
@@ -1,17 +1,7 @@
|
|
|
1
1
|
import { type Address, type Chain } from 'viem';
|
|
2
|
-
import type { TokenSymbol } from '../types.js';
|
|
3
2
|
import type { NonEvmAddress } from './destinations.js';
|
|
4
|
-
declare function getSupportedChainIds(): number[];
|
|
5
|
-
declare function getWethAddress(chain: Chain): Address;
|
|
6
|
-
declare function getWrappedTokenAddress(chain: Chain): Address;
|
|
7
|
-
declare function getTokenSymbol(tokenAddress: Address, chainId: number): string | undefined;
|
|
8
|
-
declare function getTokenAddress(tokenSymbol: TokenSymbol, chainId: number): Address;
|
|
9
3
|
declare function getChainById(chainId: number): Chain;
|
|
10
4
|
declare function isTestnet(chainId: number): boolean;
|
|
11
|
-
declare function
|
|
12
|
-
|
|
13
|
-
chainIds: number[];
|
|
14
|
-
};
|
|
15
|
-
declare function resolveTokenAddress(token: TokenSymbol | Address | NonEvmAddress, chainId: number): Address | NonEvmAddress;
|
|
16
|
-
export { getTokenSymbol, getTokenAddress, getWethAddress, getWrappedTokenAddress, getChainById, getSupportedChainIds, isTestnet, isTokenAddressSupported, getDefaultAccountAccessList, resolveTokenAddress, };
|
|
5
|
+
declare function resolveTokenAddress(token: Address | NonEvmAddress, chainId: number): Address | NonEvmAddress;
|
|
6
|
+
export { getChainById, isTestnet, resolveTokenAddress };
|
|
17
7
|
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../orchestrator/registry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../orchestrator/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,KAAK,EAA0B,MAAM,MAAM,CAAA;AAGvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAUnD,iBAAS,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK,CAc5C;AAED,iBAAS,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAG3C;AAED,iBAAS,mBAAmB,CAC1B,KAAK,EAAE,OAAO,GAAG,aAAa,EAC9B,OAAO,EAAE,MAAM,GACd,OAAO,GAAG,aAAa,CAkBzB;AAED,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,mBAAmB,EAAE,CAAA"}
|