Skip to content

Commit

Permalink
move protocols to their own directory
Browse files Browse the repository at this point in the history
  • Loading branch information
barnjamin committed Aug 24, 2023
1 parent 362f2ba commit 555d208
Show file tree
Hide file tree
Showing 22 changed files with 2,204 additions and 2,198 deletions.
2 changes: 1 addition & 1 deletion core/connect/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ export * from './wormhole';
export * from './types';
export * from './constants';
export * from './wormholeTransfer';
export * from './tokenTransfer';
export * from './protocols/tokenTransfer';
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@ import {
CCTPTransferDetails,
isCCTPTransferDetails,
TokenTransferTransaction,
} from './types';
import { WormholeTransfer, TransferState } from './wormholeTransfer';
import { Wormhole } from './wormhole';
} from '../types';
import { WormholeTransfer, TransferState } from '../wormholeTransfer';
import { Wormhole } from '../wormhole';
import {
NativeAddress,
UniversalAddress,
UnsignedTransaction,
VAA,
deserialize,
} from '@wormhole-foundation/sdk-definitions';
import { ChainName } from '@wormhole-foundation/sdk-base';
import { ChainName, PlatformName } from '@wormhole-foundation/sdk-base';

/**
* What do with multiple transactions or VAAs?
Expand All @@ -41,7 +42,7 @@ export class CCTPTransfer implements WormholeTransfer {
// The corresponding vaa representing the CCTPTransfer
// on the source chain (if its been completed and finalized)
vaas?: {
emitter: UniversalAddress;
emitter: UniversalAddress | NativeAddress<PlatformName>;
sequence: bigint;
vaa?: VAA<'Transfer'> | VAA<'TransferWithPayload'>;
}[];
Expand Down Expand Up @@ -298,7 +299,7 @@ export class CCTPTransfer implements WormholeTransfer {
static async getTransferVaa(
wh: Wormhole,
chain: ChainName,
emitter: UniversalAddress,
emitter: UniversalAddress | NativeAddress<PlatformName>,
sequence: bigint,
retries: number = 5,
): Promise<VAA<'Transfer'> | VAA<'TransferWithPayload'>> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import {
isMessageIdentifier,
isTokenTransferDetails,
isTransactionIdentifier,
} from './types';
import { WormholeTransfer, TransferState } from './wormholeTransfer';
import { Wormhole } from './wormhole';
} from '../types';
import { WormholeTransfer, TransferState } from '../wormholeTransfer';
import { Wormhole } from '../wormhole';
import {
UniversalAddress,
UnsignedTransaction,
Expand Down
7 changes: 4 additions & 3 deletions core/connect/src/wormhole.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
deserialize,
VAA,
ChainAddress,
NativeAddress,
} from '@wormhole-foundation/sdk-definitions';
import axios, { AxiosResponse } from 'axios';

Expand All @@ -22,8 +23,8 @@ import {
} from './types';

import { CONFIG } from './constants';
import { TokenTransfer } from './tokenTransfer';
import { CCTPTransfer } from './cctpTransfer';
import { TokenTransfer } from './protocols/tokenTransfer';
import { CCTPTransfer } from './protocols/cctpTransfer';

export class Wormhole {
protected _platforms: Map<PlatformName, Platform>;
Expand Down Expand Up @@ -242,7 +243,7 @@ export class Wormhole {
*/
async getVAABytes(
chain: ChainName,
emitter: UniversalAddress,
emitter: UniversalAddress | NativeAddress<PlatformName>,
sequence: bigint,
retries: number = 5,
): Promise<Uint8Array | undefined> {
Expand Down
19 changes: 0 additions & 19 deletions core/definitions/src/automaticTokenBridge.ts

This file was deleted.

6 changes: 2 additions & 4 deletions core/definitions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,5 @@ export * from "./vaa";
export * from "./unsignedTransaction";
export * from "./utils";
export * from "./relayer";
export * from "./tokenBridge";
export * from "./automaticTokenBridge";
export * from "./wormholeCircleRelayer";
export * from "./circleBridge";
export * from "./protocols/tokenBridge";
export * from "./protocols/cctp";
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
import { PlatformName } from "@wormhole-foundation/sdk-base";
import { UniversalOrNative, ChainAddress } from "./address";
import { UnsignedTransaction } from "./unsignedTransaction";
import { VAA } from "./vaa";
import { UniversalOrNative, ChainAddress } from "../address";
import { UnsignedTransaction } from "../unsignedTransaction";
import { VAA } from "../vaa";

//https://github.com/circlefin/evm-cctp-contracts

export interface WormholeCircleRelayer<P extends PlatformName> {
transfer(
token: ChainAddress,
sender: UniversalOrNative<P>,
recipient: ChainAddress,
amount: bigint,
nativeGas?: bigint
): AsyncGenerator<UnsignedTransaction>;
}

export interface CircleBridge<P extends PlatformName> {
redeem(
sender: UniversalOrNative<P>,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { PlatformName } from "@wormhole-foundation/sdk-base";
import { UniversalOrNative, NativeAddress, ChainAddress } from "./address";
import { VAA } from "./vaa";
import { UnsignedTransaction } from "./unsignedTransaction";
import "./payloads/tokenBridge";
import { UniversalOrNative, NativeAddress, ChainAddress } from "../address";
import { VAA } from "../vaa";
import { UnsignedTransaction } from "../unsignedTransaction";
import "../payloads/tokenBridge";

export interface TokenBridge<P extends PlatformName> {
//read-only:
Expand Down Expand Up @@ -36,3 +36,17 @@ export interface TokenBridge<P extends PlatformName> {
unwrapNative?: boolean //default: true
): AsyncGenerator<UnsignedTransaction>;
}

export interface AutomaticTokenBridge<P extends PlatformName> {
transfer(
sender: UniversalOrNative<P>,
recipient: ChainAddress,
token: UniversalOrNative<P> | "native",
amount: bigint,
nativeGas?: bigint
): AsyncGenerator<UnsignedTransaction>;
redeem(
sender: UniversalOrNative<P>,
vaa: VAA<"TransferWithPayload">
): AsyncGenerator<UnsignedTransaction>;
}
13 changes: 0 additions & 13 deletions core/definitions/src/wormholeCircleRelayer.ts

This file was deleted.

3 changes: 3 additions & 0 deletions platforms/evm/src/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ export class EvmAddress implements Address {
toString() {
return this.address;
}
toNative() {
return this.address;
}
toUint8Array() {
return ethers.getBytes(this.address);
}
Expand Down
Loading

0 comments on commit 555d208

Please sign in to comment.