@spicenet-io/spiceflow-core 0.9.0 → 0.10.0-private-rpc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +82 -0
- package/dist/index.cjs +4 -4
- package/dist/index.js +4 -4
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# @spicenet-io/spiceflow-core
|
|
2
|
+
|
|
3
|
+
Single source of truth for chain configs, token lists, logos, ABIs, and shared utilities across spiceflow repos.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
npm install @spicenet-io/spiceflow-core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## What's in here
|
|
12
|
+
|
|
13
|
+
### Chains
|
|
14
|
+
|
|
15
|
+
`CHAINS` is a record of all supported chains keyed by chain ID. Each entry has id, name, display name, network (mainnet/testnet), native currency, delegate contract address, block explorer, rpc url, and logo.
|
|
16
|
+
|
|
17
|
+
Helper functions: `getChainMeta(chainId)`, `getChainsByNetwork(network)`, `getChainIdsByNetwork(network)`, `getMainnetChains()`, `getTestnetChains()`, `getDelegateContract(chainId)`.
|
|
18
|
+
|
|
19
|
+
### Tokens
|
|
20
|
+
|
|
21
|
+
`TOKENS` is the official token list. Each token has symbol, name, equivalence group, logo, and deployments across chains (address, decimals, network per chain).
|
|
22
|
+
|
|
23
|
+
Helper functions: `getTokensForChain(chainId)`, `getTokenByAddress(address, chainId)`, `getEquivalentAddresses(tokenAddress)`, `areEquivalent(a, b)`, `isUsdDenominated(address)`, `isBtcDenominated(address)`.
|
|
24
|
+
|
|
25
|
+
### Logos
|
|
26
|
+
|
|
27
|
+
All chain and token logos are bundled as base64 data URIs in the package. They work directly in img src attributes with no network requests. To add a new logo, drop the PNG in `logos/` and reference it in the chain or token list. `npm run build` auto generates the base64 file.
|
|
28
|
+
|
|
29
|
+
### Utilities
|
|
30
|
+
|
|
31
|
+
`isNativeToken(address)` checks if an address is a native token (zero address, 0x0, or 0xeee...eee).
|
|
32
|
+
|
|
33
|
+
`normalizeNativeTokenAddress(address)` normalizes any native token address to the zero address.
|
|
34
|
+
|
|
35
|
+
`convertAmountBetweenDecimals(amount, fromDecimals, toDecimals)` converts token amounts between different decimal precisions.
|
|
36
|
+
|
|
37
|
+
`formatTokenAmount(amount, decimals)` formats a bigint token amount into a human readable string.
|
|
38
|
+
|
|
39
|
+
`truncateAddress(address)` shortens an address for display.
|
|
40
|
+
|
|
41
|
+
`withRetry(fn, maxRetries, delayMs)` retries an async function with exponential backoff.
|
|
42
|
+
|
|
43
|
+
Constants: `NATIVE_TOKEN_ADDRESS`, `ZERO_ADDRESS`, `ESCROW_ADDRESS`.
|
|
44
|
+
|
|
45
|
+
### ABIs
|
|
46
|
+
|
|
47
|
+
`DELEGATE_ABI`, `ERC20_ABI`, `WCBTC_ABI`.
|
|
48
|
+
|
|
49
|
+
### Authorization
|
|
50
|
+
|
|
51
|
+
`hashChainBatches(chainCalls)` hashes chain call batches for intent signing.
|
|
52
|
+
|
|
53
|
+
`getIntentHash(signatureType, nbf, exp, chainBatches)` computes the intent hash.
|
|
54
|
+
|
|
55
|
+
`getAccountNonce(address, publicClient)` gets the account nonce from chain.
|
|
56
|
+
|
|
57
|
+
### Core SDK
|
|
58
|
+
|
|
59
|
+
`SpiceFlowCore` class for building and submitting intents. Handles delegation signing, chain batch construction, intent signing, and transaction submission.
|
|
60
|
+
|
|
61
|
+
### HTTP
|
|
62
|
+
|
|
63
|
+
`fetchWithRetry(url, init, opts)` is a fetch wrapper with retry and exponential backoff.
|
|
64
|
+
|
|
65
|
+
`submitTransaction(baseUrl, request)` submits a transaction to the relayer API.
|
|
66
|
+
|
|
67
|
+
`getIntentStepStatus(txApiUrl, intentId, stepId)` checks intent execution status.
|
|
68
|
+
|
|
69
|
+
`prepareRFQT(txApiUrl, request)` prepares an RFQT quote.
|
|
70
|
+
|
|
71
|
+
## Adding a token
|
|
72
|
+
|
|
73
|
+
1. Drop the logo PNG in `logos/`
|
|
74
|
+
2. Add the token entry in `src/tokens/list.ts` with symbol, name, equivalence group, logo reference, and deployments
|
|
75
|
+
3. `npm run build` and publish
|
|
76
|
+
|
|
77
|
+
## Adding a chain
|
|
78
|
+
|
|
79
|
+
1. Drop the logo PNG in `logos/` if it's a new chain logo
|
|
80
|
+
2. Add the chain entry in `src/chains/list.ts`
|
|
81
|
+
3. Add token deployments on that chain in `src/tokens/list.ts`
|
|
82
|
+
4. `npm run build` and publish
|
package/dist/index.cjs
CHANGED
|
@@ -422,7 +422,7 @@ var CHAINS = {
|
|
|
422
422
|
delegateContract: "0x5884Bff4876C979271E65D2feA8D0CF3bF6E6CcC",
|
|
423
423
|
escrowContract: "0x93ee466f920e1b4961f85749001f03aAd868eF0E",
|
|
424
424
|
blockExplorer: "https://etherscan.io",
|
|
425
|
-
rpcUrl: "https://
|
|
425
|
+
rpcUrl: "https://tx-submission-api.spicenet.io/rpc/1",
|
|
426
426
|
logo: logo_eth
|
|
427
427
|
},
|
|
428
428
|
8453: {
|
|
@@ -434,7 +434,7 @@ var CHAINS = {
|
|
|
434
434
|
delegateContract: "0x5884Bff4876C979271E65D2feA8D0CF3bF6E6CcC",
|
|
435
435
|
escrowContract: "0xd3F8f177BB3d7dfD883d7c232f3093EdD61C3De9",
|
|
436
436
|
blockExplorer: "https://basescan.org",
|
|
437
|
-
rpcUrl: "https://
|
|
437
|
+
rpcUrl: "https://tx-submission-api.spicenet.io/rpc/8453",
|
|
438
438
|
logo: logo_base
|
|
439
439
|
},
|
|
440
440
|
42161: {
|
|
@@ -446,7 +446,7 @@ var CHAINS = {
|
|
|
446
446
|
delegateContract: "0x262E1A689555dA5209113A056d0d164EF8355395",
|
|
447
447
|
escrowContract: "0x47d6DB10d99b1E0A074B1467407C7A53B68e1147",
|
|
448
448
|
blockExplorer: "https://arbiscan.io",
|
|
449
|
-
rpcUrl: "https://
|
|
449
|
+
rpcUrl: "https://tx-submission-api.spicenet.io/rpc/42161",
|
|
450
450
|
logo: logo_arb
|
|
451
451
|
},
|
|
452
452
|
4114: {
|
|
@@ -458,7 +458,7 @@ var CHAINS = {
|
|
|
458
458
|
delegateContract: "0x5884Bff4876C979271E65D2feA8D0CF3bF6E6CcC",
|
|
459
459
|
escrowContract: "0x3677113f10d82acFEeDd22dF5c7cFD58736111ee",
|
|
460
460
|
blockExplorer: "https://explorer.mainnet.citrea.xyz",
|
|
461
|
-
rpcUrl: "https://
|
|
461
|
+
rpcUrl: "https://tx-submission-api.spicenet.io/rpc/4114",
|
|
462
462
|
logo: logo_citrea,
|
|
463
463
|
wrappedNativeTokenAddress: "0x3100000000000000000000000000000000000006"
|
|
464
464
|
},
|
package/dist/index.js
CHANGED
|
@@ -334,7 +334,7 @@ var CHAINS = {
|
|
|
334
334
|
delegateContract: "0x5884Bff4876C979271E65D2feA8D0CF3bF6E6CcC",
|
|
335
335
|
escrowContract: "0x93ee466f920e1b4961f85749001f03aAd868eF0E",
|
|
336
336
|
blockExplorer: "https://etherscan.io",
|
|
337
|
-
rpcUrl: "https://
|
|
337
|
+
rpcUrl: "https://tx-submission-api.spicenet.io/rpc/1",
|
|
338
338
|
logo: logo_eth
|
|
339
339
|
},
|
|
340
340
|
8453: {
|
|
@@ -346,7 +346,7 @@ var CHAINS = {
|
|
|
346
346
|
delegateContract: "0x5884Bff4876C979271E65D2feA8D0CF3bF6E6CcC",
|
|
347
347
|
escrowContract: "0xd3F8f177BB3d7dfD883d7c232f3093EdD61C3De9",
|
|
348
348
|
blockExplorer: "https://basescan.org",
|
|
349
|
-
rpcUrl: "https://
|
|
349
|
+
rpcUrl: "https://tx-submission-api.spicenet.io/rpc/8453",
|
|
350
350
|
logo: logo_base
|
|
351
351
|
},
|
|
352
352
|
42161: {
|
|
@@ -358,7 +358,7 @@ var CHAINS = {
|
|
|
358
358
|
delegateContract: "0x262E1A689555dA5209113A056d0d164EF8355395",
|
|
359
359
|
escrowContract: "0x47d6DB10d99b1E0A074B1467407C7A53B68e1147",
|
|
360
360
|
blockExplorer: "https://arbiscan.io",
|
|
361
|
-
rpcUrl: "https://
|
|
361
|
+
rpcUrl: "https://tx-submission-api.spicenet.io/rpc/42161",
|
|
362
362
|
logo: logo_arb
|
|
363
363
|
},
|
|
364
364
|
4114: {
|
|
@@ -370,7 +370,7 @@ var CHAINS = {
|
|
|
370
370
|
delegateContract: "0x5884Bff4876C979271E65D2feA8D0CF3bF6E6CcC",
|
|
371
371
|
escrowContract: "0x3677113f10d82acFEeDd22dF5c7cFD58736111ee",
|
|
372
372
|
blockExplorer: "https://explorer.mainnet.citrea.xyz",
|
|
373
|
-
rpcUrl: "https://
|
|
373
|
+
rpcUrl: "https://tx-submission-api.spicenet.io/rpc/4114",
|
|
374
374
|
logo: logo_citrea,
|
|
375
375
|
wrappedNativeTokenAddress: "0x3100000000000000000000000000000000000006"
|
|
376
376
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spicenet-io/spiceflow-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0-private-rpc.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"docs:clean": "rimraf docs",
|
|
20
20
|
"docs:serve": "bunx http-server docs -p 3000 --silent",
|
|
21
21
|
"prepare": "husky || true",
|
|
22
|
-
"prepack": "bun run build"
|
|
22
|
+
"prepack": "bun run build && bun test tests/rpc-defaults.test.ts"
|
|
23
23
|
},
|
|
24
24
|
"exports": {
|
|
25
25
|
".": {
|