Skip to content

Commit cc2da60

Browse files
committed
add connect
1 parent ca0df6a commit cc2da60

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

DESIGN.md

+10-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ To address this goal, the SDK is structured into layers
1010
```
1111
core/ -- Low level packages
1212
base/ -- Constants and utilities
13-
definitions/ -- Definitions of interfaces required for Platforms, Protocol interfaces and Payload layout structures
13+
definitions/ -- Definitions of interfaces for Platforms/Protocols and Payload Layouts
1414
icons/ -- Logos for chains
1515
1616
connect/ -- Makes use of the interfaces in `definitions` to expose protocols in a platform independent way.
@@ -26,7 +26,7 @@ platforms/ -- Contains `Platform` and `Protocol` implementations
2626
solana/ -- Contains Solana `Platform` and `Protocol` implementations
2727
etc...
2828
29-
sdk/ -- Metapackage that depeneds on the rest of the packages, meant to be a simpler way to install/use. Exports packages in a way that allows for tree shaking unused packages and splitting chunks.
29+
sdk/ -- Metapackage that depeneds on the rest of the packages, meant to be a simpler way to install/use.
3030
3131
examples/ -- Examples, also used for README string replace
3232
```
@@ -48,6 +48,14 @@ A Protocol (fka `Module`) is a specific application, it provides a set of method
4848

4949
To allow platform agnostic access to Protocols, each Platform that provides the protocol should have its own implementation.
5050

51+
# Connect package
52+
53+
The `connect` package provides access to all the `Platform` and `Protocol` implementations through their interfaces.
54+
55+
The `Wormhole` class represents a context to register specific Platforms and set some initial configuration overrides. It provides utility methods to do things like create a `ChainContext` or parse an address.
56+
57+
The `routes` directory contains the logic to make use of the Protocol implementations by composing a route through the use of one or more Protocol interfaces.
58+
5159
# SDK package
5260

5361
The `@wormhole-foundation/sdk` package was created to reduce the confusion reported by devs around what they needed to install and use.

notes.md

+17-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This document details some things that could be improved about the SDK.
88

99
The [token registry](./tokenRegistry/) directory is unused except for importing the tokens from connect, which is no longer necessary.
1010

11-
It is still possible to screw up a transfer (blackhole funds) if the higher level constructs are not used and care is not taken to produce a transfer that is acceptable by the destination chain. I have no suggestions for this that would prevent the platform-specific-oddities from leaking into packages they have no business in besides "better documentation".
11+
It is still possible to screw up a transfer (blackhole funds) if the higher level constructs (`WormholeTransfer` or `Route`) are not used and care is not taken to produce a transfer that is acceptable by the destination chain. I have no suggestions for this that would prevent the platform-specific-oddities from leaking into packages they have no business in besides "better documentation" or disallow it completely.
1212

1313
Examples:
1414

@@ -27,7 +27,7 @@ Examples:
2727

2828
### Base
2929

30-
The [tokens](./core/base/src/constants/tokens) consts take up a lot of packed space for marginal benefit. Consider making these a wholly separate package that _can_ be installed and fetched when necessary.
30+
The [tokens](./core/base/src/constants/tokens) consts take up a lot of packed space in a widely used package for marginal benefit. Consider making these a wholly separate package that _can_ be installed and fetched when necessary.
3131

3232
The [nativeChainIds](./core/base/src/constants/nativeChainIds.ts) constants mix different chain id types, causing extra akward type checks to be done. Consider splitting these by platform so that when a `Chain` is passed, the type of chain id can be inferred. Also will help to distinguish between chain id _kinds_ (eip155 vs whatever) since they should be unique at least in that context.
3333

@@ -51,12 +51,24 @@ The [protocols](./core/definitions/src/protocols/) should have *standard* fields
5151
- A disciminator/serde for its VAAs/payloads
5252
- Standardized Errors that may be thrown
5353

54+
Note: it is possible to enforce a namespace adheres to an interface
55+
```ts
56+
interface x { doit(): void; }
57+
interface z { dont(): void; }
58+
namespace y { export function doit () { return; } }
59+
// ok
60+
y satisfies x;
61+
// not ok, will not compile
62+
// y satisfies z;
63+
```
5464

55-
## Connect
5665

66+
## Connect
5767

5868
The [Wormhole](./connect/src/wormhole.ts) class has spotty coverage of util methods. Some of the methods are awkward to have on `Wormhole` like `canonicalAddress` which is already an exported method.
5969

70+
Getting decent typehints for the [Route](./connect/src/routes/route.ts) implementations has been rough. We should, in the route, provide a typeguard that can be called to narrow the type to itself. This would be helpful to understand the exact types required as input (specific options per route, etc) and what is returned on output (more detailed route specific quote details, etc).
71+
6072
The [Receipt typeguards](./connect/src/types.ts) should also define `hasSourceInitiated`, `hasAttested`, etc for checking if the transfer is _past_ some step.
6173

6274
The [Wormholescan API](./connect/src/whscan-api.ts) should be better documented and possibly autogenerated from the swagger for the api.
@@ -67,7 +79,7 @@ The classes that implement the [WormholeTransfer](./connect/src/protocols/wormho
6779

6880
Every Protocol implementation defines its own private `createUnsignedTransaction` function, which, kinda sucks.
6981

70-
The Signer implementations are bad at things like gas estimation or handling errors. It should also provide support for transaction review prior to signing.
82+
The Signer implementations are bad at things like gas estimation or handling errors. They should also provide support for transaction review prior to signing.
7183

7284

7385
### Evm
@@ -94,5 +106,4 @@ The IBC protocol implementation should probably have just been `Gateway` instead
94106

95107
### Sui
96108

97-
Disaster show wrt types, a lot of weird type checking to get some deeply nested field in a MoveValue.
98-
109+
Disaster show wrt types, a lot of weird type checking to get some deeply nested field in a MoveValue.

0 commit comments

Comments
 (0)