You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: DESIGN.md
+17-3
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,6 @@
1
+
# Design
1
2
2
-
# Structure
3
+
##Structure
3
4
4
5
A primary goal for the SDK was to provide modular and specific access to the protocols build on Wormhole.
5
6
@@ -30,7 +31,9 @@ sdk/ -- Metapackage that depeneds on the rest of the packages, meant to be a sim
30
31
examples/ -- Examples, also used for README string replace
31
32
```
32
33
33
-
# Platform Interfaces
34
+
# Interfaces
35
+
36
+
## Platform Interfaces
34
37
35
38
Several interfaces should be available for each platform supported.
36
39
@@ -39,8 +42,19 @@ Several interfaces should be available for each platform supported.
39
42
- A `Signer` is an interface that provides a callback to `sign` or `signAndSend` one or more transaction objects.
40
43
- An `Address` provides parsing/formatting/conversion for platform specific addresses.
41
44
42
-
# Protocol Interfaces
45
+
##Protocol Interfaces
43
46
44
47
A Protocol (fka `Module`) is a specific application, it provides a set of methods that can be called to accomplish some action (e.g. `TokenBridge` allows `transfer`/`redeem`/`getWrappedAsset`, etc...)
45
48
46
49
To allow platform agnostic access to Protocols, each Platform that provides the protocol should have its own implementation.
50
+
51
+
# SDK package
52
+
53
+
The `@wormhole-foundation/sdk` package was created to reduce the confusion reported by devs around what they needed to install and use.
54
+
55
+
Because this project has strict separation of platform implementation packages, the registration of platforms and protocols is done as a side effect. As a result, naked imports may be required for lower level packages to be properly registered.
56
+
57
+
This package specifies _all_ platforms and protocols as dependencies which increases installed size but provides provides conditional exports for each `Platform` to allow for a smaller bundle size.
58
+
59
+
Each platform has a `PlatformDefiniton` containing the `Platform` specific implementations that can be imported directly or through the `PlatformLoader` which ensures the protocols are registered as well.
Copy file name to clipboardexpand all lines: notes.md
+14-6
Original file line number
Diff line number
Diff line change
@@ -29,15 +29,19 @@ Examples:
29
29
30
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.
31
31
32
-
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).
32
+
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.
33
33
34
34
### Definitions
35
35
36
36
The [layouts](./core/definitions/src/protocols/tokenBridge/tokenBridgeLayout.ts) for the protocols are very difficult to read/comprehend from just source. We should have some way to write out the full object produced so that the fields it contains are easier to read.
37
37
38
38
The [Attestation/AttestationId](./core/definitions/src/attestation.ts) should be registered along with the protocol instead of having a hardcoded switch case. The current definition makes it very awkward to use for anything outside this repo, but since its used in the Routes, external "plugins" need to have _something_. This forces the Attestation type to be a punted `VAA<"Uint8Array">`
39
39
40
-
The [RPC](./core/definitions/src/rpc.ts) is a punted `any` type. It could benefit from the same type registration as others, where the exact type is set in some namespace so that type inteference would be happy with something like `(await solChain.getRpc()) satisfies Connection`
40
+
The [RPC](./core/definitions/src/rpc.ts) is a punted `any` type. It could benefit from the same type registration as others, where the exact type is set in some namespace so that type inteference would be happy with something like:
The [protocols](./core/definitions/src/protocols/) should have *standard* fields in their respective `namespace` for things like:
43
47
@@ -51,19 +55,19 @@ The [protocols](./core/definitions/src/protocols/) should have *standard* fields
51
55
## Connect
52
56
53
57
54
-
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.
58
+
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.
55
59
56
60
The [Receipt typeguards](./connect/src/types.ts) should also define `hasSourceInitiated`, `hasAttested`, etc for checking if the transfer is _past_ some step.
57
61
58
62
The [Wormholescan API](./connect/src/whscan-api.ts) should be better documented and possibly autogenerated from the swagger for the api.
59
63
60
-
The classes that implement the [WormholeTransfer](./connect/src/protocols/wormholeTransfer.ts) should be deprecated in favor of the `Route` usage.
64
+
The classes that implement the [WormholeTransfer](./connect/src/protocols/wormholeTransfer.ts) should be deprecated in favor of the `Route` usage. The underlying code should be preserved and made available in a static context where all args are provided rather than keeping state in the `WormholeTransfer` object.
61
65
62
66
## Platforms
63
67
64
68
Every Protocol implementation defines its own private `createUnsignedTransaction` function, which, kinda sucks.
65
69
66
-
The Signer implementations are bad at things like gas estimation or handling errors. It should also provide better support for transaction review prior to signing and sending.
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.
67
71
68
72
69
73
### Evm
@@ -76,7 +80,7 @@ Consider removing [Portico](./platforms/evm/protocols/portico/) completely from
76
80
77
81
A lot of the code here was copy/pasted without regard to what was actually necessary. Consider purging any unused functions.
78
82
79
-
While the `Buffer` type has been kept out of most packages, the Solana packages seem to really want it for now. When the next version of the Solana SDK is released, consider trying to purge it completely.
83
+
While the `Buffer` type has been kept out of most packages intentionally, the Solana packages have not been as strict. For web applications this can still be a pain, consider trying to purge it completely.
80
84
81
85
The [Unsigned Transaction](./platforms/solana/src/unsignedTransaction.ts) type can handle versioned transactions but we still only produce the legacy transaction type. We should produce the versioned transactions since they'll provide more features in the future, [issue here](https://github.com/wormhole-foundation/wormhole-sdk-ts/issues/163).
82
86
@@ -88,3 +92,7 @@ The IBC channel consts need to be updated with the [fetch-registry](./platforms/
88
92
89
93
The IBC protocol implementation should probably have just been `Gateway` instead or a new Protocol for `Gateway` specific methods should have been created. The connect package GatewayTransfer is made awkard by the current setup.
90
94
95
+
### Sui
96
+
97
+
Disaster show wrt types, a lot of weird type checking to get some deeply nested field in a MoveValue.
0 commit comments