@wonderland/interop 0.0.0 → 0.1.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 +130 -2
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +3 -0
- package/dist/src/index.js.map +1 -0
- package/package.json +36 -12
- package/LICENSE +0 -6
- package/index.d.ts +0 -1
- package/index.js +0 -1
package/README.md
CHANGED
|
@@ -1,3 +1,131 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @wonderland/interop
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A TypeScript library for handling interoperable blockchain addresses and cross-chain operations across different networks.
|
|
4
|
+
|
|
5
|
+
This package combines two powerful functionalities:
|
|
6
|
+
|
|
7
|
+
1. **Interoperable Addresses**: Provides methods to convert between human-readable addresses and their binary string representation, following the [ERC-7930](https://ethereum-magicians.org/t/erc-7930-interoperable-addresses/23365) standard. For backward compatibility with existing smart contracts, the package includes utilities to extract individual components (chainId and address) from the binary representation.
|
|
8
|
+
|
|
9
|
+
2. **Cross-Chain Operations**: Enables seamless token transfers and swaps between different blockchain networks through a unified API, supporting various bridge protocols.
|
|
10
|
+
|
|
11
|
+
```mermaid
|
|
12
|
+
graph LR
|
|
13
|
+
A[humanReadable]
|
|
14
|
+
C[binaryRepresentation]
|
|
15
|
+
D[chainId]
|
|
16
|
+
E[address]
|
|
17
|
+
F[Cross-Chain Operations]
|
|
18
|
+
G[Token Transfers]
|
|
19
|
+
|
|
20
|
+
A -->|humanReadableToBinary| C
|
|
21
|
+
C -->|binaryToHumanReadable| A
|
|
22
|
+
C -->|getChainId| D
|
|
23
|
+
C -->|getAddress| E
|
|
24
|
+
F -->|Transfer| G
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Setup
|
|
28
|
+
|
|
29
|
+
1. Install dependencies running `pnpm install`
|
|
30
|
+
|
|
31
|
+
## Available Scripts
|
|
32
|
+
|
|
33
|
+
Available scripts that can be run using `pnpm`:
|
|
34
|
+
|
|
35
|
+
| Script | Description |
|
|
36
|
+
| ------------- | ------------------------------------------------------- |
|
|
37
|
+
| `build` | Build library using tsc |
|
|
38
|
+
| `check-types` | Check types issues using tsc |
|
|
39
|
+
| `clean` | Remove `dist` folder |
|
|
40
|
+
| `lint` | Run ESLint to check for coding standards |
|
|
41
|
+
| `lint:fix` | Run linter and automatically fix code formatting issues |
|
|
42
|
+
| `format` | Check code formatting and style using Prettier |
|
|
43
|
+
| `format:fix` | Run formatter and automatically fix issues |
|
|
44
|
+
| `test` | Run tests using vitest |
|
|
45
|
+
| `test:cov` | Run tests with coverage report |
|
|
46
|
+
|
|
47
|
+
## Usage
|
|
48
|
+
|
|
49
|
+
### Interoperable Addresses
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
// Using the Provider
|
|
53
|
+
import { InteropAddressProvider } from '@wonderland/interop';
|
|
54
|
+
|
|
55
|
+
const humanReadableAddress = "alice.eth@eip155:1#ABCD1234"
|
|
56
|
+
const binaryAddress = InteropAddressProvider.humanReadableToBinary(humanReadableAddress)
|
|
57
|
+
|
|
58
|
+
// Or just importing the method
|
|
59
|
+
import { humanReadableToBinary } from '@wonderland/interop';
|
|
60
|
+
const binaryAddress = humanReadableToBinary(humanReadableAddress)
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Cross-Chain Operations
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
import { createCrossChainProvider } from "@wonderland/interop";
|
|
67
|
+
|
|
68
|
+
// Create a provider for a specific protocol (e.g., Across)
|
|
69
|
+
const provider = createCrossChainProvider("across");
|
|
70
|
+
|
|
71
|
+
// Get a quote for a cross-chain transfer
|
|
72
|
+
const quote = await provider.getQuote("crossChainTransfer", {
|
|
73
|
+
inputTokenAddress: "0x...",
|
|
74
|
+
outputTokenAddress: "0x...",
|
|
75
|
+
inputAmount: "1000000000000000000",
|
|
76
|
+
inputChainId: 1,
|
|
77
|
+
outputChainId: 137,
|
|
78
|
+
sender: "0x...",
|
|
79
|
+
recipient: "0x...",
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
// Simulate the transaction
|
|
83
|
+
const transactions = await provider.simulateOpen(quote.openParams);
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## API
|
|
87
|
+
|
|
88
|
+
### Interoperable Addresses
|
|
89
|
+
|
|
90
|
+
#### [InteropAddressProvider](./src/providers/InteropAddressProvider.ts)
|
|
91
|
+
|
|
92
|
+
Available methods:
|
|
93
|
+
|
|
94
|
+
- `humanReadableToBinary(humanReadableAddress: string)`
|
|
95
|
+
- `binaryToHumanReadable(binaryAddress: Hex)`
|
|
96
|
+
- `getChainId(binaryAddress: Hex)`
|
|
97
|
+
- `getAddress(binaryAddress: Hex)`
|
|
98
|
+
- `buildFromPayload(payload: InteropAddressFields)`
|
|
99
|
+
- `computeChecksum(humanReadableAddress: string)`
|
|
100
|
+
|
|
101
|
+
### Cross-Chain Operations
|
|
102
|
+
|
|
103
|
+
#### [CrossChainProviderFactory](./src/services/crossChainProviderFactory.ts)
|
|
104
|
+
|
|
105
|
+
The factory provides a standardized way to create and manage cross-chain providers for different protocols.
|
|
106
|
+
|
|
107
|
+
Available methods:
|
|
108
|
+
|
|
109
|
+
- `build<Protocol>(protocolName: Protocol, config?: Config, dependencies?: Dependencies)`: Creates a new provider instance for the specified protocol
|
|
110
|
+
- `createCrossChainProvider<Protocol>(protocolName: Protocol, config?: Config, dependencies?: Dependencies)`: Helper function to create a provider instance
|
|
111
|
+
|
|
112
|
+
#### [CrossChainExecutor](./src/services/crossChainExecutor.ts)
|
|
113
|
+
|
|
114
|
+
The executor handles the execution of cross-chain operations, providing a unified interface for different protocols.
|
|
115
|
+
|
|
116
|
+
Available methods:
|
|
117
|
+
|
|
118
|
+
- `execute(params: ExecutionParams)`: Executes a cross-chain operation
|
|
119
|
+
- `getQuotes(params: QuoteParams)`: Gets a quote for a cross-chain operation
|
|
120
|
+
|
|
121
|
+
Supported protocols:
|
|
122
|
+
|
|
123
|
+
- Across Protocol
|
|
124
|
+
- More protocols coming soon...
|
|
125
|
+
|
|
126
|
+
## References
|
|
127
|
+
|
|
128
|
+
- [ERC 7930: Interoperable Addresses](https://ethereum-magicians.org/t/erc-7930-interoperable-addresses/23365)
|
|
129
|
+
- [Viem Documentation](https://viem.sh/) - Low-level Ethereum interface used for transaction handling
|
|
130
|
+
- [Zod Documentation](https://zod.dev/) - TypeScript-first schema validation used for input validation
|
|
131
|
+
- [Cross-Chain Interoperability Standards](https://ethereum.org/en/developers/docs/bridges/) - Overview of cross-chain bridge concepts
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,iCAAiC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,iCAAiC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,14 +1,38 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"
|
|
13
|
-
|
|
2
|
+
"name": "@wonderland/interop",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Complete SDK for blockchain interoperability with cross-chain operations and address utilities",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/defi-wonderland/interop-sdk.git",
|
|
8
|
+
"directory": "apps/sdk"
|
|
9
|
+
},
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"author": "Wonderland",
|
|
12
|
+
"type": "module",
|
|
13
|
+
"main": "./dist/src/index.js",
|
|
14
|
+
"types": "./dist/src/index.d.ts",
|
|
15
|
+
"directories": {
|
|
16
|
+
"src": "src"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist/*",
|
|
20
|
+
"package.json",
|
|
21
|
+
"!**/*.tsbuildinfo"
|
|
22
|
+
],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "tsc -p tsconfig.build.json",
|
|
25
|
+
"check-types": "tsc --noEmit -p ./tsconfig.json",
|
|
26
|
+
"clean": "rm -rf dist/",
|
|
27
|
+
"format": "prettier --check \"{src,test}/**/*.{js,ts,json}\"",
|
|
28
|
+
"format:fix": "prettier --write \"{src,test}/**/*.{js,ts,json}\"",
|
|
29
|
+
"lint": "eslint \"{src,test}/**/*.{js,ts,json}\"",
|
|
30
|
+
"lint:fix": "pnpm lint --fix",
|
|
31
|
+
"test": "vitest run --config vitest.config.ts --passWithNoTests",
|
|
32
|
+
"test:cov": "vitest run --config vitest.config.ts --coverage"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@wonderland/interop-addresses": "0.1.0",
|
|
36
|
+
"@wonderland/interop-cross-chain": "0.1.0"
|
|
37
|
+
}
|
|
14
38
|
}
|
package/LICENSE
DELETED
package/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|