
Security News
Risky Biz Podcast: Making Reachability Analysis Work in Real-World Codebases
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
@shapeshiftoss/caip
Advanced tools
This package is ShapeShift's partial implementation of CAIPs - Chain Agnostic Improvement Protocols. It is not exhaustive and is currently only used internally.
https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/caip-2.md
Usage
toChainId
| toCAIP2
const chainNamespace = CHAIN_NAMESPACE.Evm
const chainReference = CHAIN_REFERENCE.EthereumMainnet
const result = toChainId({ chainNamespace, chainReference })
expect(result).toEqual('eip155:1')
fromChainId
| fromCAIP2
const ethereumChainId = 'eip155:1'
const { chainNamespace, chainReference } = fromChainId(ethereumChainId)
expect(chainNamespace).toEqual(CHAIN_NAMESPACE.Evm)
expect(chainReference).toEqual(CHAIN_REFERENCE.EthereumMainnet)
https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/caip-10.md
Usage
toAccountId
| toCAIP10
const chainNamespace = CHAIN_NAMESPACE.Evm
const chainReference = CHAIN_REFERENCE.EthereumMainnet
const chainId = toChainId({ chainNamespace, chainReference })
const account = '0xa44c286ba83bb771cd0107b2c1df678435bd1535'
const expectedAccountId = `${chainId}:${account}`
expect(toAccountId({ chainId, account })).toEqual('eip155:1:0xa44c286ba83bb771cd0107b2c1df678435bd1535')
expect(toAccountId({ chainNamespace, chainReference, account })).toEqual('eip155:1:0xa44c286ba83bb771cd0107b2c1df678435bd1535')
fromAccountId
| fromCAIP10
const accountId = 'eip155:1:0xa44c286ba83bb771cd0107b2c1df678435bd1535'
const { account, chainId, chainNamespace, chainReference } = fromAccountId(accountId)
expect(account).toEqual(0xa44c286ba83bb771cd0107b2c1df678435bd1535)
expect(chainNamespace).toEqual('eip155')
expect(chainReference).toEqual('1')
expect(chainId).toEqual('eip155:1')
https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/caip-19.md
Usage
toAssetId
| toCAIP19
Ether
const chainNamespace = CHAIN_NAMESPACE.Evm
const chainReference = CHAIN_REFERENCE.EthereumMainnet
const chainId = toChainId({ chainNamespace, chainReference })
const assetNamespace = 'slip44'
const assetReference = ASSET_REFERENCE.Ethereum
expect(toAssetId({ chainNamespace, chainReference, assetNamespace, assetReference })).toEqual('eip155:1/slip44:60')
expect(toAssetId({ chainId, assetNamespace, assetReference })).toEqual('eip155:1/slip44:60')
ERC20 token
const chainNamespace = CHAIN_NAMESPACE.Evm
const chainReference = CHAIN_REFERENCE.EthereumMainnet
const chainId = toChainId({ chainNamespace, chainReference })
const assetNamespace = 'erc20'
const assetReference = '0xc770eefad204b5180df6a14ee197d99d808ee52d'
expect(toAssetId({ chainNamespace, chainReference, assetNamespace, assetReference })).toEqual('eip155:1/erc20:0xc770eefad204b5180df6a14ee197d99d808ee52d')
expect(toAssetId({ chainId, assetNamespace, assetReference })).toEqual('eip155:1/erc20:0xc770eefad204b5180df6a14ee197d99d808ee52d')
fromAssetId
| fromCAIP19
Ether
const assetId = 'eip155:1/slip44:60'
const { chainId, chainReference, chainNamespace, assetNamespace, assetReference } = fromAssetId(AssetId)
expect(chainNamespace).toEqual('eip155')
expect(chainReference).toEqual('1')
expect(chainId).toEqual('eip155:1')
expect(assetNamespace).toEqual('slip44')
expect(assetReference).toEqual('60')
ERC20 token
const assetId = 'eip155:1/erc20:0xc770eefad204b5180df6a14ee197d99d808ee52d'
const { chainId, chainReference, chainNamespace, assetNamespace, assetReference } = fromAssetId(AssetId)
expect(chainNamespace).toEqual('eip155')
expect(chainReference).toEqual('1')
expect(chainId).toEqual('eip155:1')
expect(assetNamespace).toEqual('erc20')
expect(assetReference).toEqual('0xc770eefad204b5180df6a14ee197d99d808ee52d')
Adapters map asset IDs and map them to vendor-specific (e.g. CoinGecko) IDs.
This allows us to use asset IDs internally and keep any vendor IDs at the boundary.
To generate new static adapter data, run the following
cd packages/caip
yarn generate
and commit the generated adapter.json
files.
console.log(coingeckoToAssetIds('shapeshift-fox-token'))
[eip155:1/erc20:0xc770eefad204b5180df6a14ee197d99d808ee52d]
console.log(assetIdToCoingecko('bip122:000000000019d6689c085ae165831e93/slip44:0'))
bitcoin
FAQs
CAIP Implementation
The npm package @shapeshiftoss/caip receives a total of 8 weekly downloads. As such, @shapeshiftoss/caip popularity was classified as not popular.
We found that @shapeshiftoss/caip demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.