0xtrails 0.2.1 → 0.2.4
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/dist/aave.d.ts.map +1 -1
- package/dist/{ccip-BbfANth7.js → ccip-BlV1Mry3.js} +1 -1
- package/dist/chains.d.ts +5 -1
- package/dist/chains.d.ts.map +1 -1
- package/dist/constants.d.ts +4 -4
- package/dist/constants.d.ts.map +1 -1
- package/dist/{index-WpIVoh3X.js → index-BNWCIGfQ.js} +49015 -46131
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/intentEntrypoint.d.ts +0 -8
- package/dist/intentEntrypoint.d.ts.map +1 -1
- package/dist/metaTxnMonitor.d.ts +5 -4
- package/dist/metaTxnMonitor.d.ts.map +1 -1
- package/dist/metaTxns.d.ts +3 -3
- package/dist/metaTxns.d.ts.map +1 -1
- package/dist/prepareSend.d.ts +3 -3
- package/dist/prepareSend.d.ts.map +1 -1
- package/dist/relayer.d.ts +10 -7
- package/dist/relayer.d.ts.map +1 -1
- package/dist/sequenceWallet.d.ts +3 -2
- package/dist/sequenceWallet.d.ts.map +1 -1
- package/dist/tokenBalances.d.ts +7 -0
- package/dist/tokenBalances.d.ts.map +1 -1
- package/dist/tokens.d.ts +2 -1
- package/dist/tokens.d.ts.map +1 -1
- package/dist/trails.d.ts +2 -2
- package/dist/trails.d.ts.map +1 -1
- package/dist/widget/components/AccountActionsDropdown.d.ts.map +1 -1
- package/dist/widget/components/AccountSettings.d.ts.map +1 -1
- package/dist/widget/components/ConnectWallet.d.ts.map +1 -1
- package/dist/widget/components/EarnPools.d.ts.map +1 -1
- package/dist/widget/components/Fund.d.ts +1 -0
- package/dist/widget/components/Fund.d.ts.map +1 -1
- package/dist/widget/components/Pay.d.ts +1 -0
- package/dist/widget/components/Pay.d.ts.map +1 -1
- package/dist/widget/components/Recipients.d.ts.map +1 -1
- package/dist/widget/components/RefundWarning.d.ts +1 -0
- package/dist/widget/components/RefundWarning.d.ts.map +1 -1
- package/dist/widget/hooks/useBack.d.ts +5 -0
- package/dist/widget/hooks/useBack.d.ts.map +1 -1
- package/dist/widget/hooks/useDefaultTokenSelection.d.ts.map +1 -1
- package/dist/widget/hooks/useInitialRedirect.d.ts +7 -0
- package/dist/widget/hooks/useInitialRedirect.d.ts.map +1 -0
- package/dist/widget/hooks/useSelectedFeeToken.d.ts.map +1 -1
- package/dist/widget/hooks/useTokenList.d.ts.map +1 -1
- package/dist/widget/index.js +1 -1
- package/dist/widget/widget.d.ts.map +1 -1
- package/package.json +18 -17
- package/src/aave.ts +90 -74
- package/src/chains.ts +23 -3
- package/src/constants.ts +10 -17
- package/src/error.ts +1 -1
- package/src/index.ts +8 -3
- package/src/intentEntrypoint.ts +0 -15
- package/src/metaTxnMonitor.ts +28 -22
- package/src/metaTxns.ts +5 -3
- package/src/prepareSend.ts +217 -286
- package/src/relayer.ts +15 -16
- package/src/sequenceWallet.ts +7 -3
- package/src/tokenBalances.ts +55 -1
- package/src/tokens.ts +10 -0
- package/src/trails.ts +2 -2
- package/src/widget/compiled.css +1 -1
- package/src/widget/components/AccountActionsDropdown.tsx +6 -2
- package/src/widget/components/AccountIntentTransactionHistory.tsx +1 -1
- package/src/widget/components/AccountSettings.tsx +5 -4
- package/src/widget/components/ChainFilterDropdown.tsx +1 -1
- package/src/widget/components/ChainList.tsx +1 -1
- package/src/widget/components/ConnectWallet.tsx +6 -2
- package/src/widget/components/EarnPools.tsx +2 -1
- package/src/widget/components/Fund.tsx +50 -27
- package/src/widget/components/Pay.tsx +24 -1
- package/src/widget/components/Receive.tsx +1 -1
- package/src/widget/components/Recipients.tsx +4 -2
- package/src/widget/components/RefundWarning.tsx +5 -1
- package/src/widget/components/SwapSettings.tsx +9 -9
- package/src/widget/components/TokenSelector.tsx +1 -1
- package/src/widget/components/WalletList.tsx +3 -3
- package/src/widget/hooks/useBack.tsx +111 -9
- package/src/widget/hooks/useDefaultTokenSelection.tsx +5 -1
- package/src/widget/hooks/useInitialRedirect.tsx +70 -0
- package/src/widget/hooks/useSelectedFeeToken.tsx +10 -16
- package/src/widget/hooks/useSendForm.ts +10 -10
- package/src/widget/hooks/useTokenList.ts +11 -2
- package/src/widget/widget.tsx +85 -106
- /package/dist/{style.css → 0xtrails.css} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"widget.d.ts","sourceRoot":"","sources":["../../src/widget/widget.tsx"],"names":[],"mappings":"AAAA,OAAO,kCAAkC,CAAA;AAIzC,OAAO,KAUN,MAAM,OAAO,CAAA;AAKd,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"widget.d.ts","sourceRoot":"","sources":["../../src/widget/widget.tsx"],"names":[],"mappings":"AAAA,OAAO,kCAAkC,CAAA;AAIzC,OAAO,KAUN,MAAM,OAAO,CAAA;AAKd,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAYtC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAkB,MAAM,eAAe,CAAA;AAC/D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAoExC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAItC,OAAO,EAAgB,UAAU,EAAE,MAAM,aAAa,CAAA;AA2CtD,eAAO,MAAM,UAAU,YAAsB,CAAA;AAe7C,MAAM,MAAM,iBAAiB,GAAG;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAClC,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,sBAAsB,CAAC,EAAE,MAAM,G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EAAE,MAAM,IAAI,CAAA;IACrB,UAAU,EAAE,MAAM,IAAI,CAAA;IACtB,WAAW,EAAE,OAAO,CAAA;CACrB;AAgyDD,eAAO,MAAM,YAAY,2FA0LxB,CAAA;AAED,wBAAgB,YAAY,CAAC,EAC3B,QAAQ,EACR,SAAS,GACV,EAAE;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC5C,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CA0CpB;AAGD,eAAO,MAAM,qBAAqB,GAChC,KAAK,KAAK,CAAC,SAAS,CAAC,eAAe,CAAC;;;;CAKrC,CAAA;AAEF,eAAe,YAAY,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "0xtrails",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "SDK for Trails",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -32,44 +32,44 @@
|
|
|
32
32
|
"@0xsequence/indexer": "^2.3.30",
|
|
33
33
|
"@0xsequence/metadata": "^2.3.30",
|
|
34
34
|
"@0xsequence/network": "^2.3.30",
|
|
35
|
-
"@0xsequence/relayer": "
|
|
35
|
+
"@0xsequence/relayer": "github:0xsequence/sequence.js#dists/services/relayer",
|
|
36
36
|
"@0xsequence/sessions": "^2.3.30",
|
|
37
37
|
"@0xsequence/signhub": "^2.3.30",
|
|
38
|
-
"@0xsequence/trails-api": "^0.1.
|
|
38
|
+
"@0xsequence/trails-api": "^0.1.2",
|
|
39
39
|
"@0xsequence/wallet-core": "^0.0.0-20250917144328",
|
|
40
40
|
"@0xsequence/wallet-primitives": "^0.0.0-20250917144328",
|
|
41
|
-
"@aave/react": "^0.
|
|
41
|
+
"@aave/react": "^0.7.0",
|
|
42
42
|
"@databeat/tracker": "^0.9.3",
|
|
43
|
-
"@emotion/is-prop-valid": "^1.
|
|
44
|
-
"@meshconnect/web-link-sdk": "3.
|
|
43
|
+
"@emotion/is-prop-valid": "^1.4.0",
|
|
44
|
+
"@meshconnect/web-link-sdk": "3.3.4",
|
|
45
45
|
"@reservoir0x/relay-sdk": "^2.4.0",
|
|
46
46
|
"@tanstack/react-query": "^5.90.3",
|
|
47
47
|
"@types/qrcode": "^1.5.5",
|
|
48
48
|
"buffer": "^6.0.3",
|
|
49
49
|
"framer-motion": "^12.23.24",
|
|
50
|
-
"lucide-react": "^0.
|
|
50
|
+
"lucide-react": "^0.545.0",
|
|
51
51
|
"motion": "^12.23.24",
|
|
52
|
-
"ox": "^0.
|
|
52
|
+
"ox": "^0.9.11",
|
|
53
53
|
"qrcode": "^1.5.4"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@tailwindcss/cli": "^4.1.14",
|
|
57
57
|
"@testing-library/jest-dom": "^6.9.1",
|
|
58
58
|
"@testing-library/react": "^16.3.0",
|
|
59
|
-
"@types/node": "^
|
|
59
|
+
"@types/node": "^24.8.1",
|
|
60
60
|
"@types/react": "^19.2.2",
|
|
61
61
|
"@types/react-dom": "^19.2.2",
|
|
62
|
-
"@vitejs/plugin-react": "^
|
|
63
|
-
"dotenv": "^
|
|
64
|
-
"globals": "^
|
|
65
|
-
"happy-dom": "^
|
|
66
|
-
"jsdom": "^
|
|
62
|
+
"@vitejs/plugin-react": "^5.0.4",
|
|
63
|
+
"dotenv": "^17.2.3",
|
|
64
|
+
"globals": "^16.4.0",
|
|
65
|
+
"happy-dom": "^20.0.5",
|
|
66
|
+
"jsdom": "^27.0.1",
|
|
67
67
|
"patch-package": "^8.0.1",
|
|
68
68
|
"table": "^6.9.0",
|
|
69
69
|
"tailwindcss": "^4.1.14",
|
|
70
70
|
"turbo": "^2.5.8",
|
|
71
71
|
"typescript": "^5.9.3",
|
|
72
|
-
"vite": "^
|
|
72
|
+
"vite": "^7.1.10",
|
|
73
73
|
"vite-plugin-dts": "^4.5.4",
|
|
74
74
|
"vitest": "^3.2.4"
|
|
75
75
|
},
|
|
@@ -95,7 +95,8 @@
|
|
|
95
95
|
}
|
|
96
96
|
},
|
|
97
97
|
"scripts": {
|
|
98
|
-
"build": "rimraf dist && npm run build:css && npm run build:vite",
|
|
98
|
+
"build": "rimraf dist && npm run build:css && npm run build:vite && npm run build:patch",
|
|
99
|
+
"build:patch": "node scripts/apply-react-patch.cjs",
|
|
99
100
|
"build:vite": "vite build --config vite.config.ts --mode production",
|
|
100
101
|
"build:umd": "BUILD_MODE=umd vite build --config vite.umd.config.ts --mode production && npm run build:copy-umd-js",
|
|
101
102
|
"build:copy-umd-js": "mkdir -p ../../apps/trails-demo/public/js && cp ./dist/umd/trails.min.js ../../apps/trails-demo/public/js/trails.min.js",
|
|
@@ -103,7 +104,7 @@
|
|
|
103
104
|
"dev": "npm run build:vite -- --watch",
|
|
104
105
|
"test": "vitest",
|
|
105
106
|
"test:run": "vitest --run",
|
|
106
|
-
"test:scenarios": "vitest --run test/scenarios/useQuote.test.tsx",
|
|
107
|
+
"test:scenarios": "RUN_TEST_SCENARIOS=true vitest --run test/scenarios/useQuote.test.tsx",
|
|
107
108
|
"clean": "rimraf dist node_modules",
|
|
108
109
|
"lint": "biome lint ./src",
|
|
109
110
|
"lint:fix": "biome lint --write ./src",
|
package/src/aave.ts
CHANGED
|
@@ -77,82 +77,98 @@ export function useAavePools() {
|
|
|
77
77
|
const pools: Pool[] = useMemo(() => {
|
|
78
78
|
if (!markets) return []
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
logger.console.log(
|
|
85
|
-
"[trails-sdk] Supply reserves type:",
|
|
86
|
-
typeof market.supplyReserves,
|
|
87
|
-
)
|
|
88
|
-
logger.console.log(
|
|
89
|
-
"[trails-sdk] Supply reserves length:",
|
|
90
|
-
market.supplyReserves?.length,
|
|
91
|
-
)
|
|
92
|
-
|
|
93
|
-
if (!market.supplyReserves || market.supplyReserves.length === 0) {
|
|
80
|
+
try {
|
|
81
|
+
return markets.flatMap((market) => {
|
|
82
|
+
logger.console.log("[trails-sdk] Processing market:", market)
|
|
83
|
+
logger.console.log("[trails-sdk] Market chain:", market.chain)
|
|
94
84
|
logger.console.log(
|
|
95
|
-
"[trails-sdk]
|
|
96
|
-
market.
|
|
85
|
+
"[trails-sdk] Supply reserves:",
|
|
86
|
+
market.supplyReserves,
|
|
97
87
|
)
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
88
|
+
logger.console.log(
|
|
89
|
+
"[trails-sdk] Supply reserves type:",
|
|
90
|
+
typeof market.supplyReserves,
|
|
91
|
+
)
|
|
92
|
+
logger.console.log(
|
|
93
|
+
"[trails-sdk] Supply reserves length:",
|
|
94
|
+
market.supplyReserves?.length,
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
if (!market.supplyReserves || market.supplyReserves.length === 0) {
|
|
98
|
+
logger.console.log(
|
|
99
|
+
"[trails-sdk] No supply reserves found for market:",
|
|
100
|
+
market.chain.chainId,
|
|
101
|
+
)
|
|
102
|
+
return []
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return (
|
|
106
|
+
market.supplyReserves
|
|
107
|
+
?.filter((reserve: any) => {
|
|
108
|
+
// Check if reserve has supply info and is not frozen/paused
|
|
109
|
+
const hasSupplyInfo =
|
|
110
|
+
reserve.supplyInfo && !reserve.isFrozen && !reserve.isPaused
|
|
111
|
+
const hasLiquidity = parseFloat(reserve.size?.usd || "0") > 0
|
|
112
|
+
// logger.console.log(
|
|
113
|
+
// `[trails-sdk] Reserve ${reserve.underlyingToken?.symbol}: hasSupplyInfo=${hasSupplyInfo}, hasLiquidity=${hasLiquidity}, sizeUSD=${reserve.size?.usd}`,
|
|
114
|
+
// )
|
|
115
|
+
return hasSupplyInfo && hasLiquidity
|
|
116
|
+
})
|
|
117
|
+
.map((reserve: any) => {
|
|
118
|
+
const decimals = reserve.underlyingToken?.decimals
|
|
119
|
+
if (!decimals) {
|
|
120
|
+
logger.console.warn(
|
|
121
|
+
"[trails-sdk] Missing decimals for reserve:",
|
|
122
|
+
{
|
|
123
|
+
reserve: reserve.underlyingToken,
|
|
124
|
+
market: market.chain.chainId,
|
|
125
|
+
},
|
|
126
|
+
)
|
|
127
|
+
return null // Return null instead of throwing
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const tokenMetadata = {
|
|
131
|
+
symbol: reserve.underlyingToken?.symbol || "UNKNOWN",
|
|
132
|
+
name: reserve.underlyingToken?.name || "Unknown Token",
|
|
133
|
+
decimals,
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const pool = {
|
|
137
|
+
id: `${reserve.underlyingToken?.address}-${market.chain.chainId}-${reserve.aToken?.address}`,
|
|
138
|
+
name: `${tokenMetadata.symbol} Market`,
|
|
139
|
+
protocol: "Aave",
|
|
140
|
+
chainId: market.chain.chainId,
|
|
141
|
+
apy: parseFloat(reserve.supplyInfo?.apy?.value || "0") * 100, // Convert to percentage
|
|
142
|
+
tvl: parseFloat(reserve.size?.usd || "0"),
|
|
143
|
+
token: {
|
|
144
|
+
symbol: tokenMetadata.symbol,
|
|
145
|
+
name: tokenMetadata.name,
|
|
146
|
+
address: reserve.underlyingToken?.address,
|
|
147
|
+
decimals: tokenMetadata.decimals,
|
|
148
|
+
logoUrl:
|
|
149
|
+
"logoUrl" in tokenMetadata
|
|
150
|
+
? tokenMetadata.logoUrl
|
|
151
|
+
: reserve.underlyingToken?.imageUrl,
|
|
152
|
+
},
|
|
153
|
+
depositAddress: market.address,
|
|
154
|
+
isActive: !reserve.isFrozen && !reserve.isPaused,
|
|
155
|
+
protocolUrl: "https://app.aave.com/",
|
|
156
|
+
poolUrl: `https://app.aave.com/reserve-overview/?underlyingAsset=${reserve.underlyingToken?.address?.toLowerCase()}&marketName=${CHAIN_TO_MARKET_NAME[market.chain.chainId] || "proto_mainnet_v3"}`,
|
|
157
|
+
wrappedTokenGatewayAddress:
|
|
158
|
+
getAaveV3WrappedTokenGatewayAddress(market.chain.chainId) ||
|
|
159
|
+
undefined,
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// logger.console.log("[trails-sdk] pool object:", pool)
|
|
163
|
+
return pool
|
|
164
|
+
})
|
|
165
|
+
.filter((pool) => pool !== null) || [] // Filter out null values
|
|
166
|
+
)
|
|
167
|
+
})
|
|
168
|
+
} catch (error) {
|
|
169
|
+
logger.console.error("[trails-sdk] Error processing Aave markets:", error)
|
|
170
|
+
return [] // Return empty array instead of crashing
|
|
171
|
+
}
|
|
156
172
|
}, [markets])
|
|
157
173
|
|
|
158
174
|
// logger.console.log("[trails-sdk] Final pools array:", pools)
|
package/src/chains.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useQuery } from "@tanstack/react-query"
|
|
2
|
-
import type { Chain } from "viem"
|
|
2
|
+
import type { Chain as ViemChain } from "viem"
|
|
3
|
+
|
|
3
4
|
import {
|
|
4
5
|
arbitrum,
|
|
5
6
|
base,
|
|
@@ -41,6 +42,17 @@ import {
|
|
|
41
42
|
import type { QuoteProvider } from "./intents.js"
|
|
42
43
|
import { somnia } from "./customChains.js"
|
|
43
44
|
|
|
45
|
+
// Extended Chain type with imageUrl
|
|
46
|
+
export interface Chain extends ViemChain {
|
|
47
|
+
imageUrl?: string
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Function to get chain image URL
|
|
51
|
+
export function getChainImageUrl(chainId: number): string {
|
|
52
|
+
// Use Sequence's chain image assets
|
|
53
|
+
return `https://assets.sequence.info/images/networks/large/${chainId}.webp`
|
|
54
|
+
}
|
|
55
|
+
|
|
44
56
|
export function getAllChains(): Chain[] {
|
|
45
57
|
return [
|
|
46
58
|
arbitrum,
|
|
@@ -122,7 +134,7 @@ export const supportedSequenceChains: Record<number, Chain> = {
|
|
|
122
134
|
[avalanche.id]: getChainInfo(avalanche.id)!,
|
|
123
135
|
[b3.id]: getChainInfo(b3.id)!,
|
|
124
136
|
[base.id]: getChainInfo(base.id)!,
|
|
125
|
-
[blast.id]: getChainInfo(
|
|
137
|
+
[blast.id]: getChainInfo(blast.id)!,
|
|
126
138
|
[bsc.id]: getChainInfo(bsc.id)!,
|
|
127
139
|
[mainnet.id]: getChainInfo(mainnet.id)!,
|
|
128
140
|
[gnosis.id]: getChainInfo(gnosis.id)!,
|
|
@@ -207,7 +219,15 @@ export function getChainInfo(
|
|
|
207
219
|
}
|
|
208
220
|
}
|
|
209
221
|
|
|
210
|
-
|
|
222
|
+
// Add imageUrl property to chain info
|
|
223
|
+
if (chainInfo) {
|
|
224
|
+
return {
|
|
225
|
+
...chainInfo,
|
|
226
|
+
imageUrl: getChainImageUrl(chainId),
|
|
227
|
+
} as Chain
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
return null
|
|
211
231
|
}
|
|
212
232
|
|
|
213
233
|
// Get testnet chain info from mainnet chain as input
|
package/src/constants.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { AddressOverrides } from "@0xsequence/trails-api"
|
|
2
2
|
import type { Context as ContextLike } from "@0xsequence/wallet-primitives"
|
|
3
|
+
import type { Address } from "ox"
|
|
3
4
|
|
|
4
5
|
export const SEQUENCE_V3_CONTRACT_ADDRESSES: ContextLike.Context = {
|
|
5
|
-
factory: "0x00000000000018A77519fcCCa060c2537c9D6d3F" as
|
|
6
|
-
stage1: "0x00000000000084fA81809Dd337311297C5594d62" as
|
|
7
|
-
stage2: "0x7438718F9E4b9B834e305A620EEeCf2B9E6eBE79" as
|
|
6
|
+
factory: "0x00000000000018A77519fcCCa060c2537c9D6d3F" as Address.Address,
|
|
7
|
+
stage1: "0x00000000000084fA81809Dd337311297C5594d62" as Address.Address,
|
|
8
|
+
stage2: "0x7438718F9E4b9B834e305A620EEeCf2B9E6eBE79" as Address.Address,
|
|
8
9
|
creationCode:
|
|
9
|
-
"0x6041600e3d396021805130553df33d3d36153402601f57363d3d373d363d30545af43d82803e903d91601f57fd5bf3" as
|
|
10
|
+
"0x6041600e3d396021805130553df33d3d36153402601f57363d3d373d363d30545af43d82803e903d91601f57fd5bf3" as Address.Address,
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
export const SEQUENCE_V3_CONTRACT_ADDRESSES_OVERRIDES: AddressOverrides = {
|
|
@@ -16,13 +17,13 @@ export const SEQUENCE_V3_CONTRACT_ADDRESSES_OVERRIDES: AddressOverrides = {
|
|
|
16
17
|
SEQUENCE_V3_CONTRACT_ADDRESSES.stage2,
|
|
17
18
|
} as AddressOverrides
|
|
18
19
|
|
|
19
|
-
export const TRAILS_ROUTER_ADDRESS =
|
|
20
|
-
"
|
|
20
|
+
export const TRAILS_ROUTER_ADDRESS: Address.Address =
|
|
21
|
+
"0xc4415c5CabD726bA06042af752a528B3dbc263F7"
|
|
21
22
|
|
|
22
|
-
export const TRAILS_INTENT_ENTRYPOINT_ADDRESS =
|
|
23
|
-
"
|
|
23
|
+
export const TRAILS_INTENT_ENTRYPOINT_ADDRESS: Address.Address =
|
|
24
|
+
"0x9470D883bac170116d397Db3dA71B2e57d567583"
|
|
24
25
|
|
|
25
|
-
export const ATTESATION_SIGNER_ADDRESS =
|
|
26
|
+
export const ATTESATION_SIGNER_ADDRESS: Address.Address =
|
|
26
27
|
"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"
|
|
27
28
|
|
|
28
29
|
export const DEFAULT_SEQUENCE_ENV = "prod"
|
|
@@ -36,14 +37,6 @@ export const DEV_SEQUENCE_INDEXER_URL = "https://dev-indexer.sequence.app"
|
|
|
36
37
|
export const DEV_SEQUENCE_API_URL = "https://dev-api.sequence.app"
|
|
37
38
|
export const DEV_TRAILS_API_URL = "https://dev-trails-api.sequence-dev.app"
|
|
38
39
|
|
|
39
|
-
// TODO: Update with new single address once latest contracts are deployed
|
|
40
|
-
export const intentEntrypoints: Record<number, `0x${string}`> = {
|
|
41
|
-
8453: "0x80DB82D640F9Df20Cfe89fa4E70B0EcC56f3715c", // Base
|
|
42
|
-
42161: "0x20CC15eb516Ba56398c28CE1A567e3a82889Db46", // Arbitrum One
|
|
43
|
-
137: "0x1C69bCdcD751785F2a3b815333B46AB150370E6E", // Polygon
|
|
44
|
-
747474: "0x814A110fF7c664C26e6c3e2E6E85C23291e4359e", // Katana
|
|
45
|
-
}
|
|
46
|
-
|
|
47
40
|
// This is used for Sequence Indexer and API
|
|
48
41
|
export const PROD_SEQUENCE_PROJECT_ACCESS_KEY =
|
|
49
42
|
"AQAAAAAAAKhGHJc3N5V2AWqfJ1v9xZ2u0nA"
|
package/src/error.ts
CHANGED
|
@@ -89,7 +89,7 @@ export function getIsQuoteTokenError(err: unknown) {
|
|
|
89
89
|
|
|
90
90
|
export function getIsQuoteInputError(err: unknown) {
|
|
91
91
|
const isQuoteInputError =
|
|
92
|
-
/Invalid input or output currency|originTokenAmount must be greater than zero|trails fee is greater than the origin token amount/gi.test(
|
|
92
|
+
/Invalid input or output currency|originTokenAmount must be greater than zero|trails fee is greater than the origin token amount|insufficient origin amount|fees exceed the provided amount/gi.test(
|
|
93
93
|
getErrorString(err).toLowerCase(),
|
|
94
94
|
)
|
|
95
95
|
return isQuoteInputError
|
package/src/index.ts
CHANGED
|
@@ -6,6 +6,7 @@ export {
|
|
|
6
6
|
useSupportedChains,
|
|
7
7
|
getChainInfo,
|
|
8
8
|
getAllChains,
|
|
9
|
+
type Chain,
|
|
9
10
|
} from "./chains.js"
|
|
10
11
|
export {
|
|
11
12
|
getIndexerGatewayClient,
|
|
@@ -32,11 +33,14 @@ export { useMetaTxnsMonitor } from "./metaTxnMonitor.js"
|
|
|
32
33
|
export {
|
|
33
34
|
prepareSend,
|
|
34
35
|
useQuote,
|
|
35
|
-
type UseQuoteReturn,
|
|
36
|
-
type UseQuoteProps,
|
|
37
|
-
type SwapReturn,
|
|
38
36
|
TradeType,
|
|
39
37
|
} from "./prepareSend.js"
|
|
38
|
+
export type {
|
|
39
|
+
UseQuoteReturn,
|
|
40
|
+
UseQuoteProps,
|
|
41
|
+
SwapReturn,
|
|
42
|
+
Quote,
|
|
43
|
+
} from "./prepareSend.js"
|
|
40
44
|
export type {
|
|
41
45
|
TransactionState,
|
|
42
46
|
IntentTransaction,
|
|
@@ -67,6 +71,7 @@ export {
|
|
|
67
71
|
export type {
|
|
68
72
|
NativeTokenBalance,
|
|
69
73
|
TokenBalance,
|
|
74
|
+
TokenBalanceExtended,
|
|
70
75
|
} from "./tokenBalances.js"
|
|
71
76
|
export {
|
|
72
77
|
getSupportedTokens,
|
package/src/intentEntrypoint.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { Account, WalletClient, Hex, Address, PublicClient } from "viem"
|
|
2
|
-
import { intentEntrypoints } from "./constants.js"
|
|
3
2
|
import type { TrailsAPIClient } from "@0xsequence/trails-api"
|
|
4
3
|
|
|
5
4
|
// Intent Entrypoint ABI (partial - only the functions we need)
|
|
@@ -170,20 +169,6 @@ export function splitSignature(signature: Hex): {
|
|
|
170
169
|
return { v, r, s }
|
|
171
170
|
}
|
|
172
171
|
|
|
173
|
-
/**
|
|
174
|
-
* Get the Intent Entrypoint address for a given chain
|
|
175
|
-
*/
|
|
176
|
-
export function getIntentEntrypointAddress(chainId: number): Address | null {
|
|
177
|
-
return (intentEntrypoints[chainId] as Address) || null
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* Check if Intent Entrypoint is deployed on a chain
|
|
182
|
-
*/
|
|
183
|
-
export function isIntentEntrypointSupported(chainId: number): boolean {
|
|
184
|
-
return chainId in intentEntrypoints
|
|
185
|
-
}
|
|
186
|
-
|
|
187
172
|
/**
|
|
188
173
|
* Get fee options for intent entrypoint deposits
|
|
189
174
|
*/
|
package/src/metaTxnMonitor.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
RelayerOperationConfirmedStatus,
|
|
3
|
+
RelayerOperationFailedStatus,
|
|
4
|
+
RelayerOperationPendingStatus,
|
|
5
|
+
RelayerOperationStatus,
|
|
6
|
+
RelayerOperationUnknownStatus,
|
|
7
|
+
} from "./relayer.js"
|
|
8
|
+
import type { RpcRelayer } from "@0xsequence/relayer"
|
|
2
9
|
import { type Query, useQueries } from "@tanstack/react-query"
|
|
3
10
|
import { useMemo } from "react"
|
|
4
11
|
import type { Hex } from "viem"
|
|
@@ -13,22 +20,22 @@ export type MetaTxn = {
|
|
|
13
20
|
}
|
|
14
21
|
|
|
15
22
|
export type MetaTxnStatus = {
|
|
16
|
-
[key: string]:
|
|
23
|
+
[key: string]: RelayerOperationStatus
|
|
17
24
|
}
|
|
18
25
|
|
|
19
26
|
const POLL_INTERVAL = 3_000 // 3 seconds
|
|
20
27
|
|
|
21
28
|
export const getMetaTxStatus = async (
|
|
22
|
-
relayer:
|
|
29
|
+
relayer: RpcRelayer.RpcRelayer,
|
|
23
30
|
metaTxId: string,
|
|
24
31
|
chainId: number,
|
|
25
|
-
): Promise<
|
|
32
|
+
): Promise<RelayerOperationStatus> => {
|
|
26
33
|
return relayer.status(metaTxId as `0x${string}`, chainId)
|
|
27
34
|
}
|
|
28
35
|
|
|
29
36
|
export const useMetaTxnsMonitor = (
|
|
30
37
|
metaTxns: MetaTxn[] | undefined,
|
|
31
|
-
getRelayer: (chainId: number) =>
|
|
38
|
+
getRelayer: (chainId: number) => RpcRelayer.RpcRelayer,
|
|
32
39
|
) => {
|
|
33
40
|
const results = useQueries({
|
|
34
41
|
queries: (metaTxns || []).map((metaTxn) => {
|
|
@@ -36,21 +43,21 @@ export const useMetaTxnsMonitor = (
|
|
|
36
43
|
|
|
37
44
|
return {
|
|
38
45
|
queryKey: ["metaTxnStatus", metaTxn.chainId, metaTxn.id],
|
|
39
|
-
queryFn: async (): Promise<
|
|
46
|
+
queryFn: async (): Promise<RelayerOperationStatus> => {
|
|
40
47
|
const relayer = getRelayer(parseInt(metaTxn.chainId, 10))
|
|
41
48
|
|
|
42
49
|
if (!opHashToPoll) {
|
|
43
50
|
return {
|
|
44
51
|
status: "failed",
|
|
45
52
|
reason: "Missing operation hash for monitoring.",
|
|
46
|
-
} as
|
|
53
|
+
} as RelayerOperationFailedStatus
|
|
47
54
|
}
|
|
48
55
|
|
|
49
56
|
if (!relayer) {
|
|
50
57
|
return {
|
|
51
58
|
status: "failed",
|
|
52
59
|
reason: `Relayer not available for chain ${metaTxn.chainId}.`,
|
|
53
|
-
} as
|
|
60
|
+
} as RelayerOperationFailedStatus
|
|
54
61
|
}
|
|
55
62
|
|
|
56
63
|
const opStatus = await relayer.status(
|
|
@@ -58,28 +65,28 @@ export const useMetaTxnsMonitor = (
|
|
|
58
65
|
Number(metaTxn.chainId),
|
|
59
66
|
)
|
|
60
67
|
|
|
61
|
-
let newStatusEntry:
|
|
68
|
+
let newStatusEntry: RelayerOperationStatus
|
|
62
69
|
|
|
63
70
|
if (opStatus.status === "confirmed") {
|
|
64
71
|
newStatusEntry = {
|
|
65
72
|
status: "confirmed",
|
|
66
73
|
transactionHash: opStatus.transactionHash,
|
|
67
74
|
data: opStatus.data,
|
|
68
|
-
} as
|
|
75
|
+
} as RelayerOperationConfirmedStatus
|
|
69
76
|
} else if (opStatus.status === "failed") {
|
|
70
77
|
newStatusEntry = {
|
|
71
78
|
status: "failed",
|
|
72
79
|
reason: opStatus.reason,
|
|
73
80
|
data: opStatus.data,
|
|
74
|
-
} as
|
|
81
|
+
} as RelayerOperationFailedStatus
|
|
75
82
|
} else if (opStatus.status === "pending") {
|
|
76
83
|
newStatusEntry = {
|
|
77
84
|
status: "pending",
|
|
78
|
-
} as
|
|
85
|
+
} as RelayerOperationPendingStatus
|
|
79
86
|
} else if (opStatus.status === "unknown") {
|
|
80
87
|
newStatusEntry = {
|
|
81
88
|
status: "unknown",
|
|
82
|
-
} as
|
|
89
|
+
} as RelayerOperationUnknownStatus
|
|
83
90
|
} else {
|
|
84
91
|
const originalStatus = (opStatus as any).status as string
|
|
85
92
|
logger.console.warn(
|
|
@@ -88,16 +95,16 @@ export const useMetaTxnsMonitor = (
|
|
|
88
95
|
)
|
|
89
96
|
newStatusEntry = {
|
|
90
97
|
status: "unknown",
|
|
91
|
-
} as
|
|
98
|
+
} as RelayerOperationUnknownStatus
|
|
92
99
|
}
|
|
93
100
|
return newStatusEntry
|
|
94
101
|
},
|
|
95
102
|
refetchIntervalInBackground: true,
|
|
96
103
|
refetchInterval: (
|
|
97
104
|
query: Query<
|
|
98
|
-
|
|
105
|
+
RelayerOperationStatus,
|
|
99
106
|
Error,
|
|
100
|
-
|
|
107
|
+
RelayerOperationStatus,
|
|
101
108
|
ReadonlyArray<unknown>
|
|
102
109
|
>,
|
|
103
110
|
) => {
|
|
@@ -135,27 +142,26 @@ export const useMetaTxnsMonitor = (
|
|
|
135
142
|
) {
|
|
136
143
|
newStatuses[operationKey] = {
|
|
137
144
|
status: "pending",
|
|
138
|
-
} as
|
|
145
|
+
} as RelayerOperationPendingStatus
|
|
139
146
|
} else if (queryResult.isError) {
|
|
140
147
|
newStatuses[operationKey] = {
|
|
141
148
|
status: "failed",
|
|
142
149
|
reason:
|
|
143
150
|
(queryResult.error as Error)?.message ||
|
|
144
151
|
"An unknown error occurred",
|
|
145
|
-
} as
|
|
152
|
+
} as RelayerOperationFailedStatus
|
|
146
153
|
} else if (queryResult.data) {
|
|
147
|
-
newStatuses[operationKey] =
|
|
148
|
-
queryResult.data as Relayer.OperationStatus
|
|
154
|
+
newStatuses[operationKey] = queryResult.data as RelayerOperationStatus
|
|
149
155
|
} else {
|
|
150
156
|
newStatuses[operationKey] = {
|
|
151
157
|
status: "unknown",
|
|
152
|
-
} as
|
|
158
|
+
} as RelayerOperationUnknownStatus
|
|
153
159
|
}
|
|
154
160
|
} else {
|
|
155
161
|
newStatuses[operationKey] = {
|
|
156
162
|
status: "failed",
|
|
157
163
|
reason: "Query result unexpectedly missing",
|
|
158
|
-
} as
|
|
164
|
+
} as RelayerOperationFailedStatus
|
|
159
165
|
}
|
|
160
166
|
})
|
|
161
167
|
return newStatuses
|
package/src/metaTxns.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { IntentPrecondition } from "@0xsequence/trails-api"
|
|
2
|
-
import type { Relayer } from "@0xsequence/wallet-core"
|
|
3
2
|
import type { Hex } from "viem"
|
|
4
3
|
import type { MetaTxn } from "./metaTxnMonitor.js"
|
|
4
|
+
import type { RpcRelayer } from "@0xsequence/relayer"
|
|
5
|
+
|
|
5
6
|
import { logger } from "./logger.js"
|
|
7
|
+
import type { Relayer } from "@0xsequence/relayer"
|
|
6
8
|
|
|
7
9
|
export async function relayerSendMetaTx(
|
|
8
|
-
relayer:
|
|
10
|
+
relayer: RpcRelayer.RpcRelayer,
|
|
9
11
|
metaTx: MetaTxn,
|
|
10
12
|
preconditions: IntentPrecondition[],
|
|
11
13
|
feeQuote?: Relayer.FeeQuote,
|
|
@@ -23,7 +25,7 @@ export async function relayerSendMetaTx(
|
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
export async function getMetaTxnReceipt(
|
|
26
|
-
relayer:
|
|
28
|
+
relayer: RpcRelayer.RpcRelayer,
|
|
27
29
|
metaTxId: string,
|
|
28
30
|
chainId: number,
|
|
29
31
|
): Promise<{ receipt: { status: "confirmed" | "failed" | "pending" } }> {
|