Skip to content

Commit

Permalink
more replacements
Browse files Browse the repository at this point in the history
  • Loading branch information
artursapek committed Oct 11, 2024
1 parent a532f63 commit 4745c1f
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 29 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ The Wormhole Typescript SDK is useful for interacting with the chains Wormhole s

## Warning

:warning: This package is a Work in Progress so the interface may change and there are likely bugs. Please [report](https://github.com/wormhole-foundation/connect-sdk/issues) any issues you find. :warning:
:warning: This package is a Work in Progress so the interface may change and there are likely bugs. Please [report](https://github.com/wormhole-foundation/wormhole-sdk-ts/issues) any issues you find. :warning:

## Installation

Expand Down Expand Up @@ -108,7 +108,7 @@ Understanding several higher level concepts of the SDK will help in using it eff
Every chain is its own special snowflake but many of them share similar functionality. The `Platform` modules provide a consistent interface for interacting with the chains that share a platform.

Each platform can be installed separately so that dependencies can stay as slim as possible.
See all supported platforms [here](https://github.com/wormhole-foundation/connect-sdk/tree/main/platforms)
See all supported platforms [here](https://github.com/wormhole-foundation/wormhole-sdk-ts/tree/main/platforms)

### Chain Context

Expand Down Expand Up @@ -207,7 +207,7 @@ export interface SignAndSendSigner {
}
```

See the testing signers ([Evm](https://github.com/wormhole-foundation/connect-sdk/blob/main/platforms/evm/src/signer.ts), [Solana](https://github.com/wormhole-foundation/connect-sdk/blob/main/platforms/solana/src/signer.ts), ...) for an example of how to implement a signer for a specific chain or platform.
See the testing signers ([Evm](https://github.com/wormhole-foundation/wormhole-sdk-ts/blob/main/platforms/evm/src/signer.ts), [Solana](https://github.com/wormhole-foundation/wormhole-sdk-ts/blob/main/platforms/solana/src/signer.ts), ...) for an example of how to implement a signer for a specific chain or platform.

### VAAs

Expand Down Expand Up @@ -402,7 +402,7 @@ const txGenerator = tb.createAttestation(token); // => AsyncGenerator<UnsignedTr
const txids = await signSendWait(srcChain, txGenerator, src.signer); // => TxHash[]
```

Supported protocols are defined in the [definitions module](https://github.com/wormhole-foundation/connect-sdk/tree/main/core/definitions/src/protocols).
Supported protocols are defined in the [definitions module](https://github.com/wormhole-foundation/wormhole-sdk-ts/tree/main/core/definitions/src/protocols).


## Transfers
Expand Down
8 changes: 4 additions & 4 deletions Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ load("__tests__/staging/wormhole/Tiltfile", "namespace", "k8s_yaml_with_ns", "se
config.clear_enabled_resources()
config.set_enabled_resources([
"guardian", # Also adds in all the chains we need
"connect-sdk-ci-tests"
"wormhole-sdk-ts-ci-tests"
])

# Without this, some resources cant find the namespace?
namespace_create(namespace, allow_duplicates=True)

docker_build(
ref = "connect-sdk-test",
ref = "wormhole-sdk-ts-test",
context = ".",
dockerfile = "__tests__/Dockerfile",
only = [],
Expand All @@ -22,8 +22,8 @@ docker_build(
k8s_yaml_with_ns(encode_yaml_stream(set_env_in_jobs(read_yaml_stream("__tests__/tests.yaml"), "NUM_GUARDIANS", str(num_guardians))))

k8s_resource(
"connect-sdk-ci-tests",
labels = ["connect-sdk-ci"],
"wormhole-sdk-ts-ci-tests",
labels = ["wormhole-sdk-ts-ci"],
trigger_mode = TRIGGER_MODE_AUTO,
resource_deps = [], # wait-run.sh, specified in the tests.yaml file, handles waiting. Not having deps gets the build earlier.
)
10 changes: 5 additions & 5 deletions __tests__/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ RUN npm i typescript -g
RUN mkdir -p /app
WORKDIR /app

COPY package.json package-lock.json ./connect-sdk/
COPY package.json package-lock.json ./wormhole-sdk-ts/
RUN --mount=type=cache,uid=1000,gid=1000,target=/home/node/.npm \
npm ci --prefix connect-sdk
COPY . ./connect-sdk
RUN npm run rebuild --prefix connect-sdk
npm ci --prefix wormhole-sdk-ts
COPY . ./wormhole-sdk-ts
RUN npm run rebuild --prefix wormhole-sdk-ts

RUN mkdir -p testing
COPY __tests__/wait-run.sh ./testing
WORKDIR /app/testing
WORKDIR /app/testing
6 changes: 3 additions & 3 deletions __tests__/tests.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
kind: Job
apiVersion: batch/v1
metadata:
name: connect-sdk-ci-tests
name: wormhole-sdk-ts-ci-tests
spec:
backoffLimit: 0
template:
spec:
restartPolicy: Never
containers:
- name: connect-sdk-ci-tests
image: connect-sdk-test
- name: wormhole-sdk-ts-ci-tests
image: wormhole-sdk-ts-test
command:
- /bin/sh
- -c
Expand Down
2 changes: 1 addition & 1 deletion __tests__/wait-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ num=${NUM_GUARDIANS:-1} # default value for NUM_GUARDIANS = 1
for ((i=0; i<num; i++)); do
while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' guardian-$i.guardian:6060/readyz)" != "200" ]]; do sleep 5; echo "waiting for guardian $i"; done
done
CI=true npm --prefix ../connect-sdk run test:tilt
CI=true npm --prefix ../wormhole-sdk-ts run test:tilt
6 changes: 3 additions & 3 deletions docs/index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html><html class="default" lang="en"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>Wormhole TS SDK - v0.7.0</title><meta name="description" content="Documentation for Wormhole TS SDK"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="assets/style.css"/><link rel="stylesheet" href="assets/highlight.css"/><script defer src="assets/main.js"></script><script async src="assets/icons.js" id="tsd-icons-script"></script><script async src="assets/search.js" id="tsd-search-script"></script><script async src="assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search" data-base="."><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="index.html" class="title">Wormhole TS SDK - v0.7.0</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><h2>Wormhole TS SDK - v0.7.0</h2></div><div class="tsd-panel tsd-typography"><a id="md:wormhole-ts-sdk" class="tsd-anchor"></a><h1><a href="#md:wormhole-ts-sdk">Wormhole TS SDK</a></h1><p>The Wormhole Typescript SDK is useful for interacting with the chains Wormhole supports and the <a href="#md:protocols">protocols</a> built on top of Wormhole.</p>
<a id="md:warning" class="tsd-anchor"></a><h2><a href="#md:warning">Warning</a></h2><p>:warning: This package is a Work in Progress so the interface may change and there are likely bugs. Please <a href="https://github.com/wormhole-foundation/connect-sdk/issues">report</a> any issues you find. :warning:</p>
<a id="md:warning" class="tsd-anchor"></a><h2><a href="#md:warning">Warning</a></h2><p>:warning: This package is a Work in Progress so the interface may change and there are likely bugs. Please <a href="https://github.com/wormhole-foundation/wormhole-sdk-ts/issues">report</a> any issues you find. :warning:</p>
<a id="md:installation" class="tsd-anchor"></a><h2><a href="#md:installation">Installation</a></h2><a id="md:basic" class="tsd-anchor"></a><h3><a href="#md:basic">Basic</a></h3><p>Install the (meta) package</p>
<pre><code class="language-bash"><span class="hl-0">npm</span><span class="hl-1"> </span><span class="hl-2">install</span><span class="hl-1"> </span><span class="hl-2">@wormhole-foundation/sdk</span>
</code><button>Copy</button></pre>
Expand Down Expand Up @@ -59,7 +59,7 @@
<a id="md:signers" class="tsd-anchor"></a><h3><a href="#md:signers">Signers</a></h3><p>In order to sign transactions, an object that fulfils the <code>Signer</code> interface is required. This is a simple interface that can be implemented by wrapping a web wallet or other signing mechanism.</p>
<pre><code class="language-ts"><span class="hl-3">// A Signer is an interface that must be provided to certain methods</span><br/><span class="hl-3">// in the SDK to sign transactions. It can be either a SignOnlySigner</span><br/><span class="hl-3">// or a SignAndSendSigner depending on circumstances.</span><br/><span class="hl-3">// A Signer can be implemented by wrapping an existing offline wallet</span><br/><span class="hl-3">// or a web wallet</span><br/><span class="hl-4">export</span><span class="hl-1"> </span><span class="hl-6">type</span><span class="hl-1"> </span><span class="hl-9">Signer</span><span class="hl-1"> = </span><span class="hl-9">SignOnlySigner</span><span class="hl-1"> | </span><span class="hl-9">SignAndSendSigner</span><span class="hl-1">;</span><br/><br/><span class="hl-3">// A SignOnlySender is for situations where the signer is not</span><br/><span class="hl-3">// connected to the network or does not wish to broadcast the</span><br/><span class="hl-3">// transactions themselves</span><br/><span class="hl-4">export</span><span class="hl-1"> </span><span class="hl-6">interface</span><span class="hl-1"> </span><span class="hl-9">SignOnlySigner</span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-0">chain</span><span class="hl-1">(): </span><span class="hl-9">ChainName</span><span class="hl-1">;</span><br/><span class="hl-1"> </span><span class="hl-0">address</span><span class="hl-1">(): </span><span class="hl-9">string</span><span class="hl-1">;</span><br/><span class="hl-1"> </span><span class="hl-3">// Accept an array of unsigned transactions and return</span><br/><span class="hl-1"> </span><span class="hl-3">// an array of signed and serialized transactions.</span><br/><span class="hl-1"> </span><span class="hl-3">// The transactions may be inspected or altered before</span><br/><span class="hl-1"> </span><span class="hl-3">// signing.</span><br/><span class="hl-1"> </span><span class="hl-3">// Note: The serialization is chain specific, if in doubt,</span><br/><span class="hl-1"> </span><span class="hl-3">// see the example implementations linked below</span><br/><span class="hl-1"> </span><span class="hl-0">sign</span><span class="hl-1">(</span><span class="hl-5">tx</span><span class="hl-1">: </span><span class="hl-9">UnsignedTransaction</span><span class="hl-1">[]): </span><span class="hl-9">Promise</span><span class="hl-1">&lt;</span><span class="hl-9">SignedTx</span><span class="hl-1">[]&gt;;</span><br/><span class="hl-1">}</span><br/><br/><span class="hl-3">// A SignAndSendSigner is for situations where the signer is</span><br/><span class="hl-3">// connected to the network and wishes to broadcast the</span><br/><span class="hl-3">// transactions themselves</span><br/><span class="hl-4">export</span><span class="hl-1"> </span><span class="hl-6">interface</span><span class="hl-1"> </span><span class="hl-9">SignAndSendSigner</span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-0">chain</span><span class="hl-1">(): </span><span class="hl-9">ChainName</span><span class="hl-1">;</span><br/><span class="hl-1"> </span><span class="hl-0">address</span><span class="hl-1">(): </span><span class="hl-9">string</span><span class="hl-1">;</span><br/><span class="hl-1"> </span><span class="hl-3">// Accept an array of unsigned transactions and return</span><br/><span class="hl-1"> </span><span class="hl-3">// an array of transaction ids in the same order as the</span><br/><span class="hl-1"> </span><span class="hl-3">// UnsignedTransactions array.</span><br/><span class="hl-1"> </span><span class="hl-0">signAndSend</span><span class="hl-1">(</span><span class="hl-5">tx</span><span class="hl-1">: </span><span class="hl-9">UnsignedTransaction</span><span class="hl-1">[]): </span><span class="hl-9">Promise</span><span class="hl-1">&lt;</span><span class="hl-9">TxHash</span><span class="hl-1">[]&gt;;</span><br/><span class="hl-1">}</span>
</code><button>Copy</button></pre>
<p>See the testing signers (<a href="https://github.com/wormhole-foundation/connect-sdk/blob/main/platforms/evm/src/signer.ts">Evm</a>, <a href="https://github.com/wormhole-foundation/connect-sdk/blob/main/platforms/solana/src/signer.ts">Solana</a>, ...) for an example of how to implement a signer for a specific chain or platform.</p>
<p>See the testing signers (<a href="https://github.com/wormhole-foundation/wormhole-sdk-ts/blob/main/platforms/evm/src/signer.ts">Evm</a>, <a href="https://github.com/wormhole-foundation/wormhole-sdk-ts/blob/main/platforms/solana/src/signer.ts">Solana</a>, ...) for an example of how to implement a signer for a specific chain or platform.</p>
<a id="md:protocols" class="tsd-anchor"></a><h3><a href="#md:protocols">Protocols</a></h3><p>While Wormhole itself is a Generic Message Passing protocol, a number of protocols have been built on top of it to provide specific functionality.</p>
<p>Each Protocol, if available, will have a Platform specific implementation. These implementations provide methods to generate transactions or read state from the contract on-chain.</p>
<a id="md:wormhole-core" class="tsd-anchor"></a><h4><a href="#md:wormhole-core">Wormhole Core</a></h4><p>The protocol that underlies all Wormhole activity is the Core protocol. This protocol is responsible for emitting the message containing the information necessary to perform bridging including <a href="https://docs.wormhole.com/wormhole/reference/glossary#emitter">Emitter address</a>, the <a href="https://docs.wormhole.com/wormhole/reference/glossary#sequence">Sequence number</a> for the message and the Payload of the message itself.</p>
Expand All @@ -75,7 +75,7 @@
<p>Using the <code>WormholeTransfer</code> abstractions is the recommended way to interact with these protocols but it is possible to use them directly</p>
<pre><code class="language-ts"><span class="hl-4">import</span><span class="hl-1"> { </span><span class="hl-5">signSendWait</span><span class="hl-1"> } </span><span class="hl-4">from</span><span class="hl-1"> </span><span class="hl-2">&quot;@wormhole-foundation/sdk&quot;</span><span class="hl-1">;</span><br/><br/><span class="hl-3">// ...</span><br/><br/><span class="hl-6">const</span><span class="hl-1"> </span><span class="hl-7">tb</span><span class="hl-1"> = </span><span class="hl-4">await</span><span class="hl-1"> </span><span class="hl-5">srcChain</span><span class="hl-1">.</span><span class="hl-0">getTokenBridge</span><span class="hl-1">(); </span><span class="hl-3">// =&gt; TokenBridge&lt;&#39;Evm&#39;&gt;</span><br/><br/><span class="hl-6">const</span><span class="hl-1"> </span><span class="hl-7">token</span><span class="hl-1"> = </span><span class="hl-2">&quot;0xdeadbeef...&quot;</span><span class="hl-1">;</span><br/><span class="hl-6">const</span><span class="hl-1"> </span><span class="hl-7">txGenerator</span><span class="hl-1"> = </span><span class="hl-5">tb</span><span class="hl-1">.</span><span class="hl-0">createAttestation</span><span class="hl-1">(</span><span class="hl-5">token</span><span class="hl-1">); </span><span class="hl-3">// =&gt; AsyncGenerator&lt;UnsignedTransaction, ...&gt;</span><br/><span class="hl-6">const</span><span class="hl-1"> </span><span class="hl-7">txids</span><span class="hl-1"> = </span><span class="hl-4">await</span><span class="hl-1"> </span><span class="hl-0">signSendWait</span><span class="hl-1">(</span><span class="hl-5">srcChain</span><span class="hl-1">, </span><span class="hl-5">txGenerator</span><span class="hl-1">, </span><span class="hl-5">src</span><span class="hl-1">.</span><span class="hl-5">signer</span><span class="hl-1">); </span><span class="hl-3">// =&gt; TxHash[]</span>
</code><button>Copy</button></pre>
<p>Supported protocols are defined in the <a href="https://github.com/wormhole-foundation/connect-sdk/tree/main/core/definitions/src/protocols">definitions module</a>.</p>
<p>Supported protocols are defined in the <a href="https://github.com/wormhole-foundation/wormhole-sdk-ts/tree/main/core/definitions/src/protocols">definitions module</a>.</p>
<a id="md:transfers" class="tsd-anchor"></a><h2><a href="#md:transfers">Transfers</a></h2><p>While using the <a href="#md:chain-context">ChainContext</a> and <a href="#md:protocols">Protocol</a> clients directly is possible, to do things like transfer tokens, the SDK provides some helpful abstractions.</p>
<p>The <code>WormholeTransfer</code> interface provides a convenient abstraction to encapsulate the steps involved in a cross-chain transfer.</p>
<a id="md:token-transfers" class="tsd-anchor"></a><h3><a href="#md:token-transfers">Token Transfers</a></h3><p>Performing a Token Transfer is trivial for any source and destination chains.</p>
Expand Down
Loading

0 comments on commit 4745c1f

Please sign in to comment.