Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync with wormhole master repo #1

Merged
merged 70 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
1845b03
fix: throws an `Error` object instead of plain string in `getTokenMap…
scnale Jul 30, 2024
3b27d05
connect: Added InReview transfer state, governor warnings and fixes
kev1n-peters Jul 29, 2024
1b8c5ba
connect: Added eta to quote interface
kev1n-peters Jul 30, 2024
01a4269
connect: added resume method to FinalizableRoute
kev1n-peters Aug 1, 2024
d2b5e5d
update berachain chain id for they testnet v2 (#653)
evgeniko Aug 3, 2024
8d980c7
contracts: update acala and karura testnet contracts (#654)
andreclaro Aug 5, 2024
5f01bf9
contracts: add Mantle and X Layer relayer addresses
evan-gray Aug 5, 2024
74eeb75
examples: fix type imports
kev1n-peters Aug 1, 2024
f9ff531
cctp: gas drop-off fix
kev1n-peters Aug 2, 2024
97d82a4
tokenBridge protocol: add token address conversion methods (#649)
kev1n-peters Aug 6, 2024
6ac2e72
version 0.9.0 (#657)
kev1n-peters Aug 6, 2024
e91bcce
Sui vite fix (#658)
kev1n-peters Aug 7, 2024
1e8e7fb
connect: Wormhole pass config to platform constructors (#660)
kev1n-peters Aug 7, 2024
a71945a
new TransferState that represents a refunded transfer (#663)
artursapek Aug 8, 2024
5f8ad99
version bump
artursapek Aug 8, 2024
3a77ef4
solana: fix determinePriorityFee method for VersionedTransactions (#665)
kev1n-peters Aug 8, 2024
d458954
static IS_AUTOMATIC & NATIVE_GAS_DROPOFF_SUPPORTED (#664)
artursapek Aug 8, 2024
faf96ba
0.10.0 version bump (#666)
kev1n-peters Aug 8, 2024
0bd3898
remove outdated relayer api from cctp example & readme (#662)
evgeniko Aug 9, 2024
23666ca
solana: added rpc-websockets dependency (#667)
kev1n-peters Aug 13, 2024
d6cedff
0.10.1 version bump (#670)
kev1n-peters Aug 13, 2024
e089eb8
bump web3.js and use ^ notation (#671)
artursapek Aug 13, 2024
45f4376
0.10.2
artursapek Aug 13, 2024
cc33e75
ETA adjustments (#672)
artursapek Aug 14, 2024
b2283dc
Added missing finality and block times (#674)
kev1n-peters Aug 22, 2024
fb6e21a
contracts: added arbitrum and optimism tb relayer addresses (#676)
kev1n-peters Aug 26, 2024
9abeccd
contracts: remove acala and karura standard relayer addresses (#677)
kev1n-peters Aug 26, 2024
0275091
0.10.3 version bump (#681)
kev1n-peters Aug 27, 2024
007f61b
tests: fix finality tests, run CI tests on pull requests (#682)
kev1n-peters Aug 27, 2024
8309985
Add Snaxchain mainnet support (#673)
bruce-riley Aug 29, 2024
430477a
move some solana utils from ntt sdk (#685)
nonergodic Sep 3, 2024
95912bc
Sepolia finality threshold (#688)
evgeniko Sep 5, 2024
9bb6fe3
0.10.4 version bump (#689)
evgeniko Sep 5, 2024
5810ebb
solana cctp: create ata if not exists in redeem function (#692)
kev1n-peters Sep 10, 2024
cc51d7c
Custom error class for minimum amount error (#321)
artursapek Sep 12, 2024
d61cc30
`amount.display`: Don't add trailing zeros by default (#696)
artursapek Sep 13, 2024
3607933
core/base: add snaxchain mainnet rpc (#697)
panoel Sep 13, 2024
dbbbc7c
Remove duplicate configs (#699)
eshaben Sep 18, 2024
b2268aa
tokenBridge: fromIdentifier amount scaling fix (#700)
kev1n-peters Sep 23, 2024
1249937
0.10.8 version bump (#702)
kev1n-peters Sep 23, 2024
94d966a
fix wrong bpfUpgradeableLoader layout (#704)
nonergodic Sep 25, 2024
3632223
automatic cctp: use MinAmountError (#703)
kev1n-peters Sep 27, 2024
fa4ba4b
0.10.9 version bump (#707)
kev1n-peters Sep 27, 2024
0d4bceb
Unichain testnet support (#713)
bruce-riley Oct 10, 2024
e997fce
Set unichain testnet RPC (#714)
bruce-riley Oct 10, 2024
0e7e158
0.11.0 version bump (#719)
kev1n-peters Oct 11, 2024
3f4c8e9
Added Portico Bridge USDT support (#552)
kev1n-peters Oct 16, 2024
5325c12
Add Worldchain testnet (#721)
bruce-riley Oct 21, 2024
194b44a
a little README grooming (#723)
artursapek Oct 23, 2024
b44cd1a
Add Monad Devnet support (#726)
bruce-riley Oct 24, 2024
8d3a680
Sui CCTP support (#718)
artursapek Oct 28, 2024
6ff334b
0.14.0 version bump (#727)
kev1n-peters Oct 28, 2024
cf07b6a
Disable Sui CCTP (#729)
artursapek Oct 31, 2024
074b9aa
Include Spl Token 2022 in getBalances (#728)
yuli-ferna Nov 1, 2024
870323f
Add MonadDevnet blocktime (#732)
kev1n-peters Nov 5, 2024
9396746
use 72 blocks for eth finality which should cover p75 (#733)
kev1n-peters Nov 7, 2024
d847b4d
sui: getCoinType native token address fix (#734)
kev1n-peters Nov 8, 2024
4dd0795
removed automatic route isAvailable method (#720)
kev1n-peters Nov 11, 2024
dd576e0
remove redundant method from Route interface (#736)
artursapek Nov 12, 2024
46ffba0
1.0.3 version bump (#735)
kev1n-peters Nov 12, 2024
a2ec724
Ink testnet and Worldchain mainnet support (#737)
bruce-riley Nov 12, 2024
76b2031
Update Monad devnet core address (#739)
bruce-riley Nov 14, 2024
394b7fd
fix, cleanup, and tighten type programming utils (#710)
nonergodic Nov 21, 2024
0c57292
extract layouting into standalone package and adjust for changes (#738)
nonergodic Nov 21, 2024
cff7ce2
Make sure both chains are supported (#744)
artursapek Nov 25, 2024
9105de2
sepolia finality should be 72 (#745)
kev1n-peters Nov 26, 2024
d4b2fea
Fix infinite loop in address parsing (#746)
artursapek Dec 3, 2024
bfedcc6
bump @solana/web3.js to ^1.95.8 (#747)
kev1n-peters Dec 4, 2024
a4f49e3
ensure token address is a string
artursapek Dec 11, 2024
4b43423
Merge pull request #753 from wormhole-foundation/fix-spl-balance-fetc…
artursapek Dec 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
name: Node.js CI
on: [push]
on:
workflow_dispatch:
pull_request:
push:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
14 changes: 3 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# Wormhole TS SDK
# Wormhole TypeScript SDK

The Wormhole Typescript SDK is useful for interacting with the chains Wormhole supports and the [protocols](#protocols) built on top of Wormhole.

## Warning
[![npm version](https://img.shields.io/npm/v/@wormhole-foundation/sdk.svg)](https://www.npmjs.com/package/@wormhole-foundation/sdk)

: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:
The Wormhole Typescript SDK is useful for interacting with the chains Wormhole supports and the [protocols](#protocols) built on top of Wormhole.

## Installation

Expand Down Expand Up @@ -497,12 +495,6 @@ We can also transfer native USDC using [Circle's CCTP](https://www.circle.com/en
const srcTxids = await xfer.initiateTransfer(src.signer);
console.log(`Started Transfer: `, srcTxids);

if (req.automatic) {
const relayStatus = await waitForRelay(srcTxids[srcTxids.length - 1]!);
console.log(`Finished relay: `, relayStatus);
return;
}

// Note: Depending on chain finality, this timeout may need to be increased.
// See https://developers.circle.com/stablecoin/docs/cctp-technical-reference#mainnet for more
console.log("Waiting for Attestation");
Expand Down
8 changes: 0 additions & 8 deletions connect/__tests__/mocks/routes/automatic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,6 @@ export class AutomaticMockRoute<N extends Network>
return [nativeTokenId(toChain.chain)];
}

static isProtocolSupported<N extends Network>(chain: ChainContext<N>): boolean {
return true;
}

async isAvailable(): Promise<boolean> {
return true;
}

async validate(
request: RouteTransferRequest<N>,
params: TransferParams<Op>,
Expand Down
4 changes: 0 additions & 4 deletions connect/__tests__/mocks/routes/manual.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ export class ManualMockRoute<N extends Network>
return [nativeTokenId(toChain.chain)];
}

static isProtocolSupported<N extends Network>(chain: ChainContext<N>): boolean {
return true;
}

async validate(
request: RouteTransferRequest<N>,
params: TransferParams<Op>,
Expand Down
6 changes: 3 additions & 3 deletions connect/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wormhole-foundation/sdk-connect",
"version": "0.8.2-beta.0",
"version": "1.0.3",
"repository": {
"type": "git",
"url": "git+https://github.com/wormhole-foundation/connect-sdk.git"
Expand Down Expand Up @@ -98,8 +98,8 @@
},
"dependencies": {
"axios": "^1.4.0",
"@wormhole-foundation/sdk-base": "0.8.2-beta.0",
"@wormhole-foundation/sdk-definitions": "0.8.2-beta.0"
"@wormhole-foundation/sdk-base": "1.0.3",
"@wormhole-foundation/sdk-definitions": "1.0.3"
},
"type": "module"
}
1 change: 1 addition & 0 deletions connect/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export * from "./wormhole.js";
export * from "./config.js";
export * from "./common.js";
export * from "./types.js";
export * from "./warnings.js";

export * from "./protocols/index.js";

Expand Down
29 changes: 20 additions & 9 deletions connect/src/protocols/cctp/cctpTransfer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Chain, Network } from "@wormhole-foundation/sdk-base";
import { circle, encoding, toChain } from "@wormhole-foundation/sdk-base";
import { circle, encoding, finality, guardians, toChain } from "@wormhole-foundation/sdk-base";
import type {
Attestation,
AttestationId,
Expand Down Expand Up @@ -34,7 +34,13 @@ import type {
TransferQuote,
TransferReceipt as _TransferReceipt,
} from "../../types.js";
import { TransferState, isAttested, isSourceFinalized, isSourceInitiated } from "../../types.js";
import {
TransferState,
isAttested,
isRedeemed,
isSourceFinalized,
isSourceInitiated,
} from "../../types.js";
import { Wormhole } from "../../wormhole.js";
import type { WormholeTransfer } from "../wormholeTransfer.js";

Expand Down Expand Up @@ -225,10 +231,10 @@ export class CircleTransfer<N extends Network = Network>
try {
msgIds = await fromChain.parseTransaction(txid);
} catch (e: any) {
if (e.message.includes('no bridge messages found')) {
if (e.message.includes("no bridge messages found")) {
// This means it's a Circle attestation; swallow
} else {
throw e
throw e;
}
}

Expand Down Expand Up @@ -536,7 +542,7 @@ export namespace CircleTransfer {
// Fall back to asking the destination chain if this VAA has been redeemed
// assuming we have the full attestation

if (isAttested(receipt)) {
if (isAttested(receipt) || isRedeemed(receipt)) {
const isComplete = await CircleTransfer.isTransferComplete(
_toChain,
receipt.attestation.attestation,
Expand Down Expand Up @@ -584,10 +590,14 @@ export namespace CircleTransfer {
const dstToken = Wormhole.chainAddress(dstChain.chain, dstUsdcAddress);
const srcToken = Wormhole.chainAddress(srcChain.chain, srcUsdcAddress);

// https://developers.circle.com/stablecoins/docs/required-block-confirmations
const eta =
(srcChain.chain === "Polygon" ? 2_000 * 200 : finality.estimateFinalityTime(srcChain.chain)) + guardians.guardianAttestationEta;
if (!transfer.automatic) {
return {
sourceToken: { token: srcToken, amount: transfer.amount },
destinationToken: { token: dstToken, amount: transfer.amount },
eta,
};
}

Expand All @@ -600,15 +610,15 @@ export namespace CircleTransfer {

// The fee is also removed from the amount transferred
// quoted on the source chain
const stb = await srcChain.getAutomaticCircleBridge();
const fee = await stb.getRelayerFee(dstChain.chain);
const scb = await srcChain.getAutomaticCircleBridge();
const fee = await scb.getRelayerFee(dstChain.chain);
dstAmount -= fee;

// The expected destination gas can be pulled from the destination token bridge
let destinationNativeGas = 0n;
if (transfer.nativeGas) {
const dtb = await dstChain.getAutomaticTokenBridge();
destinationNativeGas = await dtb.nativeTokenAmount(dstToken.address, _nativeGas);
const dcb = await dstChain.getAutomaticCircleBridge();
destinationNativeGas = await dcb.nativeTokenAmount(_nativeGas);
}

return {
Expand All @@ -619,6 +629,7 @@ export namespace CircleTransfer {
destinationToken: { token: dstToken, amount: dstAmount },
relayFee: { token: srcToken, amount: fee },
destinationNativeGas,
eta,
};
}

Expand Down
Loading
Loading