New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@wormhole-foundation/sdk-definitions

Package Overview
Dependencies
Maintainers
5
Versions
274
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wormhole-foundation/sdk-definitions - npm Package Compare versions

Comparing version 0.4.0-beta.9 to 0.4.0-beta.10

24

dist/cjs/address.d.ts
import { Chain, ChainToPlatform, Platform } from "@wormhole-foundation/sdk-base";
import { UniversalAddress } from "./universalAddress";
/**
* Address is the base interface all address types must implement.
*
* Represents a parsed address
*/
export interface Address {
/**
* unwrap returns the underlying native address type, e.g.:
* a Uint8Array for UniversalAddress
* a checksum hex string string for EVM(ethers)
* a PublicKey for Solana
* etc.
*/
unwrap(): unknown;
/** Return the address in its canonical string format */
toString(): string;
/** Return the bytes for the address */
toUint8Array(): Uint8Array;
/** Return an Address that has been converted to its Universal representation */
toUniversalAddress(): UniversalAddress;

@@ -16,6 +31,14 @@ }

export type MappedPlatforms = keyof WormholeNamespace.PlatformToNativeAddressMapping;
/** Utility type to map platform to its native address implementation */
type GetNativeAddress<P extends Platform> = P extends MappedPlatforms ? WormholeNamespace.PlatformToNativeAddressMapping[P] : never;
/** An address that has been parsed into its Nativfe Address type */
export type NativeAddress<C extends Chain> = GetNativeAddress<ChainToPlatform<C>>;
/** A union type representing a parsed address */
export type UniversalOrNative<C extends Chain> = UniversalAddress | NativeAddress<C>;
/** An address that represents an account */
export type AccountAddress<C extends Chain> = UniversalOrNative<C>;
/**
* ChainAddress represents the parsed address for a given chain
* and comes with the context of which chain its relevant for
*/
export type ChainAddress<C extends Chain = Chain> = {

@@ -28,2 +51,3 @@ readonly chain: C;

export declare function nativeIsRegistered<C extends Chain>(chain: C): boolean;
/** Parse an address into its NativeAddress representation */
export declare function toNative<C extends Chain>(chain: C, ua: UniversalAddress | string | Uint8Array): NativeAddress<C>;

@@ -30,0 +54,0 @@ export declare function toUniversal<C extends Chain>(chain: C, address: string | Uint8Array): UniversalAddress;

1

dist/cjs/address.js

@@ -26,2 +26,3 @@ "use strict";

exports.nativeIsRegistered = nativeIsRegistered;
/** Parse an address into its NativeAddress representation */
function toNative(chain, ua) {

@@ -28,0 +29,0 @@ const platform = sdk_base_1.chainToPlatform.get(chain);

@@ -10,4 +10,13 @@ import { Chain } from "@wormhole-foundation/sdk-base";

import { VAA } from "./vaa";
/**
* The Identifier of an attestation, useful to look up the full attestation
*/
export type AttestationId<PN extends ProtocolName = ProtocolName> = PN extends "TokenBridge" | "AutomaticTokenBridge" | "WormholeCore" | "PorticoBridge" | "AutomaticCircleBridge" ? WormholeMessageId : PN extends "AutomaticCircleBridge" ? WormholeMessageId | CircleMessageId : PN extends "CircleBridge" ? CircleMessageId : PN extends "IbcBridge" ? IbcMessageId : never;
/**
* The full attestation that represents evidence of a transaction
*/
export type Attestation<PN extends ProtocolName = ProtocolName> = PN extends "TokenBridge" | "AutomaticTokenBridge" ? AutomaticTokenBridge.VAA | TokenBridge.VAA : PN extends "AutomaticCircleBridge" ? AutomaticCircleBridge.VAA | CircleBridge.Attestation : PN extends "CircleBridge" ? CircleBridge.Attestation : PN extends "IbcBridge" ? IbcTransferData : PN extends "WormholeCore" ? VAA<"Uint8Array"> : PN extends "PorticoBridge" ? PorticoBridge.VAA : never;
/**
* Wormhole Message Identifier used to fetch a VAA
*/
export type WormholeMessageId = {

@@ -20,2 +29,6 @@ chain: Chain;

export type getWormholeAttestation = (id: WormholeMessageId) => Promise<VAA>;
/**
* Circle Message Identifier
* Used to fetch a Circle attestation
*/
export type CircleMessageId = {

@@ -25,4 +38,9 @@ hash: string;

export declare function isCircleMessageId(thing: CircleMessageId | any): thing is CircleMessageId;
/** Attestation from circle attestation api */
export type CircleAttestation = string;
export type getCircleAttestation = (id: CircleMessageId) => Promise<CircleAttestation>;
/**
* Ibc Message Identifier
* Used to fetch a Ibc attestation
*/
export type IbcMessageId = {

@@ -29,0 +47,0 @@ chain: Chain;

@@ -1,2 +0,3 @@

import { Chain, Network, Platform, PlatformToChains, tokens } from "@wormhole-foundation/sdk-base";
import { Chain, Network, Platform, tokens } from "@wormhole-foundation/sdk-base";
import { ChainToPlatform } from "@wormhole-foundation/sdk-base/src";
import { ChainAddress, UniversalOrNative } from "./address";

@@ -9,46 +10,178 @@ import { WormholeMessageId } from "./attestation";

import { IbcBridge } from "./protocols/ibc";
import { PorticoBridge } from "./protocols/portico";
import { AutomaticTokenBridge, TokenBridge } from "./protocols/tokenBridge";
import { RpcConnection } from "./rpc";
import { ChainConfig, SignedTx, TokenId, TokenAddress } from "./types";
import { PorticoBridge } from "./protocols/portico";
export declare abstract class ChainContext<N extends Network, P extends Platform = Platform, C extends Chain = PlatformToChains<P>> {
import { ChainConfig, SignedTx, TokenAddress, TokenId } from "./types";
/**
* A ChainContext provides a consistent interface for interacting with a chain.
* It holds the configuration for the chain and cached RPC and protocol clients.
*
*/
export declare abstract class ChainContext<N extends Network, C extends Chain = Chain, P extends Platform = ChainToPlatform<C>> {
readonly network: N;
readonly platform: PlatformContext<N, P>;
readonly chain: C;
readonly config: ChainConfig<N, C>;
readonly platform: PlatformContext<N, P>;
protected rpc?: RpcConnection<P>;
protected coreBridge?: WormholeCore<N, P, C>;
protected tokenBridge?: TokenBridge<N, P, C>;
protected autoTokenBridge?: AutomaticTokenBridge<N, P, C>;
protected circleBridge?: CircleBridge<N, P, C>;
protected autoCircleBridge?: AutomaticCircleBridge<N, P, C>;
protected ibcBridge?: IbcBridge<N, P, C>;
protected porticoBridge?: PorticoBridge<N, P, C>;
protected coreBridge?: WormholeCore<N, C>;
protected tokenBridge?: TokenBridge<N, C>;
protected autoTokenBridge?: AutomaticTokenBridge<N, C>;
protected circleBridge?: CircleBridge<N, C>;
protected autoCircleBridge?: AutomaticCircleBridge<N, C>;
protected ibcBridge?: IbcBridge<N, C>;
protected porticoBridge?: PorticoBridge<N, C>;
constructor(chain: C, platform: PlatformContext<N, P>, rpc?: RpcConnection<P>);
/**
* Get an RPC connection for this chain, uses the configuration passed in
* the initial constructor
*
* @returns the RPC connection for this chain
*/
getRpc(): Promise<RpcConnection<P>>;
/**
* Get the number of decimals for a token
*
* @param token the token to get the decimals for
* @returns the number of decimals for the token
*/
getDecimals(token: TokenAddress<C>): Promise<number>;
/**
* Get the balance of a token for a given address
*
* @param walletAddr the address to get the balance for
* @param token the token to get the balance for
* @returns the balance of the token for the address
*
*/
getBalance(walletAddr: string, token: TokenAddress<C>): Promise<bigint | null>;
/**
* Get the latest block number seen by the chain according to the RPC
*
* @returns the latest block number
*/
getLatestBlock(): Promise<number>;
/**
* Get the latest _finalized_ block number seen by the chain according to the RPC
*
* @returns the latest finalized block number
*/
getLatestFinalizedBlock(): Promise<number>;
/**
* Parse the Wormhole Core messages from a transaction
*
* @param txid the transaction to parse
* @returns the Wormhole Core messages emitted by the transaction
*/
parseTransaction(txid: string): Promise<WormholeMessageId[]>;
sendWait(stxns: SignedTx): Promise<string[]>;
/**
* Send a transaction and wait for it to be confirmed
*
* @param stxns the signed transaction to send
* @returns the transaction hashes of the sent transactions
*/
sendWait(stxns: SignedTx[]): Promise<string[]>;
/**
* Get the token data from the local cache if available
* @param symbol the symbol of the token to get
* @returns the token data if available
*/
getToken(symbol: tokens.TokenSymbol): tokens.Token | undefined;
/**
* Get the token id of the wrapped token for the native gas token
*
* @returns the wrapped token for the native gas token
*/
getNativeWrappedTokenId(): Promise<TokenId<C>>;
/**
* Get the token account for a given address and token
*
* @remarks
* This is really only useful in the context of Solana but in order
* to provide a consistent interface, we provide it here.
*
* @param address the address to get the token account for
* @param token the token to get the token account for
* @returns the token account for the address and token
*/
getTokenAccount(address: UniversalOrNative<C>, token: TokenAddress<C>): Promise<ChainAddress<C>>;
/**
* Check to see if a given protocol is supported by this chain
* by checking if it is registered in the platform and the configuration
* is available and correct
*
* @param protocolName the name of the Protocol to check for support
* @returns a boolean indicating if this protocol is supported
*/
supportsProtocol(protocolName: ProtocolName): boolean;
/**
* Check to see if the Wormhole Core protocol is supported by this chain
* @returns a boolean indicating if this chain supports the Wormhole Core protocol
*/
supportsWormholeCore: () => boolean;
getWormholeCore(): Promise<WormholeCore<N, P, C>>;
/**
* Get the Wormhole Core protocol client for this chain
* @returns the Wormhole Core protocol client for this chain
*/
getWormholeCore(): Promise<WormholeCore<N, C>>;
/**
* Check to see if the Token Bridge protocol is supported by this chain
* @returns a boolean indicating if this chain supports the Token Bridge protocol
*/
supportsTokenBridge: () => boolean;
getTokenBridge(): Promise<TokenBridge<N, P, C>>;
/**
* Get the Token Bridge protocol client for this chain
* @returns the Token Bridge protocol client for this chain
*/
getTokenBridge(): Promise<TokenBridge<N, C>>;
/**
* Check to see if the Automatic Token Bridge protocol is supported by this chain
* @returns a boolean indicating if this chain supports the Automatic Token Bridge protocol
*/
supportsAutomaticTokenBridge: () => boolean;
getAutomaticTokenBridge(): Promise<AutomaticTokenBridge<N, P, C>>;
/**
* Get the Automatic Token Bridge protocol client for this chain
* @returns the Automatic Token Bridge protocol client for this chain
*/
getAutomaticTokenBridge(): Promise<AutomaticTokenBridge<N, C>>;
/**
* Check to see if the Circle Bridge protocol is supported by this chain
* @returns a boolean indicating if this chain supports the Circle Bridge protocol
*/
supportsCircleBridge: () => boolean;
getCircleBridge(): Promise<CircleBridge<N, P, C>>;
/**
* Get the Circle Bridge protocol client for this chain
* @returns the Circle Bridge protocol client for this chain
*/
getCircleBridge(): Promise<CircleBridge<N, C>>;
/**
* Check to see if the Automatic Circle Bridge protocol is supported by this chain
* @returns a boolean indicating if this chain supports the Automatic Circle Bridge protocol
*/
supportsAutomaticCircleBridge: () => boolean;
getAutomaticCircleBridge(): Promise<AutomaticCircleBridge<N, P, C>>;
/**
* Get the Automatic Circle Bridge protocol client for this chain
* @returns the Automatic Circle Bridge protocol client for this chain
*/
getAutomaticCircleBridge(): Promise<AutomaticCircleBridge<N, C>>;
/**
* Check to see if the IBC Bridge protocol is supported by this chain
* @returns a boolean indicating if this chain supports the IBC Bridge protocol
*/
supportsIbcBridge: () => boolean;
getIbcBridge(): Promise<IbcBridge<N, P, C>>;
/**
* Get the IBC Bridge protocol client for this chain
* @returns the IBC Bridge protocol client for this chain
*/
getIbcBridge(): Promise<IbcBridge<N, C>>;
/**
* Check to see if the Portico Bridge protocol is supported by this chain
* @returns a boolean indicating if this chain supports the Portico Bridge protocol
*/
supportsPorticoBridge: () => boolean;
getPorticoBridge(): Promise<PorticoBridge<N, P, C>>;
/**
* Get the Portico Bridge protocol client for this chain
* @returns the Portico Bridge protocol client for this chain
*/
getPorticoBridge(): Promise<PorticoBridge<N, C>>;
}
//# sourceMappingURL=chain.d.ts.map

@@ -7,7 +7,12 @@ "use strict";

const protocol_1 = require("./protocol");
/**
* A ChainContext provides a consistent interface for interacting with a chain.
* It holds the configuration for the chain and cached RPC and protocol clients.
*
*/
class ChainContext {
network;
platform;
chain;
config;
platform;
// Cached Protocol clients

@@ -29,2 +34,8 @@ rpc;

}
/**
* Get an RPC connection for this chain, uses the configuration passed in
* the initial constructor
*
* @returns the RPC connection for this chain
*/
getRpc() {

@@ -34,3 +45,8 @@ this.rpc = this.rpc ? this.rpc : this.platform.getRpc(this.chain);

}
// Get the number of decimals for a token
/**
* Get the number of decimals for a token
*
* @param token the token to get the decimals for
* @returns the number of decimals for the token
*/
async getDecimals(token) {

@@ -45,20 +61,52 @@ // try to find it in the token cache first

}
// Get the balance of a token for a given address
/**
* Get the balance of a token for a given address
*
* @param walletAddr the address to get the balance for
* @param token the token to get the balance for
* @returns the balance of the token for the address
*
*/
async getBalance(walletAddr, token) {
return this.platform.utils().getBalance(this.chain, await this.getRpc(), walletAddr, token);
}
/**
* Get the latest block number seen by the chain according to the RPC
*
* @returns the latest block number
*/
async getLatestBlock() {
return this.platform.utils().getLatestBlock(await this.getRpc());
}
/**
* Get the latest _finalized_ block number seen by the chain according to the RPC
*
* @returns the latest finalized block number
*/
async getLatestFinalizedBlock() {
return this.platform.utils().getLatestFinalizedBlock(await this.getRpc());
}
// Get details about the transaction
/**
* Parse the Wormhole Core messages from a transaction
*
* @param txid the transaction to parse
* @returns the Wormhole Core messages emitted by the transaction
*/
async parseTransaction(txid) {
return this.platform.parseWormholeMessages(this.chain, await this.getRpc(), txid);
}
// Send a transaction and wait for it to be confirmed
/**
* Send a transaction and wait for it to be confirmed
*
* @param stxns the signed transaction to send
* @returns the transaction hashes of the sent transactions
*/
async sendWait(stxns) {
return this.platform.utils().sendWait(this.chain, await this.getRpc(), stxns);
}
/**
* Get the token data from the local cache if available
* @param symbol the symbol of the token to get
* @returns the token data if available
*/
getToken(symbol) {

@@ -71,2 +119,7 @@ if (!this.config.tokenMap)

}
/**
* Get the token id of the wrapped token for the native gas token
*
* @returns the wrapped token for the native gas token
*/
async getNativeWrappedTokenId() {

@@ -82,3 +135,13 @@ // see if we have it configured

}
// Get the token account for a given address
/**
* Get the token account for a given address and token
*
* @remarks
* This is really only useful in the context of Solana but in order
* to provide a consistent interface, we provide it here.
*
* @param address the address to get the token account for
* @param token the token to get the token account for
* @returns the token account for the address and token
*/
async getTokenAccount(address, token) {

@@ -88,10 +151,22 @@ // Noop by default, override in implementation if necessary

}
//
// protocols
//
//
/**
* Check to see if a given protocol is supported by this chain
* by checking if it is registered in the platform and the configuration
* is available and correct
*
* @param protocolName the name of the Protocol to check for support
* @returns a boolean indicating if this protocol is supported
*/
supportsProtocol(protocolName) {
return (0, protocol_1.protocolIsRegistered)(this.chain, protocolName);
}
/**
* Check to see if the Wormhole Core protocol is supported by this chain
* @returns a boolean indicating if this chain supports the Wormhole Core protocol
*/
supportsWormholeCore = () => this.supportsProtocol("WormholeCore");
/**
* Get the Wormhole Core protocol client for this chain
* @returns the Wormhole Core protocol client for this chain
*/
async getWormholeCore() {

@@ -103,3 +178,11 @@ this.coreBridge = this.coreBridge

}
/**
* Check to see if the Token Bridge protocol is supported by this chain
* @returns a boolean indicating if this chain supports the Token Bridge protocol
*/
supportsTokenBridge = () => this.supportsProtocol("TokenBridge");
/**
* Get the Token Bridge protocol client for this chain
* @returns the Token Bridge protocol client for this chain
*/
async getTokenBridge() {

@@ -111,4 +194,11 @@ this.tokenBridge = this.tokenBridge

}
//
/**
* Check to see if the Automatic Token Bridge protocol is supported by this chain
* @returns a boolean indicating if this chain supports the Automatic Token Bridge protocol
*/
supportsAutomaticTokenBridge = () => this.supportsProtocol("AutomaticTokenBridge");
/**
* Get the Automatic Token Bridge protocol client for this chain
* @returns the Automatic Token Bridge protocol client for this chain
*/
async getAutomaticTokenBridge() {

@@ -120,4 +210,11 @@ this.autoTokenBridge = this.autoTokenBridge

}
//
/**
* Check to see if the Circle Bridge protocol is supported by this chain
* @returns a boolean indicating if this chain supports the Circle Bridge protocol
*/
supportsCircleBridge = () => this.supportsProtocol("CircleBridge");
/**
* Get the Circle Bridge protocol client for this chain
* @returns the Circle Bridge protocol client for this chain
*/
async getCircleBridge() {

@@ -129,4 +226,11 @@ this.circleBridge = this.circleBridge

}
//
/**
* Check to see if the Automatic Circle Bridge protocol is supported by this chain
* @returns a boolean indicating if this chain supports the Automatic Circle Bridge protocol
*/
supportsAutomaticCircleBridge = () => this.supportsProtocol("AutomaticCircleBridge");
/**
* Get the Automatic Circle Bridge protocol client for this chain
* @returns the Automatic Circle Bridge protocol client for this chain
*/
async getAutomaticCircleBridge() {

@@ -138,4 +242,11 @@ this.autoCircleBridge = this.autoCircleBridge

}
//
/**
* Check to see if the IBC Bridge protocol is supported by this chain
* @returns a boolean indicating if this chain supports the IBC Bridge protocol
*/
supportsIbcBridge = () => this.supportsProtocol("IbcBridge");
/**
* Get the IBC Bridge protocol client for this chain
* @returns the IBC Bridge protocol client for this chain
*/
async getIbcBridge() {

@@ -147,4 +258,11 @@ this.ibcBridge = this.ibcBridge

}
//
/**
* Check to see if the Portico Bridge protocol is supported by this chain
* @returns a boolean indicating if this chain supports the Portico Bridge protocol
*/
supportsPorticoBridge = () => this.supportsProtocol("PorticoBridge");
/**
* Get the Portico Bridge protocol client for this chain
* @returns the Portico Bridge protocol client for this chain
*/
async getPorticoBridge() {

@@ -151,0 +269,0 @@ this.porticoBridge = this.porticoBridge

import { Chain, Network, contracts } from "@wormhole-foundation/sdk-base";
/** The Contract addresses set in configuration for a given chain */
export type Contracts = {

@@ -13,3 +14,11 @@ coreBridge?: string;

};
/**
*
* Get the contracts for a given network and chain
*
* @param n the network to get contracts for
* @param c the chain to get contracts for
* @returns the contracts for the given network and chain
*/
export declare function getContracts(n: Network, c: Chain): Contracts;
//# sourceMappingURL=contracts.d.ts.map

@@ -5,2 +5,10 @@ "use strict";

const sdk_base_1 = require("@wormhole-foundation/sdk-base");
/**
*
* Get the contracts for a given network and chain
*
* @param n the network to get contracts for
* @param c the chain to get contracts for
* @returns the contracts for the given network and chain
*/
function getContracts(n, c) {

@@ -7,0 +15,0 @@ const ct = {

2

dist/cjs/index.d.ts

@@ -12,3 +12,2 @@ import "./payloads/automaticCircleBridge";

export * from "./utils";
export * from "./relayer";
export * from "./platform";

@@ -27,4 +26,5 @@ export * from "./chain";

export * from "./protocols/portico";
export * from "./protocols/relayer";
export * as layoutItems from "./layout-items";
export * as testing from "./testing";
//# sourceMappingURL=index.d.ts.map

@@ -42,3 +42,2 @@ "use strict";

__exportStar(require("./utils"), exports);
__exportStar(require("./relayer"), exports);
__exportStar(require("./platform"), exports);

@@ -57,4 +56,5 @@ __exportStar(require("./chain"), exports);

__exportStar(require("./protocols/portico"), exports);
__exportStar(require("./protocols/relayer"), exports);
exports.layoutItems = __importStar(require("./layout-items"));
exports.testing = __importStar(require("./testing"));
//# sourceMappingURL=index.js.map

@@ -16,3 +16,3 @@ type AllowNull<T, B extends boolean> = B extends true ? T | null : T;

to: C;
from: (C extends bigint ? `bigint(${C})` : C extends boolean ? `boolean(${C})` : C) extends "Solana" | "Btc" | "Algorand" | "Sui" | "Aptos" | "Near" | "Ethereum" | "Terra" | "Bsc" | "Polygon" | "Avalanche" | "Oasis" | "Aurora" | "Fantom" | "Karura" | "Acala" | "Klaytn" | "Celo" | "Moonbeam" | "Neon" | "Terra2" | "Injective" | "Osmosis" | "Arbitrum" | "Optimism" | "Gnosis" | "Pythnet" | "Xpla" | "Base" | "Sei" | "Rootstock" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" ? {
from: {
Solana: 1;

@@ -58,89 +58,3 @@ Ethereum: 2;

Holesky: 10006;
}[("Solana" | "Btc" | "Algorand" | "Sui" | "Aptos" | "Near" | "Ethereum" | "Terra" | "Bsc" | "Polygon" | "Avalanche" | "Oasis" | "Aurora" | "Fantom" | "Karura" | "Acala" | "Klaytn" | "Celo" | "Moonbeam" | "Neon" | "Terra2" | "Injective" | "Osmosis" | "Arbitrum" | "Optimism" | "Gnosis" | "Pythnet" | "Xpla" | "Base" | "Sei" | "Rootstock" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky") & (C extends bigint ? `bigint(${C})` : C extends boolean ? `boolean(${C})` : C)] extends {
[key: string]: unknown;
[key: number]: unknown;
[key: symbol]: unknown;
} ? {
Solana: 1;
Ethereum: 2;
Terra: 3;
Bsc: 4;
Polygon: 5;
Avalanche: 6;
Oasis: 7;
Algorand: 8;
Aurora: 9;
Fantom: 10;
Karura: 11;
Acala: 12;
Klaytn: 13;
Celo: 14;
Near: 15;
Moonbeam: 16;
Neon: 17;
Terra2: 18;
Injective: 19;
Osmosis: 20;
Sui: 21;
Aptos: 22;
Arbitrum: 23;
Optimism: 24;
Gnosis: 25;
Pythnet: 26;
Xpla: 28;
Btc: 29;
Base: 30;
Sei: 32;
Rootstock: 33;
Wormchain: 3104;
Cosmoshub: 4000;
Evmos: 4001;
Kujira: 4002;
Sepolia: 10002;
ArbitrumSepolia: 10003;
BaseSepolia: 10004;
OptimismSepolia: 10005;
Holesky: 10006;
}[("Solana" | "Btc" | "Algorand" | "Sui" | "Aptos" | "Near" | "Ethereum" | "Terra" | "Bsc" | "Polygon" | "Avalanche" | "Oasis" | "Aurora" | "Fantom" | "Karura" | "Acala" | "Klaytn" | "Celo" | "Moonbeam" | "Neon" | "Terra2" | "Injective" | "Osmosis" | "Arbitrum" | "Optimism" | "Gnosis" | "Pythnet" | "Xpla" | "Base" | "Sei" | "Rootstock" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky") & (C extends bigint ? `bigint(${C})` : C extends boolean ? `boolean(${C})` : C)] : {
Solana: 1;
Ethereum: 2;
Terra: 3;
Bsc: 4;
Polygon: 5;
Avalanche: 6;
Oasis: 7;
Algorand: 8;
Aurora: 9;
Fantom: 10;
Karura: 11;
Acala: 12;
Klaytn: 13;
Celo: 14;
Near: 15;
Moonbeam: 16;
Neon: 17;
Terra2: 18;
Injective: 19;
Osmosis: 20;
Sui: 21;
Aptos: 22;
Arbitrum: 23;
Optimism: 24;
Gnosis: 25;
Pythnet: 26;
Xpla: 28;
Btc: 29;
Base: 30;
Sei: 32;
Rootstock: 33;
Wormchain: 3104;
Cosmoshub: 4000;
Evmos: 4001;
Kujira: 4002;
Sepolia: 10002;
ArbitrumSepolia: 10003;
BaseSepolia: 10004;
OptimismSepolia: 10005;
Holesky: 10006;
}[("Solana" | "Btc" | "Algorand" | "Sui" | "Aptos" | "Near" | "Ethereum" | "Terra" | "Bsc" | "Polygon" | "Avalanche" | "Oasis" | "Aurora" | "Fantom" | "Karura" | "Acala" | "Klaytn" | "Celo" | "Moonbeam" | "Neon" | "Terra2" | "Injective" | "Osmosis" | "Arbitrum" | "Optimism" | "Gnosis" | "Pythnet" | "Xpla" | "Base" | "Sei" | "Rootstock" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky") & (C extends bigint ? `bigint(${C})` : C extends boolean ? `boolean(${C})` : C)] : never;
}[C extends bigint ? `bigint(${C})` : C extends boolean ? `boolean(${C})` : C];
};

@@ -147,0 +61,0 @@ readonly binary: "uint";

@@ -7,14 +7,38 @@ import { Chain, Network, Platform, PlatformToChains } from "@wormhole-foundation/sdk-base";

import { Balances, ChainsConfig, SignedTx, TokenId, TxHash, TokenAddress } from "./types";
/**
* PlatformUtils represents the _static_ attributes available on
* the PlatformContext Class
*/
export interface PlatformUtils<P extends Platform> {
/** Value for the Platform so we can access it at runtime */
_platform: P;
/** Initialize a new PlatformContext object */
new <N extends Network>(network: N, config?: ChainsConfig<N, P>): PlatformContext<N, P>;
/**
* Check if this chain is supported by this platform
*/
isSupportedChain(chain: Chain): boolean;
/** Look up a Chain from its native chain ID
* See implementation for details
* Note: this is _not_ the same as the Wormhole chain id
*/
chainFromChainId(chainId: string | bigint): [Network, Chain];
/**
* Given an RPC connection, request the native chain id
* then resolve it to a Wormhole Canonical network and chain name
*/
chainFromRpc(rpc: RpcConnection<P>): Promise<[Network, Chain]>;
/** Get the native (gas) token id for a given chain */
nativeTokenId<N extends Network, C extends PlatformToChains<P>>(network: N, chain: C): TokenId<C>;
/** Check if the token passed is the native token id for the argued chain and network */
isNativeTokenId<N extends Network, C extends PlatformToChains<P>>(network: N, chain: C, tokenId: TokenId): boolean;
/** Get the number of decimals for a given token */
getDecimals<C extends PlatformToChains<P>>(chain: C, rpc: RpcConnection<P>, token: TokenAddress<C>): Promise<number>;
/** Get the balance of a token for a given wallet address */
getBalance<C extends PlatformToChains<P>>(chain: C, rpc: RpcConnection<P>, walletAddr: string, token: TokenAddress<C>): Promise<bigint | null>;
/** Look up the balances for a list of tokens for a given wallet address */
getBalances<C extends PlatformToChains<P>>(chain: C, rpc: RpcConnection<P>, walletAddress: string, tokens: TokenAddress<C>[]): Promise<Balances>;
/** Look up the latest block according to the RPC passed */
getLatestBlock(rpc: RpcConnection<P>): Promise<number>;
/** Look up the latest _finalized_ block according to the RPC passed */
getLatestFinalizedBlock(rpc: RpcConnection<P>): Promise<number>;

@@ -24,2 +48,5 @@ sendWait<C extends PlatformToChains<P>>(chain: C, rpc: RpcConnection<P>, stxns: SignedTx[]): Promise<TxHash[]>;

export type StaticPlatformMethods<P extends Platform, I extends PlatformUtils<P>> = InstanceType<I>;
/**
* PlatformContext is an instance of the class that represents a specific Platform
*/
export declare abstract class PlatformContext<N extends Network, P extends Platform> {

@@ -29,8 +56,13 @@ readonly network: N;

constructor(network: N, config: ChainsConfig<N, P>);
/** provides access to the static attributes of the PlatformContext class */
utils(): PlatformUtils<P>;
/** Create a new RPC Connection */
abstract getRpc<C extends PlatformToChains<P>>(chain: C): RpcConnection<P> | Promise<RpcConnection<P>>;
abstract getChain<C extends PlatformToChains<P>>(chain: C, rpc?: RpcConnection<P>): ChainContext<N, P, C>;
/** Create a new Chain context object */
abstract getChain<C extends PlatformToChains<P>>(chain: C, rpc?: RpcConnection<P>): ChainContext<N, C>;
/** Create a new Protocol Client instance by protocol name */
getProtocol<PN extends ProtocolName, T>(protocol: PN, rpc: RpcConnection<P>): Promise<T>;
/** Look up transaction logs and parse out Wormhole messages */
parseWormholeMessages<C extends PlatformToChains<P>>(chain: C, rpc: RpcConnection<P>, txid: TxHash): Promise<WormholeMessageId[]>;
}
//# sourceMappingURL=platform.d.ts.map

@@ -5,3 +5,5 @@ "use strict";

const protocol_1 = require("./protocol");
// PlatformContext is an instance of the class that represents a specific Platform
/**
* PlatformContext is an instance of the class that represents a specific Platform
*/
class PlatformContext {

@@ -14,11 +16,11 @@ network;

}
// provides access to the static attributes of the PlatformContext class
/** provides access to the static attributes of the PlatformContext class */
utils() {
return this.constructor;
}
// Create a new Protocol Client instance by protocol name
/** Create a new Protocol Client instance by protocol name */
getProtocol(protocol, rpc) {
return (0, protocol_1.create)(this.utils()._platform, protocol, rpc, this.config);
}
// Look up transaction logs and parse out Wormhole messages
/** Look up transaction logs and parse out Wormhole messages */
async parseWormholeMessages(chain, rpc, txid) {

@@ -25,0 +27,0 @@ const wc = await this.getProtocol("WormholeCore", rpc);

@@ -10,2 +10,3 @@ import { Chain, Network, Platform } from "@wormhole-foundation/sdk-base";

}
/** A string type representing the name of a protocol */
export type ProtocolName = keyof WormholeNamespace.ProtocolToPlatformMapping;

@@ -12,0 +13,0 @@ type MappedProtocolPlatforms = keyof WormholeNamespace.ProtocolToPlatformMapping[ProtocolName];

@@ -1,2 +0,2 @@

import { Chain, LayoutToType, Network, Platform, PlatformToChains } from "@wormhole-foundation/sdk-base";
import { Chain, LayoutToType, Network, Platform } from "@wormhole-foundation/sdk-base";
import { AccountAddress, ChainAddress } from "../address";

@@ -8,4 +8,4 @@ import { CircleMessageId } from "../attestation";

import { circleMessageLayout } from "../payloads/circleBridge";
import { EmptyPlatformMap } from "../protocol";
import { ProtocolPayload, ProtocolVAA } from "../vaa";
import { EmptyPlatformMap } from "../protocol";
declare global {

@@ -21,2 +21,3 @@ namespace WormholeNamespace {

const _protocol = "CircleBridge";
/** The compile time type for the CircleBridge protocol */
export type ProtocolName = typeof _protocol;

@@ -26,2 +27,3 @@ const _payloads: readonly ["Message"];

export type Message = LayoutToType<typeof circleMessageLayout>;
/** Circle message and attestation if available */
export type Attestation = {

@@ -41,2 +43,3 @@ message: Message;

export type PayloadNames = (typeof _payloads)[number];
/** The VAA types that are emitted from the AutomaticCirlceBridge protocol */
export type VAA<PayloadName extends PayloadNames = PayloadNames> = ProtocolVAA<ProtocolName, PayloadName>;

@@ -64,12 +67,64 @@ export type Payload<PayloadName extends PayloadNames = PayloadNames> = ProtocolPayload<ProtocolName, PayloadName>;

export declare function isCircleTransferDetails(thing: any): thing is CircleTransferDetails;
export interface CircleBridge<N extends Network, P extends Platform, C extends PlatformToChains<P>> {
/**
* CircleBridge protocol definition, providing a consistent client
* interface to the CircleBridge protocol (CCTP).
*
* Find the source contracts here: ${@link https://github.com/circlefin/evm-cctp-contracts}
*
*/
export interface CircleBridge<N extends Network, C extends Chain> {
/**
* Redeem a circle transfer against the Circle Bridge
*
* @param sender The address of the sender
* @param message The Circle message to redeem
* @param attestation The attestation, from the Circle attestation service
*
* @returns a stream of unsigned transactions to be signed and submitted on chain
*/
redeem(sender: AccountAddress<C>, message: CircleBridge.Message, attestation: string): AsyncGenerator<UnsignedTransaction<N, C>>;
/**
* Initiate a transfer through the Circle CCTP Bridge
*
* @param sender the sender of the transaction
* @param recipient the chain and address of the recipient of the transfer
* @param amount how much to send in base units
*/
transfer(sender: AccountAddress<C>, recipient: ChainAddress, amount: bigint): AsyncGenerator<UnsignedTransaction<N, C>>;
/**
* Check if a transfer has been completed according to the bridge contract
*
* @param message The message to check
*/
isTransferCompleted(message: CircleBridge.Message): Promise<boolean>;
/**
* Grabs the logs from the transaction and parse the circle message
*
* @param txid The transaction hash from which to parse a message
*
* @returns The parsed CircleTransferMessage
*/
parseTransactionDetails(txid: string): Promise<CircleTransferMessage>;
}
export interface AutomaticCircleBridge<N extends Network, P extends Platform, C extends Chain = PlatformToChains<P>> {
/**
* AutomaticCircleBridge protocol definition, providing a consistent client
* interface for the CircleBridge protocol with Automatic delivery.
*/
export interface AutomaticCircleBridge<N extends Network, C extends Chain> {
/**
* Get the fee required by the relayer to cover the costs of redemption on the destination chain
*
* @param destination The destination chain for which to get a fee quote
* @returns the fee required by the relayer to cover the costs of redemption on the destination chain
*/
getRelayerFee(destination: Chain): Promise<bigint>;
/**
*
* @param sender address of the transaction sender
* @param recipient address of the destination chain recipient
* @param amount how much to send, in base units
* @param nativeGas if set, determines how much native gas should be received by the recipient
*/
transfer(sender: AccountAddress<C>, recipient: ChainAddress, amount: bigint, nativeGas?: bigint): AsyncGenerator<UnsignedTransaction<N, C>>;
}
//# sourceMappingURL=circleBridge.d.ts.map

@@ -1,8 +0,8 @@

import { PlatformToChains, Network, Platform } from "@wormhole-foundation/sdk-base";
import { Chain, Network, Platform } from "@wormhole-foundation/sdk-base";
import { AccountAddress } from "../address";
import { WormholeMessageId } from "../attestation";
import { EmptyPlatformMap } from "../protocol";
import { TxHash } from "../types";
import { UnsignedTransaction } from "../unsignedTransaction";
import { VAA } from "../vaa";
import { EmptyPlatformMap } from "../protocol";
declare global {

@@ -15,8 +15,39 @@ namespace WormholeNamespace {

}
export interface WormholeCore<N extends Network, P extends Platform, C extends PlatformToChains<P>> {
/**
* WormholeCore provides a consistent interface to interact
* with the Wormhole core messaging protocol.
*
*/
export interface WormholeCore<N extends Network, C extends Chain> {
/** Get the fee for publishing a message */
getMessageFee(): Promise<bigint>;
/**
* Publish a message
*
* @param sender The address of the sender
* @param message The message to send
* @param nonce A number that may be set if needed for the application, may be 0 if unneeded
* @param consistencyLevel The consistency level to reach before the guardians should sign the message
* see {@link https://docs.wormhole.com/wormhole/reference/glossary#consistency-level | the docs} for more information
*
* @returns a stream of unsigned transactions to be signed and submitted on chain
*/
publishMessage(sender: AccountAddress<C>, message: string | Uint8Array, nonce: number, consistencyLevel: number): AsyncGenerator<UnsignedTransaction<N, C>>;
/**
* Verify a VAA against the core contract
* @param sender the sender of the transaction
* @param vaa the VAA to verify
*
* @returns a stream of unsigned transactions to be signed and submitted on chain
*/
verifyMessage(sender: AccountAddress<C>, vaa: VAA): AsyncGenerator<UnsignedTransaction<N, C>>;
/**
* Parse a transaction to get its message id
*
* @param txid the transaction hash to parse
*
* @returns the message ids produced by the transaction
*/
parseTransaction(txid: TxHash): Promise<WormholeMessageId[]>;
}
//# sourceMappingURL=core.d.ts.map

@@ -1,7 +0,7 @@

import { Chain, ChainId, Network, Platform, PlatformToChains } from "@wormhole-foundation/sdk-base";
import { Chain, ChainId, Network, Platform } from "@wormhole-foundation/sdk-base";
import { AccountAddress, ChainAddress, NativeAddress } from "../address";
import { IbcMessageId, WormholeMessageId } from "../attestation";
import { TokenId, TxHash, TokenAddress } from "../types";
import { EmptyPlatformMap } from "../protocol";
import { TokenAddress, TokenId, TxHash } from "../types";
import { UnsignedTransaction } from "../unsignedTransaction";
import { EmptyPlatformMap } from "../protocol";
declare global {

@@ -14,2 +14,3 @@ namespace WormholeNamespace {

}
/** Configuration for a transfer through the Gateway */
export type GatewayTransferDetails = {

@@ -25,2 +26,6 @@ token: TokenId<Chain>;

};
/**
* Holds the data of a gateway message without
* special keys required by cosmos contracts
*/
export interface GatewayMsg {

@@ -55,2 +60,5 @@ chain: ChainId;

export declare function isIbcTransferInfo(thing: IbcTransferInfo | any): thing is IbcTransferInfo;
/**
* The expected payload sent as a string over IBC
*/
export interface IbcTransferData {

@@ -63,11 +71,27 @@ amount: string;

}
export interface IbcBridge<N extends Network, P extends Platform, C extends PlatformToChains<P>> {
/**
* IbcBridge provides an interface to use the IBC token transfer protocol
*
* See more here {@link https://tutorials.cosmos.network/academy/3-ibc/7-token-transfer.html}
*
*/
export interface IbcBridge<N extends Network, C extends Chain> {
/** Initiate an IBC token transfer */
transfer(sender: AccountAddress<C>, recipient: ChainAddress, token: TokenAddress<C>, amount: bigint, payload?: Uint8Array): AsyncGenerator<UnsignedTransaction<N, C>>;
/** Get the transfer channel for a remote chain, pulled from local cache */
getTransferChannel(chain: Chain): string | null;
/** Get the transfer channel for a remote chain, pulled from contract */
fetchTransferChannel(chain: Chain): Promise<string | null>;
/**
* Find the wormhole emitted message id for a given IBC transfer
* if it does not exist, this will return null
*/
lookupMessageFromIbcMsgId(msg: IbcMessageId): Promise<WormholeMessageId | null>;
/** Find the IBCTransferInfo given a transaction id */
lookupTransferFromTx(txid: TxHash): Promise<IbcTransferInfo>;
/** Find the IBCTransferInfo from a message id */
lookupTransferFromIbcMsgId(msg: IbcMessageId): Promise<IbcTransferInfo>;
/** Find the IBCTransferInfo from a gateway transfer message */
lookupTransferFromMsg(payload: GatewayTransferMsg | GatewayTransferWithPayloadMsg): Promise<IbcTransferInfo>;
}
//# sourceMappingURL=ibc.d.ts.map

@@ -1,2 +0,2 @@

import { LayoutToType, Network, Platform, PlatformToChains } from "@wormhole-foundation/sdk-base";
import { Chain, LayoutToType, Network, Platform } from "@wormhole-foundation/sdk-base";
import { AccountAddress, ChainAddress } from "../address";

@@ -6,3 +6,3 @@ import "../payloads/portico";

import { EmptyPlatformMap } from "../protocol";
import { TokenId, TokenAddress } from "../types";
import { TokenAddress, TokenId } from "../types";
import { UnsignedTransaction } from "../unsignedTransaction";

@@ -19,2 +19,3 @@ import { ProtocolVAA } from "../vaa";

const _protocol = "PorticoBridge";
/** The compile time protocol name type for Portico Bridge */
export type ProtocolName = typeof _protocol;

@@ -34,2 +35,3 @@ export interface SwapAmounts {

export type PayloadNames = (typeof _payloads)[number];
/** The VAA types emitted by the PorticoBridge protocol */
export type VAA<PayloadName extends PayloadNames = PayloadNames> = ProtocolVAA<ProtocolName, PayloadName>;

@@ -44,6 +46,14 @@ export type Payload = LayoutToType<typeof porticoPayloadLayout>;

}
export interface PorticoBridge<N extends Network, P extends Platform, C extends PlatformToChains<P>> {
/**
* PorticoBridge provides a consistent interface to interact with
* the Portico bridge contracts.
*/
export interface PorticoBridge<N extends Network, C extends Chain> {
/** Initiate a transfer of some token to another chain */
transfer(sender: AccountAddress<C>, recipient: ChainAddress, token: TokenAddress<C>, amount: bigint, destToken: TokenId, quote: PorticoBridge.Quote): AsyncGenerator<UnsignedTransaction<N, C>>;
/** Redeem a transfer VAA to receive the tokens on this chain */
redeem(sender: AccountAddress<C>, vaa: PorticoBridge.VAA): AsyncGenerator<UnsignedTransaction<N, C>>;
/** quote token conversion */
quoteSwap(input: TokenAddress<C>, output: TokenAddress<C>, amount: bigint): Promise<bigint>;
/** quote relay on destination with conversion */
quoteRelay(token: TokenAddress<C>, destination: TokenAddress<C>): Promise<bigint>;

@@ -50,0 +60,0 @@ getTransferrableToken(address: string): TokenId;

@@ -0,1 +1,3 @@

import { Chain } from "@wormhole-foundation/sdk-base";
import { TokenAddress } from "../types";
import { Platform } from "@wormhole-foundation/sdk-base";

@@ -10,2 +12,9 @@ import { EmptyPlatformMap } from "../protocol";

}
export interface Relayer {
relaySupported(chain: Chain): boolean;
getRelayerFee(sourceChain: Chain, destChain: Chain, tokenId: TokenAddress<Chain>): Promise<bigint>;
startTransferWithRelay(token: TokenAddress<Chain>, amount: bigint, toNativeToken: string, sendingChain: Chain, senderAddress: string, recipientChain: Chain, recipientAddress: string, overrides?: any): Promise<any>;
calculateNativeTokenAmt(destChain: Chain, tokenId: TokenAddress<Chain>, amount: bigint, walletAddress: string): Promise<bigint>;
calculateMaxSwapAmount(destChain: Chain, tokenId: TokenAddress<Chain>, walletAddress: string): Promise<bigint>;
}
//# sourceMappingURL=relayer.d.ts.map

@@ -1,9 +0,9 @@

import { Chain, Network, Platform, PlatformToChains } from "@wormhole-foundation/sdk-base";
import { Chain, Network, Platform } from "@wormhole-foundation/sdk-base";
import { AccountAddress, ChainAddress, NativeAddress, UniversalOrNative } from "../address";
import "../payloads/automaticTokenBridge";
import "../payloads/tokenBridge";
import { EmptyPlatformMap } from "../protocol";
import { TokenAddress, TokenId } from "../types";
import { UnsignedTransaction } from "../unsignedTransaction";
import { ProtocolPayload, ProtocolVAA } from "../vaa";
import { EmptyPlatformMap } from "../protocol";
export declare const ErrNotWrapped: (token: string) => Error;

@@ -18,4 +18,8 @@ declare global {

}
/**
* @namespace TokenBridge
*/
export declare namespace TokenBridge {
const _protocol = "TokenBridge";
/** The compile time type of the TokenBridge protocol */
export type ProtocolName = typeof _protocol;

@@ -30,2 +34,3 @@ const _transferPayloads: readonly ["Transfer", "TransferWithPayload"];

export type AttestVAA<PayloadName extends AttestPayloadNames = AttestPayloadNames> = ProtocolVAA<ProtocolName, PayloadName>;
/** The VAAs emitted from the TokenBridge protocol */
export type VAA<PayloadName extends PayloadNames = PayloadNames> = ProtocolVAA<ProtocolName, PayloadName>;

@@ -40,5 +45,7 @@ export type TransferPayload<PayloadName extends TransferPayloadNames = TransferPayloadNames> = ProtocolPayload<ProtocolName, PayloadName>;

const _protocol = "AutomaticTokenBridge";
/** The compile time type of the AutomaticTokenBridge protocol */
export type ProtocolName = typeof _protocol;
const _payloads: readonly ["TransferWithRelay"];
export type PayloadNames = (typeof _payloads)[number];
/** The VAAs emitted from the AutomaticTokenBridge protocol */
export type VAA<PayloadName extends PayloadNames = PayloadNames> = ProtocolVAA<ProtocolName, PayloadName>;

@@ -48,2 +55,5 @@ export type Payload<PayloadName extends PayloadNames = PayloadNames> = ProtocolPayload<ProtocolName, PayloadName>;

}
/**
* Details of a token transfer, used to initiate a transfer
*/
export type TokenTransferDetails = {

@@ -59,23 +69,113 @@ token: TokenId;

export declare function isTokenTransferDetails(thing: TokenTransferDetails | any): thing is TokenTransferDetails;
export interface TokenBridge<N extends Network, P extends Platform, C extends PlatformToChains<P>> {
/**
* TokenBridge protocol definition, providing a consistent client interface
* for the TokenBridge protocol
*
* Find details on the TokenBridge protocol here: {@link https://github.com/wormhole-foundation/wormhole/blob/main/whitepapers/0003_token_bridge.md}
*
*/
export interface TokenBridge<N extends Network, C extends Chain> {
/** Checks a native address to see if its a wrapped version
*
* @param nativeAddress The address to check
* @returns true if the address is a wrapped version of a foreign token
*/
isWrappedAsset(nativeAddress: TokenAddress<C>): Promise<boolean>;
/**
* returns the original asset with its foreign chain
*
* @param nativeAddress The wrapped address to check
* @returns The TokenId corresponding to the original asset and chain
*/
getOriginalAsset(nativeAddress: TokenAddress<C>): Promise<TokenId<Chain>>;
/**
* returns the wrapped version of the native asset
*
* @returns The address of the native gas token that has been wrapped
* for use where the gas token is not possible to use (e.g. bridging)
*/
getWrappedNative(): Promise<NativeAddress<C>>;
/**
* Check to see if a foreign token has a wrapped version
*
* @param foreignToken The token to check
* @returns true if the token has a wrapped version
*/
hasWrappedAsset(foreignToken: TokenId<Chain>): Promise<boolean>;
/**
* Returns the address of the native version of this asset
*
* @param foreignToken The token to check
* @returns The address of the native version of this asset
*/
getWrappedAsset(foreignToken: TokenId<Chain>): Promise<NativeAddress<C>>;
/**
* Checks if a transfer VAA has been redeemed
*
* @param vaa The transfer VAA to check
* @returns true if the transfer has been redeemed
*/
isTransferCompleted(vaa: TokenBridge.TransferVAA): Promise<boolean>;
/**
* Create a Token Attestation VAA containing metadata about
* the token that may be submitted to a Token bridge on another chain
* to allow it to create a wrapped version of the token
*
* @param token The token to create an attestation for
* @param payer The payer of the transaction
* @returns An AsyncGenerator that produces transactions to sign and send
*/
createAttestation(token: TokenAddress<C>, payer?: UniversalOrNative<C>): AsyncGenerator<UnsignedTransaction<N, C>>;
/**
* Submit the Token Attestation VAA to the Token bridge
* to create the wrapped token represented by the data in the VAA
* @param vaa The attestation VAA to submit
* @param payer The payer of the transaction
* @returns An AsyncGenerator that produces transactions to sign and send
*/
submitAttestation(vaa: TokenBridge.AttestVAA, payer?: UniversalOrNative<C>): AsyncGenerator<UnsignedTransaction<N, C>>;
/**
* Initiate a transfer of some token to another chain
*
* @param sender The sender of the transfer
* @param recipient The recipient of the transfer as a ChainAddress so we know what the destination chain should be
* @param token The token to transfer
* @param amount The amount of the token to transfer
* @param payload Optional payload to include in the transfer
* @returns An AsyncGenerator that produces transactions to sign and send
*/
transfer(sender: AccountAddress<C>, recipient: ChainAddress, token: TokenAddress<C>, amount: bigint, payload?: Uint8Array): AsyncGenerator<UnsignedTransaction<N, C>>;
/**
* Redeem a transfer VAA to receive the tokens on this chain
*
* @param sender The sender of the transfer
* @param vaa The transfer VAA to redeem
* @param unwrapNative Whether to unwrap the native token if it is a wrapped token
* @returns An AsyncGenerator that produces transactions to sign and send
*/
redeem(sender: AccountAddress<C>, vaa: TokenBridge.TransferVAA, unwrapNative?: boolean): AsyncGenerator<UnsignedTransaction<N, C>>;
}
export interface AutomaticTokenBridge<N extends Network, P extends Platform, C extends PlatformToChains<P>> {
/**
* AutomaticTokenBridge provides a consistent interface to the
* TokenBridge with Automatic redemption on the destination chain
*/
export interface AutomaticTokenBridge<N extends Network, C extends Chain> {
/** Initiate the transfer over the automatic bridge */
transfer(sender: AccountAddress<C>, recipient: ChainAddress, token: TokenAddress<C>, amount: bigint, nativeGas?: bigint): AsyncGenerator<UnsignedTransaction<N, C>>;
/**
* Manually redeem a transfer, should not be used unless
* necessary to take over some stalled transfer
*/
redeem(sender: AccountAddress<C>, vaa: AutomaticTokenBridge.VAA): AsyncGenerator<UnsignedTransaction<N, C>>;
/** Fee charged to relay */
getRelayerFee(sender: AccountAddress<C>, recipient: ChainAddress, token: TokenAddress<C>): Promise<bigint>;
/** Check if a given token is in the registered token list */
isRegisteredToken(token: TokenAddress<C>): Promise<boolean>;
/** Get the list of tokens that are registered and acceptable to send */
getRegisteredTokens(): Promise<NativeAddress<C>[]>;
/** Amount of native tokens a user would receive by swapping x amount of sending tokens */
nativeTokenAmount(token: TokenAddress<C>, amount: bigint): Promise<bigint>;
/** Maximum amount of sending tokens that can be swapped for native tokens */
maxSwapAmount(token: TokenAddress<C>): Promise<bigint>;
}
//# sourceMappingURL=tokenBridge.d.ts.map

@@ -10,2 +10,5 @@ "use strict";

exports.ErrNotWrapped = ErrNotWrapped;
/**
* @namespace TokenBridge
*/
var TokenBridge;

@@ -12,0 +15,0 @@ (function (TokenBridge) {

@@ -0,1 +1,2 @@

/** Signature represents the secp256k1 signature of a Guardian */
export declare class Signature {

@@ -2,0 +3,0 @@ readonly r: bigint;

"use strict";
// Signature represents the secp256k1 signature of a Guardian
Object.defineProperty(exports, "__esModule", { value: true });
exports.Signature = void 0;
const layout_items_1 = require("./layout-items");
// use layout-items/signature.ts to serialize/deserialize
/** Signature represents the secp256k1 signature of a Guardian */
class Signature {

@@ -8,0 +7,0 @@ r;

import { Chain, Network } from "@wormhole-foundation/sdk-base";
import { SignedTx, TxHash } from "./types";
import { UnsignedTransaction } from "./unsignedTransaction";
/**
* A Signer is an interface that must be provided to certain methods
* in the SDK to sign transactions. It can be either a SignOnlySigner
* or a SignAndSendSigner depending on circumstances.
* A Signer can be implemented by wrapping an existing offline wallet
* or a web wallet
*/
export type Signer<N extends Network = Network, C extends Chain = Chain> = SignOnlySigner<N, C> | SignAndSendSigner<N, C>;

@@ -10,2 +17,7 @@ export declare function isSigner(thing: any): thing is Signer<Network, Chain>;

}
/**
* A SignOnlySender is for situations where the signer is not
* connected to the network or does not wish to broadcast the
* transactions themselves
*/
export interface SignOnlySigner<N extends Network, C extends Chain> extends SignerBase<C> {

@@ -15,2 +27,7 @@ sign(tx: UnsignedTransaction<N, C>[]): Promise<SignedTx[]>;

export declare function isSignOnlySigner(thing: any): thing is SignOnlySigner<Network, Chain>;
/**
* A SignAndSendSigner is for situations where the signer is
* connected to the network and wishes to broadcast the
* transactions themselves
*/
export interface SignAndSendSigner<N extends Network, C extends Chain> extends SignerBase<C> {

@@ -21,2 +38,7 @@ signAndSend(tx: UnsignedTransaction<N, C>[]): Promise<TxHash[]>;

export type NativeSigner = any;
/**
* A PlatformNativeSigner should allow wrapping and unwrapping of a platform specific Signer
* so that the underlying native signer may be used by unwrapping it where needed
*
*/
export declare abstract class PlatformNativeSigner<NS extends NativeSigner, N extends Network = Network, C extends Chain = Chain> {

@@ -23,0 +45,0 @@ protected _chain: C;

@@ -28,2 +28,7 @@ "use strict";

exports.isSignAndSendSigner = isSignAndSendSigner;
/**
* A PlatformNativeSigner should allow wrapping and unwrapping of a platform specific Signer
* so that the underlying native signer may be used by unwrapping it where needed
*
*/
class PlatformNativeSigner {

@@ -30,0 +35,0 @@ _chain;

import { Chain, Network, Platform, PlatformToChains } from "@wormhole-foundation/sdk-base";
import { ChainToPlatform } from "@wormhole-foundation/sdk-base/src";
import { ChainContext, PlatformContext } from "../..";
export declare function chainFactory<N extends Network, P extends Platform, C extends PlatformToChains<P>>(p: PlatformContext<N, P>, chain: C): ChainContext<N, P, C>;
export declare class MockChain<N extends Network, P extends Platform, C extends Chain = PlatformToChains<P>> extends ChainContext<N, P, C> {
constructor(chain: C, platform: PlatformContext<N, P>);
export declare function chainFactory<N extends Network, P extends Platform, C extends PlatformToChains<P>>(p: PlatformContext<N, P>, chain: C): ChainContext<N, C>;
export declare class MockChain<N extends Network, C extends Chain = Chain> extends ChainContext<N, C> {
constructor(chain: C, platform: PlatformContext<N, ChainToPlatform<C>>);
}
//# sourceMappingURL=chain.d.ts.map

@@ -1,3 +0,3 @@

import { Chain, Network, Platform, PlatformToChains } from "@wormhole-foundation/sdk-base";
import { ChainContext, ChainsConfig, PlatformContext, PlatformUtils, RpcConnection, TokenAddress, TokenId, ProtocolName } from "../..";
import { Network, Platform, PlatformToChains } from "@wormhole-foundation/sdk-base";
import { ChainContext, ChainsConfig, PlatformContext, PlatformUtils, ProtocolName, RpcConnection, TokenAddress, TokenId } from "../..";
export declare function mockPlatformFactory<N extends Network, P extends Platform>(platform: P, config: ChainsConfig<N, P>): PlatformUtils<P>;

@@ -7,3 +7,3 @@ export declare class MockPlatform<N extends Network, P extends Platform> extends PlatformContext<N, P> {

static getProtocol<PN extends ProtocolName, T extends any>(protocol: PN): T;
getChain<C extends Chain>(chain: C): ChainContext<N, P, C>;
getChain<C extends PlatformToChains<P>>(chain: C): ChainContext<N, C>;
getRpc<C extends PlatformToChains<P>>(chain: C): RpcConnection<P>;

@@ -10,0 +10,0 @@ getWrappedAsset<C extends PlatformToChains<P>>(chain: C, rpc: RpcConnection<P>, token: TokenId<C>): Promise<TokenId<C> | null>;

@@ -76,2 +76,3 @@ "use strict";

getChain(chain) {
// @ts-ignore
if (chain in this.config)

@@ -78,0 +79,0 @@ return new chain_1.MockChain(chain, this);

@@ -1,4 +0,4 @@

import { PlatformToChains, Network, Platform } from "@wormhole-foundation/sdk-base";
import { TokenAddress, ChainAddress, NativeAddress, RpcConnection, TokenBridge, UnsignedTransaction } from "../..";
export declare class MockTokenBridge<N extends Network, P extends Platform, C extends PlatformToChains<P>> implements TokenBridge<N, P, C> {
import { Network, Platform, PlatformToChains } from "@wormhole-foundation/sdk-base";
import { ChainAddress, NativeAddress, RpcConnection, TokenAddress, TokenBridge, UnsignedTransaction } from "../..";
export declare class MockTokenBridge<N extends Network, P extends Platform, C extends PlatformToChains<P>> implements TokenBridge<N, C> {
readonly rpc: RpcConnection<P>;

@@ -5,0 +5,0 @@ constructor(rpc: RpcConnection<P>);

@@ -5,5 +5,5 @@ import { Chain } from "@wormhole-foundation/sdk-base";

export declare function makeChainAddress<C extends Chain>(chain: C): ChainAddress<C>;
export declare function makeUniversalChainAddress(chain: Chain): ChainAddress<Chain>;
export declare function makeUniversalChainAddress<C extends Chain>(chain: C): ChainAddress<C>;
export declare function makeUniversalAddress(chain: Chain): UniversalAddress;
export declare function makeNativeAddress<T extends Chain>(chain: T): NativeAddress<T>;
//# sourceMappingURL=address.d.ts.map
import { Chain, ChainToPlatform, Network, Platform, PlatformToChains, explorer, tokens } from "@wormhole-foundation/sdk-base";
import { ChainAddress, UniversalOrNative } from "./address";
import { Contracts } from "./contracts";
/** Alias for string, used to look up transaction details */
export type TxHash = string;
/** The sequence number assigned to a given message by the core bridge */
export type SequenceId = bigint;
/** A signed transaction in its canonical format */
export type SignedTx = any;
/**
* An address representing an asset
* @remarks the string literal 'native' is used to represent the native gas token
*/
export type TokenAddress<C extends Chain> = UniversalOrNative<C> | "native";
export declare function isNative(thing: any): thing is "native";
/** Utility to create a TokenId with the address set to the string "native" */
export declare function nativeTokenId<C extends Chain>(chain: C): TokenId<C>;
/**
* A TokenId is a unique identifier for a token on a given chain
*
* @interface TokenId
*/
export type TokenId<C extends Chain = Chain> = {

@@ -16,3 +29,8 @@ chain: C;

export declare function isSameToken(a: TokenId, b: TokenId): boolean;
/** Utility function to return the string representation of a ChainAddress or TokenId */
export declare function canonicalAddress(ca: ChainAddress | TokenId): string;
/**
* Given a token id, address, or the const string 'native' return
* a TokenId representing either the token itself or the wrapped version
*/
export declare function resolveWrappedToken<N extends Network, C extends Chain>(network: N, chain: C, token: TokenId<C> | TokenAddress<C>): [boolean, TokenId<C>];

@@ -22,2 +40,3 @@ export type Balances = {

};
/** Fully qualified Transaction ID */
export type TransactionId<C extends Chain = Chain> = {

@@ -28,2 +47,3 @@ chain: C;

export declare function isTransactionIdentifier(thing: TransactionId | any): thing is TransactionId;
/** Configuration for a given Chain */
export type ChainConfig<N extends Network, C extends Chain> = {

@@ -33,8 +53,20 @@ key: C;

platform: ChainToPlatform<C>;
/** Wormhole Chain Id for this chain */
chainId: number;
/** Contract addresses for this chain */
contracts: Contracts;
/** Number of blocks before a transaction is considered final */
finalityThreshold: number;
/** Average block time in milliseconds */
blockTime: number;
/** Number of decimal places for the native gas token (e.g. 18 for ETH) */
nativeTokenDecimals: number;
/**
* Native chain id may be eip155 or genesis hash or network moninker or something else
* depending on the platform
*/
nativeChainId: string | bigint;
/**
* Rpc address for this chain
*/
rpc: string;

@@ -41,0 +73,0 @@ tokenMap?: tokens.ChainTokens;

@@ -13,3 +13,3 @@ "use strict";

exports.isNative = isNative;
// Utility to create a TokenId with the address set to the string "native"
/** Utility to create a TokenId with the address set to the string "native" */
function nativeTokenId(chain) {

@@ -34,2 +34,3 @@ return { chain, address: "native" };

exports.isSameToken = isSameToken;
/** Utility function to return the string representation of a ChainAddress or TokenId */
function canonicalAddress(ca) {

@@ -42,4 +43,6 @@ if (isTokenId(ca) && isNative(ca.address))

exports.canonicalAddress = canonicalAddress;
// Given a token id, address, or the const string 'native' return
// a TokenId representing either the token itself or the wrapped version
/**
* Given a token id, address, or the const string 'native' return
* a TokenId representing either the token itself or the wrapped version
*/
function resolveWrappedToken(network, chain, token) {

@@ -46,0 +49,0 @@ let tokenAddr;

import { PlatformAddressFormat } from "@wormhole-foundation/sdk-base";
import { Address, NativeAddress, toNative } from "./address";
/**
* The UniversalAddress represents an address that has been parsed into its
* byte representation and possibly modified to ensure it is exactly 32 bytes long
*/
export declare class UniversalAddress implements Address {

@@ -4,0 +8,0 @@ static readonly byteSize = 32;

@@ -11,2 +11,6 @@ "use strict";

];
/**
* The UniversalAddress represents an address that has been parsed into its
* byte representation and possibly modified to ensure it is exactly 32 bytes long
*/
class UniversalAddress {

@@ -13,0 +17,0 @@ static byteSize = 32;

import { Chain, Network } from "@wormhole-foundation/sdk-base";
/**
* An unsigned transaction is a transaction that has not been signed
* along with details about the transaction
*/
export interface UnsignedTransaction<N extends Network = Network, C extends Chain = Chain> {

@@ -3,0 +7,0 @@ readonly transaction: any;

@@ -129,2 +129,9 @@ import { LayoutToType } from "@wormhole-foundation/sdk-base";

type VAABase = LayoutToType<typeof baseLayout>;
/**
* A VAA is a Verifiable Action Assertion, a signed message that contains
* information about an action that has occurred on a chain.
*
* See {@link https://docs.wormhole.com/wormhole/explore-wormhole/vaa | this link} for more.
*
*/
export interface VAA<PL extends PayloadLiteral = PayloadLiteral> extends VAABase {

@@ -138,2 +145,3 @@ readonly protocolName: DecomposeLiteral<PL>[0];

export type DistributiveVAA<PL extends PayloadLiteral> = PL extends PayloadLiteral ? VAA<PL> : never;
/** A utility type that maps a protocol and payload name to its defined structure */
export type ProtocolVAA<PN extends ProtocolName, PayloadName extends string> = ComposeLiteral<PN, PayloadName, PayloadLiteral> extends infer PL extends PayloadLiteral ? DistributiveVAA<PL> : never;

@@ -140,0 +148,0 @@ export type DistributivePayload<PL extends PayloadLiteral> = PL extends PayloadLiteral ? Payload<PL> : never;

import { Chain, ChainToPlatform, Platform } from "@wormhole-foundation/sdk-base";
import { UniversalAddress } from "./universalAddress";
/**
* Address is the base interface all address types must implement.
*
* Represents a parsed address
*/
export interface Address {
/**
* unwrap returns the underlying native address type, e.g.:
* a Uint8Array for UniversalAddress
* a checksum hex string string for EVM(ethers)
* a PublicKey for Solana
* etc.
*/
unwrap(): unknown;
/** Return the address in its canonical string format */
toString(): string;
/** Return the bytes for the address */
toUint8Array(): Uint8Array;
/** Return an Address that has been converted to its Universal representation */
toUniversalAddress(): UniversalAddress;

@@ -16,6 +31,14 @@ }

export type MappedPlatforms = keyof WormholeNamespace.PlatformToNativeAddressMapping;
/** Utility type to map platform to its native address implementation */
type GetNativeAddress<P extends Platform> = P extends MappedPlatforms ? WormholeNamespace.PlatformToNativeAddressMapping[P] : never;
/** An address that has been parsed into its Nativfe Address type */
export type NativeAddress<C extends Chain> = GetNativeAddress<ChainToPlatform<C>>;
/** A union type representing a parsed address */
export type UniversalOrNative<C extends Chain> = UniversalAddress | NativeAddress<C>;
/** An address that represents an account */
export type AccountAddress<C extends Chain> = UniversalOrNative<C>;
/**
* ChainAddress represents the parsed address for a given chain
* and comes with the context of which chain its relevant for
*/
export type ChainAddress<C extends Chain = Chain> = {

@@ -28,2 +51,3 @@ readonly chain: C;

export declare function nativeIsRegistered<C extends Chain>(chain: C): boolean;
/** Parse an address into its NativeAddress representation */
export declare function toNative<C extends Chain>(chain: C, ua: UniversalAddress | string | Uint8Array): NativeAddress<C>;

@@ -30,0 +54,0 @@ export declare function toUniversal<C extends Chain>(chain: C, address: string | Uint8Array): UniversalAddress;

@@ -21,2 +21,3 @@ import { chainToPlatform, platformToAddressFormat, } from "@wormhole-foundation/sdk-base";

}
/** Parse an address into its NativeAddress representation */
export function toNative(chain, ua) {

@@ -23,0 +24,0 @@ const platform = chainToPlatform.get(chain);

@@ -10,4 +10,13 @@ import { Chain } from "@wormhole-foundation/sdk-base";

import { VAA } from "./vaa";
/**
* The Identifier of an attestation, useful to look up the full attestation
*/
export type AttestationId<PN extends ProtocolName = ProtocolName> = PN extends "TokenBridge" | "AutomaticTokenBridge" | "WormholeCore" | "PorticoBridge" | "AutomaticCircleBridge" ? WormholeMessageId : PN extends "AutomaticCircleBridge" ? WormholeMessageId | CircleMessageId : PN extends "CircleBridge" ? CircleMessageId : PN extends "IbcBridge" ? IbcMessageId : never;
/**
* The full attestation that represents evidence of a transaction
*/
export type Attestation<PN extends ProtocolName = ProtocolName> = PN extends "TokenBridge" | "AutomaticTokenBridge" ? AutomaticTokenBridge.VAA | TokenBridge.VAA : PN extends "AutomaticCircleBridge" ? AutomaticCircleBridge.VAA | CircleBridge.Attestation : PN extends "CircleBridge" ? CircleBridge.Attestation : PN extends "IbcBridge" ? IbcTransferData : PN extends "WormholeCore" ? VAA<"Uint8Array"> : PN extends "PorticoBridge" ? PorticoBridge.VAA : never;
/**
* Wormhole Message Identifier used to fetch a VAA
*/
export type WormholeMessageId = {

@@ -20,2 +29,6 @@ chain: Chain;

export type getWormholeAttestation = (id: WormholeMessageId) => Promise<VAA>;
/**
* Circle Message Identifier
* Used to fetch a Circle attestation
*/
export type CircleMessageId = {

@@ -25,4 +38,9 @@ hash: string;

export declare function isCircleMessageId(thing: CircleMessageId | any): thing is CircleMessageId;
/** Attestation from circle attestation api */
export type CircleAttestation = string;
export type getCircleAttestation = (id: CircleMessageId) => Promise<CircleAttestation>;
/**
* Ibc Message Identifier
* Used to fetch a Ibc attestation
*/
export type IbcMessageId = {

@@ -29,0 +47,0 @@ chain: Chain;

@@ -1,2 +0,3 @@

import { Chain, Network, Platform, PlatformToChains, tokens } from "@wormhole-foundation/sdk-base";
import { Chain, Network, Platform, tokens } from "@wormhole-foundation/sdk-base";
import { ChainToPlatform } from "@wormhole-foundation/sdk-base/src";
import { ChainAddress, UniversalOrNative } from "./address";

@@ -9,46 +10,178 @@ import { WormholeMessageId } from "./attestation";

import { IbcBridge } from "./protocols/ibc";
import { PorticoBridge } from "./protocols/portico";
import { AutomaticTokenBridge, TokenBridge } from "./protocols/tokenBridge";
import { RpcConnection } from "./rpc";
import { ChainConfig, SignedTx, TokenId, TokenAddress } from "./types";
import { PorticoBridge } from "./protocols/portico";
export declare abstract class ChainContext<N extends Network, P extends Platform = Platform, C extends Chain = PlatformToChains<P>> {
import { ChainConfig, SignedTx, TokenAddress, TokenId } from "./types";
/**
* A ChainContext provides a consistent interface for interacting with a chain.
* It holds the configuration for the chain and cached RPC and protocol clients.
*
*/
export declare abstract class ChainContext<N extends Network, C extends Chain = Chain, P extends Platform = ChainToPlatform<C>> {
readonly network: N;
readonly platform: PlatformContext<N, P>;
readonly chain: C;
readonly config: ChainConfig<N, C>;
readonly platform: PlatformContext<N, P>;
protected rpc?: RpcConnection<P>;
protected coreBridge?: WormholeCore<N, P, C>;
protected tokenBridge?: TokenBridge<N, P, C>;
protected autoTokenBridge?: AutomaticTokenBridge<N, P, C>;
protected circleBridge?: CircleBridge<N, P, C>;
protected autoCircleBridge?: AutomaticCircleBridge<N, P, C>;
protected ibcBridge?: IbcBridge<N, P, C>;
protected porticoBridge?: PorticoBridge<N, P, C>;
protected coreBridge?: WormholeCore<N, C>;
protected tokenBridge?: TokenBridge<N, C>;
protected autoTokenBridge?: AutomaticTokenBridge<N, C>;
protected circleBridge?: CircleBridge<N, C>;
protected autoCircleBridge?: AutomaticCircleBridge<N, C>;
protected ibcBridge?: IbcBridge<N, C>;
protected porticoBridge?: PorticoBridge<N, C>;
constructor(chain: C, platform: PlatformContext<N, P>, rpc?: RpcConnection<P>);
/**
* Get an RPC connection for this chain, uses the configuration passed in
* the initial constructor
*
* @returns the RPC connection for this chain
*/
getRpc(): Promise<RpcConnection<P>>;
/**
* Get the number of decimals for a token
*
* @param token the token to get the decimals for
* @returns the number of decimals for the token
*/
getDecimals(token: TokenAddress<C>): Promise<number>;
/**
* Get the balance of a token for a given address
*
* @param walletAddr the address to get the balance for
* @param token the token to get the balance for
* @returns the balance of the token for the address
*
*/
getBalance(walletAddr: string, token: TokenAddress<C>): Promise<bigint | null>;
/**
* Get the latest block number seen by the chain according to the RPC
*
* @returns the latest block number
*/
getLatestBlock(): Promise<number>;
/**
* Get the latest _finalized_ block number seen by the chain according to the RPC
*
* @returns the latest finalized block number
*/
getLatestFinalizedBlock(): Promise<number>;
/**
* Parse the Wormhole Core messages from a transaction
*
* @param txid the transaction to parse
* @returns the Wormhole Core messages emitted by the transaction
*/
parseTransaction(txid: string): Promise<WormholeMessageId[]>;
sendWait(stxns: SignedTx): Promise<string[]>;
/**
* Send a transaction and wait for it to be confirmed
*
* @param stxns the signed transaction to send
* @returns the transaction hashes of the sent transactions
*/
sendWait(stxns: SignedTx[]): Promise<string[]>;
/**
* Get the token data from the local cache if available
* @param symbol the symbol of the token to get
* @returns the token data if available
*/
getToken(symbol: tokens.TokenSymbol): tokens.Token | undefined;
/**
* Get the token id of the wrapped token for the native gas token
*
* @returns the wrapped token for the native gas token
*/
getNativeWrappedTokenId(): Promise<TokenId<C>>;
/**
* Get the token account for a given address and token
*
* @remarks
* This is really only useful in the context of Solana but in order
* to provide a consistent interface, we provide it here.
*
* @param address the address to get the token account for
* @param token the token to get the token account for
* @returns the token account for the address and token
*/
getTokenAccount(address: UniversalOrNative<C>, token: TokenAddress<C>): Promise<ChainAddress<C>>;
/**
* Check to see if a given protocol is supported by this chain
* by checking if it is registered in the platform and the configuration
* is available and correct
*
* @param protocolName the name of the Protocol to check for support
* @returns a boolean indicating if this protocol is supported
*/
supportsProtocol(protocolName: ProtocolName): boolean;
/**
* Check to see if the Wormhole Core protocol is supported by this chain
* @returns a boolean indicating if this chain supports the Wormhole Core protocol
*/
supportsWormholeCore: () => boolean;
getWormholeCore(): Promise<WormholeCore<N, P, C>>;
/**
* Get the Wormhole Core protocol client for this chain
* @returns the Wormhole Core protocol client for this chain
*/
getWormholeCore(): Promise<WormholeCore<N, C>>;
/**
* Check to see if the Token Bridge protocol is supported by this chain
* @returns a boolean indicating if this chain supports the Token Bridge protocol
*/
supportsTokenBridge: () => boolean;
getTokenBridge(): Promise<TokenBridge<N, P, C>>;
/**
* Get the Token Bridge protocol client for this chain
* @returns the Token Bridge protocol client for this chain
*/
getTokenBridge(): Promise<TokenBridge<N, C>>;
/**
* Check to see if the Automatic Token Bridge protocol is supported by this chain
* @returns a boolean indicating if this chain supports the Automatic Token Bridge protocol
*/
supportsAutomaticTokenBridge: () => boolean;
getAutomaticTokenBridge(): Promise<AutomaticTokenBridge<N, P, C>>;
/**
* Get the Automatic Token Bridge protocol client for this chain
* @returns the Automatic Token Bridge protocol client for this chain
*/
getAutomaticTokenBridge(): Promise<AutomaticTokenBridge<N, C>>;
/**
* Check to see if the Circle Bridge protocol is supported by this chain
* @returns a boolean indicating if this chain supports the Circle Bridge protocol
*/
supportsCircleBridge: () => boolean;
getCircleBridge(): Promise<CircleBridge<N, P, C>>;
/**
* Get the Circle Bridge protocol client for this chain
* @returns the Circle Bridge protocol client for this chain
*/
getCircleBridge(): Promise<CircleBridge<N, C>>;
/**
* Check to see if the Automatic Circle Bridge protocol is supported by this chain
* @returns a boolean indicating if this chain supports the Automatic Circle Bridge protocol
*/
supportsAutomaticCircleBridge: () => boolean;
getAutomaticCircleBridge(): Promise<AutomaticCircleBridge<N, P, C>>;
/**
* Get the Automatic Circle Bridge protocol client for this chain
* @returns the Automatic Circle Bridge protocol client for this chain
*/
getAutomaticCircleBridge(): Promise<AutomaticCircleBridge<N, C>>;
/**
* Check to see if the IBC Bridge protocol is supported by this chain
* @returns a boolean indicating if this chain supports the IBC Bridge protocol
*/
supportsIbcBridge: () => boolean;
getIbcBridge(): Promise<IbcBridge<N, P, C>>;
/**
* Get the IBC Bridge protocol client for this chain
* @returns the IBC Bridge protocol client for this chain
*/
getIbcBridge(): Promise<IbcBridge<N, C>>;
/**
* Check to see if the Portico Bridge protocol is supported by this chain
* @returns a boolean indicating if this chain supports the Portico Bridge protocol
*/
supportsPorticoBridge: () => boolean;
getPorticoBridge(): Promise<PorticoBridge<N, P, C>>;
/**
* Get the Portico Bridge protocol client for this chain
* @returns the Portico Bridge protocol client for this chain
*/
getPorticoBridge(): Promise<PorticoBridge<N, C>>;
}
//# sourceMappingURL=chain.d.ts.map
import { tokens } from "@wormhole-foundation/sdk-base";
import { toNative } from "./address";
import { protocolIsRegistered } from "./protocol";
/**
* A ChainContext provides a consistent interface for interacting with a chain.
* It holds the configuration for the chain and cached RPC and protocol clients.
*
*/
export class ChainContext {
network;
platform;
chain;
config;
platform;
// Cached Protocol clients

@@ -25,2 +30,8 @@ rpc;

}
/**
* Get an RPC connection for this chain, uses the configuration passed in
* the initial constructor
*
* @returns the RPC connection for this chain
*/
getRpc() {

@@ -30,3 +41,8 @@ this.rpc = this.rpc ? this.rpc : this.platform.getRpc(this.chain);

}
// Get the number of decimals for a token
/**
* Get the number of decimals for a token
*
* @param token the token to get the decimals for
* @returns the number of decimals for the token
*/
async getDecimals(token) {

@@ -41,20 +57,52 @@ // try to find it in the token cache first

}
// Get the balance of a token for a given address
/**
* Get the balance of a token for a given address
*
* @param walletAddr the address to get the balance for
* @param token the token to get the balance for
* @returns the balance of the token for the address
*
*/
async getBalance(walletAddr, token) {
return this.platform.utils().getBalance(this.chain, await this.getRpc(), walletAddr, token);
}
/**
* Get the latest block number seen by the chain according to the RPC
*
* @returns the latest block number
*/
async getLatestBlock() {
return this.platform.utils().getLatestBlock(await this.getRpc());
}
/**
* Get the latest _finalized_ block number seen by the chain according to the RPC
*
* @returns the latest finalized block number
*/
async getLatestFinalizedBlock() {
return this.platform.utils().getLatestFinalizedBlock(await this.getRpc());
}
// Get details about the transaction
/**
* Parse the Wormhole Core messages from a transaction
*
* @param txid the transaction to parse
* @returns the Wormhole Core messages emitted by the transaction
*/
async parseTransaction(txid) {
return this.platform.parseWormholeMessages(this.chain, await this.getRpc(), txid);
}
// Send a transaction and wait for it to be confirmed
/**
* Send a transaction and wait for it to be confirmed
*
* @param stxns the signed transaction to send
* @returns the transaction hashes of the sent transactions
*/
async sendWait(stxns) {
return this.platform.utils().sendWait(this.chain, await this.getRpc(), stxns);
}
/**
* Get the token data from the local cache if available
* @param symbol the symbol of the token to get
* @returns the token data if available
*/
getToken(symbol) {

@@ -67,2 +115,7 @@ if (!this.config.tokenMap)

}
/**
* Get the token id of the wrapped token for the native gas token
*
* @returns the wrapped token for the native gas token
*/
async getNativeWrappedTokenId() {

@@ -78,3 +131,13 @@ // see if we have it configured

}
// Get the token account for a given address
/**
* Get the token account for a given address and token
*
* @remarks
* This is really only useful in the context of Solana but in order
* to provide a consistent interface, we provide it here.
*
* @param address the address to get the token account for
* @param token the token to get the token account for
* @returns the token account for the address and token
*/
async getTokenAccount(address, token) {

@@ -84,10 +147,22 @@ // Noop by default, override in implementation if necessary

}
//
// protocols
//
//
/**
* Check to see if a given protocol is supported by this chain
* by checking if it is registered in the platform and the configuration
* is available and correct
*
* @param protocolName the name of the Protocol to check for support
* @returns a boolean indicating if this protocol is supported
*/
supportsProtocol(protocolName) {
return protocolIsRegistered(this.chain, protocolName);
}
/**
* Check to see if the Wormhole Core protocol is supported by this chain
* @returns a boolean indicating if this chain supports the Wormhole Core protocol
*/
supportsWormholeCore = () => this.supportsProtocol("WormholeCore");
/**
* Get the Wormhole Core protocol client for this chain
* @returns the Wormhole Core protocol client for this chain
*/
async getWormholeCore() {

@@ -99,3 +174,11 @@ this.coreBridge = this.coreBridge

}
/**
* Check to see if the Token Bridge protocol is supported by this chain
* @returns a boolean indicating if this chain supports the Token Bridge protocol
*/
supportsTokenBridge = () => this.supportsProtocol("TokenBridge");
/**
* Get the Token Bridge protocol client for this chain
* @returns the Token Bridge protocol client for this chain
*/
async getTokenBridge() {

@@ -107,4 +190,11 @@ this.tokenBridge = this.tokenBridge

}
//
/**
* Check to see if the Automatic Token Bridge protocol is supported by this chain
* @returns a boolean indicating if this chain supports the Automatic Token Bridge protocol
*/
supportsAutomaticTokenBridge = () => this.supportsProtocol("AutomaticTokenBridge");
/**
* Get the Automatic Token Bridge protocol client for this chain
* @returns the Automatic Token Bridge protocol client for this chain
*/
async getAutomaticTokenBridge() {

@@ -116,4 +206,11 @@ this.autoTokenBridge = this.autoTokenBridge

}
//
/**
* Check to see if the Circle Bridge protocol is supported by this chain
* @returns a boolean indicating if this chain supports the Circle Bridge protocol
*/
supportsCircleBridge = () => this.supportsProtocol("CircleBridge");
/**
* Get the Circle Bridge protocol client for this chain
* @returns the Circle Bridge protocol client for this chain
*/
async getCircleBridge() {

@@ -125,4 +222,11 @@ this.circleBridge = this.circleBridge

}
//
/**
* Check to see if the Automatic Circle Bridge protocol is supported by this chain
* @returns a boolean indicating if this chain supports the Automatic Circle Bridge protocol
*/
supportsAutomaticCircleBridge = () => this.supportsProtocol("AutomaticCircleBridge");
/**
* Get the Automatic Circle Bridge protocol client for this chain
* @returns the Automatic Circle Bridge protocol client for this chain
*/
async getAutomaticCircleBridge() {

@@ -134,4 +238,11 @@ this.autoCircleBridge = this.autoCircleBridge

}
//
/**
* Check to see if the IBC Bridge protocol is supported by this chain
* @returns a boolean indicating if this chain supports the IBC Bridge protocol
*/
supportsIbcBridge = () => this.supportsProtocol("IbcBridge");
/**
* Get the IBC Bridge protocol client for this chain
* @returns the IBC Bridge protocol client for this chain
*/
async getIbcBridge() {

@@ -143,4 +254,11 @@ this.ibcBridge = this.ibcBridge

}
//
/**
* Check to see if the Portico Bridge protocol is supported by this chain
* @returns a boolean indicating if this chain supports the Portico Bridge protocol
*/
supportsPorticoBridge = () => this.supportsProtocol("PorticoBridge");
/**
* Get the Portico Bridge protocol client for this chain
* @returns the Portico Bridge protocol client for this chain
*/
async getPorticoBridge() {

@@ -147,0 +265,0 @@ this.porticoBridge = this.porticoBridge

import { Chain, Network, contracts } from "@wormhole-foundation/sdk-base";
/** The Contract addresses set in configuration for a given chain */
export type Contracts = {

@@ -13,3 +14,11 @@ coreBridge?: string;

};
/**
*
* Get the contracts for a given network and chain
*
* @param n the network to get contracts for
* @param c the chain to get contracts for
* @returns the contracts for the given network and chain
*/
export declare function getContracts(n: Network, c: Chain): Contracts;
//# sourceMappingURL=contracts.d.ts.map
import { contracts } from "@wormhole-foundation/sdk-base";
/**
*
* Get the contracts for a given network and chain
*
* @param n the network to get contracts for
* @param c the chain to get contracts for
* @returns the contracts for the given network and chain
*/
export function getContracts(n, c) {

@@ -3,0 +11,0 @@ const ct = {

@@ -12,3 +12,2 @@ import "./payloads/automaticCircleBridge";

export * from "./utils";
export * from "./relayer";
export * from "./platform";

@@ -27,4 +26,5 @@ export * from "./chain";

export * from "./protocols/portico";
export * from "./protocols/relayer";
export * as layoutItems from "./layout-items";
export * as testing from "./testing";
//# sourceMappingURL=index.d.ts.map

@@ -13,3 +13,2 @@ // Make sure payloads are registered

export * from "./utils";
export * from "./relayer";
export * from "./platform";

@@ -28,4 +27,5 @@ export * from "./chain";

export * from "./protocols/portico";
export * from "./protocols/relayer";
export * as layoutItems from "./layout-items";
export * as testing from "./testing";
//# sourceMappingURL=index.js.map

@@ -16,3 +16,3 @@ type AllowNull<T, B extends boolean> = B extends true ? T | null : T;

to: C;
from: (C extends bigint ? `bigint(${C})` : C extends boolean ? `boolean(${C})` : C) extends "Solana" | "Btc" | "Algorand" | "Sui" | "Aptos" | "Near" | "Ethereum" | "Terra" | "Bsc" | "Polygon" | "Avalanche" | "Oasis" | "Aurora" | "Fantom" | "Karura" | "Acala" | "Klaytn" | "Celo" | "Moonbeam" | "Neon" | "Terra2" | "Injective" | "Osmosis" | "Arbitrum" | "Optimism" | "Gnosis" | "Pythnet" | "Xpla" | "Base" | "Sei" | "Rootstock" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky" ? {
from: {
Solana: 1;

@@ -58,89 +58,3 @@ Ethereum: 2;

Holesky: 10006;
}[("Solana" | "Btc" | "Algorand" | "Sui" | "Aptos" | "Near" | "Ethereum" | "Terra" | "Bsc" | "Polygon" | "Avalanche" | "Oasis" | "Aurora" | "Fantom" | "Karura" | "Acala" | "Klaytn" | "Celo" | "Moonbeam" | "Neon" | "Terra2" | "Injective" | "Osmosis" | "Arbitrum" | "Optimism" | "Gnosis" | "Pythnet" | "Xpla" | "Base" | "Sei" | "Rootstock" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky") & (C extends bigint ? `bigint(${C})` : C extends boolean ? `boolean(${C})` : C)] extends {
[key: string]: unknown;
[key: number]: unknown;
[key: symbol]: unknown;
} ? {
Solana: 1;
Ethereum: 2;
Terra: 3;
Bsc: 4;
Polygon: 5;
Avalanche: 6;
Oasis: 7;
Algorand: 8;
Aurora: 9;
Fantom: 10;
Karura: 11;
Acala: 12;
Klaytn: 13;
Celo: 14;
Near: 15;
Moonbeam: 16;
Neon: 17;
Terra2: 18;
Injective: 19;
Osmosis: 20;
Sui: 21;
Aptos: 22;
Arbitrum: 23;
Optimism: 24;
Gnosis: 25;
Pythnet: 26;
Xpla: 28;
Btc: 29;
Base: 30;
Sei: 32;
Rootstock: 33;
Wormchain: 3104;
Cosmoshub: 4000;
Evmos: 4001;
Kujira: 4002;
Sepolia: 10002;
ArbitrumSepolia: 10003;
BaseSepolia: 10004;
OptimismSepolia: 10005;
Holesky: 10006;
}[("Solana" | "Btc" | "Algorand" | "Sui" | "Aptos" | "Near" | "Ethereum" | "Terra" | "Bsc" | "Polygon" | "Avalanche" | "Oasis" | "Aurora" | "Fantom" | "Karura" | "Acala" | "Klaytn" | "Celo" | "Moonbeam" | "Neon" | "Terra2" | "Injective" | "Osmosis" | "Arbitrum" | "Optimism" | "Gnosis" | "Pythnet" | "Xpla" | "Base" | "Sei" | "Rootstock" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky") & (C extends bigint ? `bigint(${C})` : C extends boolean ? `boolean(${C})` : C)] : {
Solana: 1;
Ethereum: 2;
Terra: 3;
Bsc: 4;
Polygon: 5;
Avalanche: 6;
Oasis: 7;
Algorand: 8;
Aurora: 9;
Fantom: 10;
Karura: 11;
Acala: 12;
Klaytn: 13;
Celo: 14;
Near: 15;
Moonbeam: 16;
Neon: 17;
Terra2: 18;
Injective: 19;
Osmosis: 20;
Sui: 21;
Aptos: 22;
Arbitrum: 23;
Optimism: 24;
Gnosis: 25;
Pythnet: 26;
Xpla: 28;
Btc: 29;
Base: 30;
Sei: 32;
Rootstock: 33;
Wormchain: 3104;
Cosmoshub: 4000;
Evmos: 4001;
Kujira: 4002;
Sepolia: 10002;
ArbitrumSepolia: 10003;
BaseSepolia: 10004;
OptimismSepolia: 10005;
Holesky: 10006;
}[("Solana" | "Btc" | "Algorand" | "Sui" | "Aptos" | "Near" | "Ethereum" | "Terra" | "Bsc" | "Polygon" | "Avalanche" | "Oasis" | "Aurora" | "Fantom" | "Karura" | "Acala" | "Klaytn" | "Celo" | "Moonbeam" | "Neon" | "Terra2" | "Injective" | "Osmosis" | "Arbitrum" | "Optimism" | "Gnosis" | "Pythnet" | "Xpla" | "Base" | "Sei" | "Rootstock" | "Wormchain" | "Cosmoshub" | "Evmos" | "Kujira" | "Sepolia" | "ArbitrumSepolia" | "BaseSepolia" | "OptimismSepolia" | "Holesky") & (C extends bigint ? `bigint(${C})` : C extends boolean ? `boolean(${C})` : C)] : never;
}[C extends bigint ? `bigint(${C})` : C extends boolean ? `boolean(${C})` : C];
};

@@ -147,0 +61,0 @@ readonly binary: "uint";

@@ -7,14 +7,38 @@ import { Chain, Network, Platform, PlatformToChains } from "@wormhole-foundation/sdk-base";

import { Balances, ChainsConfig, SignedTx, TokenId, TxHash, TokenAddress } from "./types";
/**
* PlatformUtils represents the _static_ attributes available on
* the PlatformContext Class
*/
export interface PlatformUtils<P extends Platform> {
/** Value for the Platform so we can access it at runtime */
_platform: P;
/** Initialize a new PlatformContext object */
new <N extends Network>(network: N, config?: ChainsConfig<N, P>): PlatformContext<N, P>;
/**
* Check if this chain is supported by this platform
*/
isSupportedChain(chain: Chain): boolean;
/** Look up a Chain from its native chain ID
* See implementation for details
* Note: this is _not_ the same as the Wormhole chain id
*/
chainFromChainId(chainId: string | bigint): [Network, Chain];
/**
* Given an RPC connection, request the native chain id
* then resolve it to a Wormhole Canonical network and chain name
*/
chainFromRpc(rpc: RpcConnection<P>): Promise<[Network, Chain]>;
/** Get the native (gas) token id for a given chain */
nativeTokenId<N extends Network, C extends PlatformToChains<P>>(network: N, chain: C): TokenId<C>;
/** Check if the token passed is the native token id for the argued chain and network */
isNativeTokenId<N extends Network, C extends PlatformToChains<P>>(network: N, chain: C, tokenId: TokenId): boolean;
/** Get the number of decimals for a given token */
getDecimals<C extends PlatformToChains<P>>(chain: C, rpc: RpcConnection<P>, token: TokenAddress<C>): Promise<number>;
/** Get the balance of a token for a given wallet address */
getBalance<C extends PlatformToChains<P>>(chain: C, rpc: RpcConnection<P>, walletAddr: string, token: TokenAddress<C>): Promise<bigint | null>;
/** Look up the balances for a list of tokens for a given wallet address */
getBalances<C extends PlatformToChains<P>>(chain: C, rpc: RpcConnection<P>, walletAddress: string, tokens: TokenAddress<C>[]): Promise<Balances>;
/** Look up the latest block according to the RPC passed */
getLatestBlock(rpc: RpcConnection<P>): Promise<number>;
/** Look up the latest _finalized_ block according to the RPC passed */
getLatestFinalizedBlock(rpc: RpcConnection<P>): Promise<number>;

@@ -24,2 +48,5 @@ sendWait<C extends PlatformToChains<P>>(chain: C, rpc: RpcConnection<P>, stxns: SignedTx[]): Promise<TxHash[]>;

export type StaticPlatformMethods<P extends Platform, I extends PlatformUtils<P>> = InstanceType<I>;
/**
* PlatformContext is an instance of the class that represents a specific Platform
*/
export declare abstract class PlatformContext<N extends Network, P extends Platform> {

@@ -29,8 +56,13 @@ readonly network: N;

constructor(network: N, config: ChainsConfig<N, P>);
/** provides access to the static attributes of the PlatformContext class */
utils(): PlatformUtils<P>;
/** Create a new RPC Connection */
abstract getRpc<C extends PlatformToChains<P>>(chain: C): RpcConnection<P> | Promise<RpcConnection<P>>;
abstract getChain<C extends PlatformToChains<P>>(chain: C, rpc?: RpcConnection<P>): ChainContext<N, P, C>;
/** Create a new Chain context object */
abstract getChain<C extends PlatformToChains<P>>(chain: C, rpc?: RpcConnection<P>): ChainContext<N, C>;
/** Create a new Protocol Client instance by protocol name */
getProtocol<PN extends ProtocolName, T>(protocol: PN, rpc: RpcConnection<P>): Promise<T>;
/** Look up transaction logs and parse out Wormhole messages */
parseWormholeMessages<C extends PlatformToChains<P>>(chain: C, rpc: RpcConnection<P>, txid: TxHash): Promise<WormholeMessageId[]>;
}
//# sourceMappingURL=platform.d.ts.map
import { create } from "./protocol";
// PlatformContext is an instance of the class that represents a specific Platform
/**
* PlatformContext is an instance of the class that represents a specific Platform
*/
export class PlatformContext {

@@ -10,11 +12,11 @@ network;

}
// provides access to the static attributes of the PlatformContext class
/** provides access to the static attributes of the PlatformContext class */
utils() {
return this.constructor;
}
// Create a new Protocol Client instance by protocol name
/** Create a new Protocol Client instance by protocol name */
getProtocol(protocol, rpc) {
return create(this.utils()._platform, protocol, rpc, this.config);
}
// Look up transaction logs and parse out Wormhole messages
/** Look up transaction logs and parse out Wormhole messages */
async parseWormholeMessages(chain, rpc, txid) {

@@ -21,0 +23,0 @@ const wc = await this.getProtocol("WormholeCore", rpc);

@@ -10,2 +10,3 @@ import { Chain, Network, Platform } from "@wormhole-foundation/sdk-base";

}
/** A string type representing the name of a protocol */
export type ProtocolName = keyof WormholeNamespace.ProtocolToPlatformMapping;

@@ -12,0 +13,0 @@ type MappedProtocolPlatforms = keyof WormholeNamespace.ProtocolToPlatformMapping[ProtocolName];

@@ -1,2 +0,2 @@

import { Chain, LayoutToType, Network, Platform, PlatformToChains } from "@wormhole-foundation/sdk-base";
import { Chain, LayoutToType, Network, Platform } from "@wormhole-foundation/sdk-base";
import { AccountAddress, ChainAddress } from "../address";

@@ -8,4 +8,4 @@ import { CircleMessageId } from "../attestation";

import { circleMessageLayout } from "../payloads/circleBridge";
import { EmptyPlatformMap } from "../protocol";
import { ProtocolPayload, ProtocolVAA } from "../vaa";
import { EmptyPlatformMap } from "../protocol";
declare global {

@@ -21,2 +21,3 @@ namespace WormholeNamespace {

const _protocol = "CircleBridge";
/** The compile time type for the CircleBridge protocol */
export type ProtocolName = typeof _protocol;

@@ -26,2 +27,3 @@ const _payloads: readonly ["Message"];

export type Message = LayoutToType<typeof circleMessageLayout>;
/** Circle message and attestation if available */
export type Attestation = {

@@ -41,2 +43,3 @@ message: Message;

export type PayloadNames = (typeof _payloads)[number];
/** The VAA types that are emitted from the AutomaticCirlceBridge protocol */
export type VAA<PayloadName extends PayloadNames = PayloadNames> = ProtocolVAA<ProtocolName, PayloadName>;

@@ -64,12 +67,64 @@ export type Payload<PayloadName extends PayloadNames = PayloadNames> = ProtocolPayload<ProtocolName, PayloadName>;

export declare function isCircleTransferDetails(thing: any): thing is CircleTransferDetails;
export interface CircleBridge<N extends Network, P extends Platform, C extends PlatformToChains<P>> {
/**
* CircleBridge protocol definition, providing a consistent client
* interface to the CircleBridge protocol (CCTP).
*
* Find the source contracts here: ${@link https://github.com/circlefin/evm-cctp-contracts}
*
*/
export interface CircleBridge<N extends Network, C extends Chain> {
/**
* Redeem a circle transfer against the Circle Bridge
*
* @param sender The address of the sender
* @param message The Circle message to redeem
* @param attestation The attestation, from the Circle attestation service
*
* @returns a stream of unsigned transactions to be signed and submitted on chain
*/
redeem(sender: AccountAddress<C>, message: CircleBridge.Message, attestation: string): AsyncGenerator<UnsignedTransaction<N, C>>;
/**
* Initiate a transfer through the Circle CCTP Bridge
*
* @param sender the sender of the transaction
* @param recipient the chain and address of the recipient of the transfer
* @param amount how much to send in base units
*/
transfer(sender: AccountAddress<C>, recipient: ChainAddress, amount: bigint): AsyncGenerator<UnsignedTransaction<N, C>>;
/**
* Check if a transfer has been completed according to the bridge contract
*
* @param message The message to check
*/
isTransferCompleted(message: CircleBridge.Message): Promise<boolean>;
/**
* Grabs the logs from the transaction and parse the circle message
*
* @param txid The transaction hash from which to parse a message
*
* @returns The parsed CircleTransferMessage
*/
parseTransactionDetails(txid: string): Promise<CircleTransferMessage>;
}
export interface AutomaticCircleBridge<N extends Network, P extends Platform, C extends Chain = PlatformToChains<P>> {
/**
* AutomaticCircleBridge protocol definition, providing a consistent client
* interface for the CircleBridge protocol with Automatic delivery.
*/
export interface AutomaticCircleBridge<N extends Network, C extends Chain> {
/**
* Get the fee required by the relayer to cover the costs of redemption on the destination chain
*
* @param destination The destination chain for which to get a fee quote
* @returns the fee required by the relayer to cover the costs of redemption on the destination chain
*/
getRelayerFee(destination: Chain): Promise<bigint>;
/**
*
* @param sender address of the transaction sender
* @param recipient address of the destination chain recipient
* @param amount how much to send, in base units
* @param nativeGas if set, determines how much native gas should be received by the recipient
*/
transfer(sender: AccountAddress<C>, recipient: ChainAddress, amount: bigint, nativeGas?: bigint): AsyncGenerator<UnsignedTransaction<N, C>>;
}
//# sourceMappingURL=circleBridge.d.ts.map

@@ -1,8 +0,8 @@

import { PlatformToChains, Network, Platform } from "@wormhole-foundation/sdk-base";
import { Chain, Network, Platform } from "@wormhole-foundation/sdk-base";
import { AccountAddress } from "../address";
import { WormholeMessageId } from "../attestation";
import { EmptyPlatformMap } from "../protocol";
import { TxHash } from "../types";
import { UnsignedTransaction } from "../unsignedTransaction";
import { VAA } from "../vaa";
import { EmptyPlatformMap } from "../protocol";
declare global {

@@ -15,8 +15,39 @@ namespace WormholeNamespace {

}
export interface WormholeCore<N extends Network, P extends Platform, C extends PlatformToChains<P>> {
/**
* WormholeCore provides a consistent interface to interact
* with the Wormhole core messaging protocol.
*
*/
export interface WormholeCore<N extends Network, C extends Chain> {
/** Get the fee for publishing a message */
getMessageFee(): Promise<bigint>;
/**
* Publish a message
*
* @param sender The address of the sender
* @param message The message to send
* @param nonce A number that may be set if needed for the application, may be 0 if unneeded
* @param consistencyLevel The consistency level to reach before the guardians should sign the message
* see {@link https://docs.wormhole.com/wormhole/reference/glossary#consistency-level | the docs} for more information
*
* @returns a stream of unsigned transactions to be signed and submitted on chain
*/
publishMessage(sender: AccountAddress<C>, message: string | Uint8Array, nonce: number, consistencyLevel: number): AsyncGenerator<UnsignedTransaction<N, C>>;
/**
* Verify a VAA against the core contract
* @param sender the sender of the transaction
* @param vaa the VAA to verify
*
* @returns a stream of unsigned transactions to be signed and submitted on chain
*/
verifyMessage(sender: AccountAddress<C>, vaa: VAA): AsyncGenerator<UnsignedTransaction<N, C>>;
/**
* Parse a transaction to get its message id
*
* @param txid the transaction hash to parse
*
* @returns the message ids produced by the transaction
*/
parseTransaction(txid: TxHash): Promise<WormholeMessageId[]>;
}
//# sourceMappingURL=core.d.ts.map

@@ -1,7 +0,7 @@

import { Chain, ChainId, Network, Platform, PlatformToChains } from "@wormhole-foundation/sdk-base";
import { Chain, ChainId, Network, Platform } from "@wormhole-foundation/sdk-base";
import { AccountAddress, ChainAddress, NativeAddress } from "../address";
import { IbcMessageId, WormholeMessageId } from "../attestation";
import { TokenId, TxHash, TokenAddress } from "../types";
import { EmptyPlatformMap } from "../protocol";
import { TokenAddress, TokenId, TxHash } from "../types";
import { UnsignedTransaction } from "../unsignedTransaction";
import { EmptyPlatformMap } from "../protocol";
declare global {

@@ -14,2 +14,3 @@ namespace WormholeNamespace {

}
/** Configuration for a transfer through the Gateway */
export type GatewayTransferDetails = {

@@ -25,2 +26,6 @@ token: TokenId<Chain>;

};
/**
* Holds the data of a gateway message without
* special keys required by cosmos contracts
*/
export interface GatewayMsg {

@@ -55,2 +60,5 @@ chain: ChainId;

export declare function isIbcTransferInfo(thing: IbcTransferInfo | any): thing is IbcTransferInfo;
/**
* The expected payload sent as a string over IBC
*/
export interface IbcTransferData {

@@ -63,11 +71,27 @@ amount: string;

}
export interface IbcBridge<N extends Network, P extends Platform, C extends PlatformToChains<P>> {
/**
* IbcBridge provides an interface to use the IBC token transfer protocol
*
* See more here {@link https://tutorials.cosmos.network/academy/3-ibc/7-token-transfer.html}
*
*/
export interface IbcBridge<N extends Network, C extends Chain> {
/** Initiate an IBC token transfer */
transfer(sender: AccountAddress<C>, recipient: ChainAddress, token: TokenAddress<C>, amount: bigint, payload?: Uint8Array): AsyncGenerator<UnsignedTransaction<N, C>>;
/** Get the transfer channel for a remote chain, pulled from local cache */
getTransferChannel(chain: Chain): string | null;
/** Get the transfer channel for a remote chain, pulled from contract */
fetchTransferChannel(chain: Chain): Promise<string | null>;
/**
* Find the wormhole emitted message id for a given IBC transfer
* if it does not exist, this will return null
*/
lookupMessageFromIbcMsgId(msg: IbcMessageId): Promise<WormholeMessageId | null>;
/** Find the IBCTransferInfo given a transaction id */
lookupTransferFromTx(txid: TxHash): Promise<IbcTransferInfo>;
/** Find the IBCTransferInfo from a message id */
lookupTransferFromIbcMsgId(msg: IbcMessageId): Promise<IbcTransferInfo>;
/** Find the IBCTransferInfo from a gateway transfer message */
lookupTransferFromMsg(payload: GatewayTransferMsg | GatewayTransferWithPayloadMsg): Promise<IbcTransferInfo>;
}
//# sourceMappingURL=ibc.d.ts.map

@@ -1,2 +0,2 @@

import { LayoutToType, Network, Platform, PlatformToChains } from "@wormhole-foundation/sdk-base";
import { Chain, LayoutToType, Network, Platform } from "@wormhole-foundation/sdk-base";
import { AccountAddress, ChainAddress } from "../address";

@@ -6,3 +6,3 @@ import "../payloads/portico";

import { EmptyPlatformMap } from "../protocol";
import { TokenId, TokenAddress } from "../types";
import { TokenAddress, TokenId } from "../types";
import { UnsignedTransaction } from "../unsignedTransaction";

@@ -19,2 +19,3 @@ import { ProtocolVAA } from "../vaa";

const _protocol = "PorticoBridge";
/** The compile time protocol name type for Portico Bridge */
export type ProtocolName = typeof _protocol;

@@ -34,2 +35,3 @@ export interface SwapAmounts {

export type PayloadNames = (typeof _payloads)[number];
/** The VAA types emitted by the PorticoBridge protocol */
export type VAA<PayloadName extends PayloadNames = PayloadNames> = ProtocolVAA<ProtocolName, PayloadName>;

@@ -44,6 +46,14 @@ export type Payload = LayoutToType<typeof porticoPayloadLayout>;

}
export interface PorticoBridge<N extends Network, P extends Platform, C extends PlatformToChains<P>> {
/**
* PorticoBridge provides a consistent interface to interact with
* the Portico bridge contracts.
*/
export interface PorticoBridge<N extends Network, C extends Chain> {
/** Initiate a transfer of some token to another chain */
transfer(sender: AccountAddress<C>, recipient: ChainAddress, token: TokenAddress<C>, amount: bigint, destToken: TokenId, quote: PorticoBridge.Quote): AsyncGenerator<UnsignedTransaction<N, C>>;
/** Redeem a transfer VAA to receive the tokens on this chain */
redeem(sender: AccountAddress<C>, vaa: PorticoBridge.VAA): AsyncGenerator<UnsignedTransaction<N, C>>;
/** quote token conversion */
quoteSwap(input: TokenAddress<C>, output: TokenAddress<C>, amount: bigint): Promise<bigint>;
/** quote relay on destination with conversion */
quoteRelay(token: TokenAddress<C>, destination: TokenAddress<C>): Promise<bigint>;

@@ -50,0 +60,0 @@ getTransferrableToken(address: string): TokenId;

@@ -0,1 +1,3 @@

import { Chain } from "@wormhole-foundation/sdk-base";
import { TokenAddress } from "../types";
import { Platform } from "@wormhole-foundation/sdk-base";

@@ -10,2 +12,9 @@ import { EmptyPlatformMap } from "../protocol";

}
export interface Relayer {
relaySupported(chain: Chain): boolean;
getRelayerFee(sourceChain: Chain, destChain: Chain, tokenId: TokenAddress<Chain>): Promise<bigint>;
startTransferWithRelay(token: TokenAddress<Chain>, amount: bigint, toNativeToken: string, sendingChain: Chain, senderAddress: string, recipientChain: Chain, recipientAddress: string, overrides?: any): Promise<any>;
calculateNativeTokenAmt(destChain: Chain, tokenId: TokenAddress<Chain>, amount: bigint, walletAddress: string): Promise<bigint>;
calculateMaxSwapAmount(destChain: Chain, tokenId: TokenAddress<Chain>, walletAddress: string): Promise<bigint>;
}
//# sourceMappingURL=relayer.d.ts.map

@@ -1,9 +0,9 @@

import { Chain, Network, Platform, PlatformToChains } from "@wormhole-foundation/sdk-base";
import { Chain, Network, Platform } from "@wormhole-foundation/sdk-base";
import { AccountAddress, ChainAddress, NativeAddress, UniversalOrNative } from "../address";
import "../payloads/automaticTokenBridge";
import "../payloads/tokenBridge";
import { EmptyPlatformMap } from "../protocol";
import { TokenAddress, TokenId } from "../types";
import { UnsignedTransaction } from "../unsignedTransaction";
import { ProtocolPayload, ProtocolVAA } from "../vaa";
import { EmptyPlatformMap } from "../protocol";
export declare const ErrNotWrapped: (token: string) => Error;

@@ -18,4 +18,8 @@ declare global {

}
/**
* @namespace TokenBridge
*/
export declare namespace TokenBridge {
const _protocol = "TokenBridge";
/** The compile time type of the TokenBridge protocol */
export type ProtocolName = typeof _protocol;

@@ -30,2 +34,3 @@ const _transferPayloads: readonly ["Transfer", "TransferWithPayload"];

export type AttestVAA<PayloadName extends AttestPayloadNames = AttestPayloadNames> = ProtocolVAA<ProtocolName, PayloadName>;
/** The VAAs emitted from the TokenBridge protocol */
export type VAA<PayloadName extends PayloadNames = PayloadNames> = ProtocolVAA<ProtocolName, PayloadName>;

@@ -40,5 +45,7 @@ export type TransferPayload<PayloadName extends TransferPayloadNames = TransferPayloadNames> = ProtocolPayload<ProtocolName, PayloadName>;

const _protocol = "AutomaticTokenBridge";
/** The compile time type of the AutomaticTokenBridge protocol */
export type ProtocolName = typeof _protocol;
const _payloads: readonly ["TransferWithRelay"];
export type PayloadNames = (typeof _payloads)[number];
/** The VAAs emitted from the AutomaticTokenBridge protocol */
export type VAA<PayloadName extends PayloadNames = PayloadNames> = ProtocolVAA<ProtocolName, PayloadName>;

@@ -48,2 +55,5 @@ export type Payload<PayloadName extends PayloadNames = PayloadNames> = ProtocolPayload<ProtocolName, PayloadName>;

}
/**
* Details of a token transfer, used to initiate a transfer
*/
export type TokenTransferDetails = {

@@ -59,23 +69,113 @@ token: TokenId;

export declare function isTokenTransferDetails(thing: TokenTransferDetails | any): thing is TokenTransferDetails;
export interface TokenBridge<N extends Network, P extends Platform, C extends PlatformToChains<P>> {
/**
* TokenBridge protocol definition, providing a consistent client interface
* for the TokenBridge protocol
*
* Find details on the TokenBridge protocol here: {@link https://github.com/wormhole-foundation/wormhole/blob/main/whitepapers/0003_token_bridge.md}
*
*/
export interface TokenBridge<N extends Network, C extends Chain> {
/** Checks a native address to see if its a wrapped version
*
* @param nativeAddress The address to check
* @returns true if the address is a wrapped version of a foreign token
*/
isWrappedAsset(nativeAddress: TokenAddress<C>): Promise<boolean>;
/**
* returns the original asset with its foreign chain
*
* @param nativeAddress The wrapped address to check
* @returns The TokenId corresponding to the original asset and chain
*/
getOriginalAsset(nativeAddress: TokenAddress<C>): Promise<TokenId<Chain>>;
/**
* returns the wrapped version of the native asset
*
* @returns The address of the native gas token that has been wrapped
* for use where the gas token is not possible to use (e.g. bridging)
*/
getWrappedNative(): Promise<NativeAddress<C>>;
/**
* Check to see if a foreign token has a wrapped version
*
* @param foreignToken The token to check
* @returns true if the token has a wrapped version
*/
hasWrappedAsset(foreignToken: TokenId<Chain>): Promise<boolean>;
/**
* Returns the address of the native version of this asset
*
* @param foreignToken The token to check
* @returns The address of the native version of this asset
*/
getWrappedAsset(foreignToken: TokenId<Chain>): Promise<NativeAddress<C>>;
/**
* Checks if a transfer VAA has been redeemed
*
* @param vaa The transfer VAA to check
* @returns true if the transfer has been redeemed
*/
isTransferCompleted(vaa: TokenBridge.TransferVAA): Promise<boolean>;
/**
* Create a Token Attestation VAA containing metadata about
* the token that may be submitted to a Token bridge on another chain
* to allow it to create a wrapped version of the token
*
* @param token The token to create an attestation for
* @param payer The payer of the transaction
* @returns An AsyncGenerator that produces transactions to sign and send
*/
createAttestation(token: TokenAddress<C>, payer?: UniversalOrNative<C>): AsyncGenerator<UnsignedTransaction<N, C>>;
/**
* Submit the Token Attestation VAA to the Token bridge
* to create the wrapped token represented by the data in the VAA
* @param vaa The attestation VAA to submit
* @param payer The payer of the transaction
* @returns An AsyncGenerator that produces transactions to sign and send
*/
submitAttestation(vaa: TokenBridge.AttestVAA, payer?: UniversalOrNative<C>): AsyncGenerator<UnsignedTransaction<N, C>>;
/**
* Initiate a transfer of some token to another chain
*
* @param sender The sender of the transfer
* @param recipient The recipient of the transfer as a ChainAddress so we know what the destination chain should be
* @param token The token to transfer
* @param amount The amount of the token to transfer
* @param payload Optional payload to include in the transfer
* @returns An AsyncGenerator that produces transactions to sign and send
*/
transfer(sender: AccountAddress<C>, recipient: ChainAddress, token: TokenAddress<C>, amount: bigint, payload?: Uint8Array): AsyncGenerator<UnsignedTransaction<N, C>>;
/**
* Redeem a transfer VAA to receive the tokens on this chain
*
* @param sender The sender of the transfer
* @param vaa The transfer VAA to redeem
* @param unwrapNative Whether to unwrap the native token if it is a wrapped token
* @returns An AsyncGenerator that produces transactions to sign and send
*/
redeem(sender: AccountAddress<C>, vaa: TokenBridge.TransferVAA, unwrapNative?: boolean): AsyncGenerator<UnsignedTransaction<N, C>>;
}
export interface AutomaticTokenBridge<N extends Network, P extends Platform, C extends PlatformToChains<P>> {
/**
* AutomaticTokenBridge provides a consistent interface to the
* TokenBridge with Automatic redemption on the destination chain
*/
export interface AutomaticTokenBridge<N extends Network, C extends Chain> {
/** Initiate the transfer over the automatic bridge */
transfer(sender: AccountAddress<C>, recipient: ChainAddress, token: TokenAddress<C>, amount: bigint, nativeGas?: bigint): AsyncGenerator<UnsignedTransaction<N, C>>;
/**
* Manually redeem a transfer, should not be used unless
* necessary to take over some stalled transfer
*/
redeem(sender: AccountAddress<C>, vaa: AutomaticTokenBridge.VAA): AsyncGenerator<UnsignedTransaction<N, C>>;
/** Fee charged to relay */
getRelayerFee(sender: AccountAddress<C>, recipient: ChainAddress, token: TokenAddress<C>): Promise<bigint>;
/** Check if a given token is in the registered token list */
isRegisteredToken(token: TokenAddress<C>): Promise<boolean>;
/** Get the list of tokens that are registered and acceptable to send */
getRegisteredTokens(): Promise<NativeAddress<C>[]>;
/** Amount of native tokens a user would receive by swapping x amount of sending tokens */
nativeTokenAmount(token: TokenAddress<C>, amount: bigint): Promise<bigint>;
/** Maximum amount of sending tokens that can be swapped for native tokens */
maxSwapAmount(token: TokenAddress<C>): Promise<bigint>;
}
//# sourceMappingURL=tokenBridge.d.ts.map

@@ -1,2 +0,2 @@

import { lazyInstantiate, } from "@wormhole-foundation/sdk-base";
import { lazyInstantiate } from "@wormhole-foundation/sdk-base";
import "../payloads/automaticTokenBridge";

@@ -6,2 +6,5 @@ import "../payloads/tokenBridge";

export const ErrNotWrapped = (token) => new Error(`Token ${token} is not a wrapped asset`);
/**
* @namespace TokenBridge
*/
export var TokenBridge;

@@ -8,0 +11,0 @@ (function (TokenBridge) {

@@ -0,1 +1,2 @@

/** Signature represents the secp256k1 signature of a Guardian */
export declare class Signature {

@@ -2,0 +3,0 @@ readonly r: bigint;

@@ -1,4 +0,3 @@

// Signature represents the secp256k1 signature of a Guardian
import { signatureItem } from "./layout-items";
// use layout-items/signature.ts to serialize/deserialize
/** Signature represents the secp256k1 signature of a Guardian */
export class Signature {

@@ -5,0 +4,0 @@ r;

import { Chain, Network } from "@wormhole-foundation/sdk-base";
import { SignedTx, TxHash } from "./types";
import { UnsignedTransaction } from "./unsignedTransaction";
/**
* A Signer is an interface that must be provided to certain methods
* in the SDK to sign transactions. It can be either a SignOnlySigner
* or a SignAndSendSigner depending on circumstances.
* A Signer can be implemented by wrapping an existing offline wallet
* or a web wallet
*/
export type Signer<N extends Network = Network, C extends Chain = Chain> = SignOnlySigner<N, C> | SignAndSendSigner<N, C>;

@@ -10,2 +17,7 @@ export declare function isSigner(thing: any): thing is Signer<Network, Chain>;

}
/**
* A SignOnlySender is for situations where the signer is not
* connected to the network or does not wish to broadcast the
* transactions themselves
*/
export interface SignOnlySigner<N extends Network, C extends Chain> extends SignerBase<C> {

@@ -15,2 +27,7 @@ sign(tx: UnsignedTransaction<N, C>[]): Promise<SignedTx[]>;

export declare function isSignOnlySigner(thing: any): thing is SignOnlySigner<Network, Chain>;
/**
* A SignAndSendSigner is for situations where the signer is
* connected to the network and wishes to broadcast the
* transactions themselves
*/
export interface SignAndSendSigner<N extends Network, C extends Chain> extends SignerBase<C> {

@@ -21,2 +38,7 @@ signAndSend(tx: UnsignedTransaction<N, C>[]): Promise<TxHash[]>;

export type NativeSigner = any;
/**
* A PlatformNativeSigner should allow wrapping and unwrapping of a platform specific Signer
* so that the underlying native signer may be used by unwrapping it where needed
*
*/
export declare abstract class PlatformNativeSigner<NS extends NativeSigner, N extends Network = Network, C extends Chain = Chain> {

@@ -23,0 +45,0 @@ protected _chain: C;

@@ -22,2 +22,7 @@ export function isSigner(thing) {

}
/**
* A PlatformNativeSigner should allow wrapping and unwrapping of a platform specific Signer
* so that the underlying native signer may be used by unwrapping it where needed
*
*/
export class PlatformNativeSigner {

@@ -24,0 +29,0 @@ _chain;

import { Chain, Network, Platform, PlatformToChains } from "@wormhole-foundation/sdk-base";
import { ChainToPlatform } from "@wormhole-foundation/sdk-base/src";
import { ChainContext, PlatformContext } from "../..";
export declare function chainFactory<N extends Network, P extends Platform, C extends PlatformToChains<P>>(p: PlatformContext<N, P>, chain: C): ChainContext<N, P, C>;
export declare class MockChain<N extends Network, P extends Platform, C extends Chain = PlatformToChains<P>> extends ChainContext<N, P, C> {
constructor(chain: C, platform: PlatformContext<N, P>);
export declare function chainFactory<N extends Network, P extends Platform, C extends PlatformToChains<P>>(p: PlatformContext<N, P>, chain: C): ChainContext<N, C>;
export declare class MockChain<N extends Network, C extends Chain = Chain> extends ChainContext<N, C> {
constructor(chain: C, platform: PlatformContext<N, ChainToPlatform<C>>);
}
//# sourceMappingURL=chain.d.ts.map

@@ -1,3 +0,3 @@

import { Chain, Network, Platform, PlatformToChains } from "@wormhole-foundation/sdk-base";
import { ChainContext, ChainsConfig, PlatformContext, PlatformUtils, RpcConnection, TokenAddress, TokenId, ProtocolName } from "../..";
import { Network, Platform, PlatformToChains } from "@wormhole-foundation/sdk-base";
import { ChainContext, ChainsConfig, PlatformContext, PlatformUtils, ProtocolName, RpcConnection, TokenAddress, TokenId } from "../..";
export declare function mockPlatformFactory<N extends Network, P extends Platform>(platform: P, config: ChainsConfig<N, P>): PlatformUtils<P>;

@@ -7,3 +7,3 @@ export declare class MockPlatform<N extends Network, P extends Platform> extends PlatformContext<N, P> {

static getProtocol<PN extends ProtocolName, T extends any>(protocol: PN): T;
getChain<C extends Chain>(chain: C): ChainContext<N, P, C>;
getChain<C extends PlatformToChains<P>>(chain: C): ChainContext<N, C>;
getRpc<C extends PlatformToChains<P>>(chain: C): RpcConnection<P>;

@@ -10,0 +10,0 @@ getWrappedAsset<C extends PlatformToChains<P>>(chain: C, rpc: RpcConnection<P>, token: TokenId<C>): Promise<TokenId<C> | null>;

@@ -72,2 +72,3 @@ import { PlatformContext, } from "../..";

getChain(chain) {
// @ts-ignore
if (chain in this.config)

@@ -74,0 +75,0 @@ return new MockChain(chain, this);

@@ -1,4 +0,4 @@

import { PlatformToChains, Network, Platform } from "@wormhole-foundation/sdk-base";
import { TokenAddress, ChainAddress, NativeAddress, RpcConnection, TokenBridge, UnsignedTransaction } from "../..";
export declare class MockTokenBridge<N extends Network, P extends Platform, C extends PlatformToChains<P>> implements TokenBridge<N, P, C> {
import { Network, Platform, PlatformToChains } from "@wormhole-foundation/sdk-base";
import { ChainAddress, NativeAddress, RpcConnection, TokenAddress, TokenBridge, UnsignedTransaction } from "../..";
export declare class MockTokenBridge<N extends Network, P extends Platform, C extends PlatformToChains<P>> implements TokenBridge<N, C> {
readonly rpc: RpcConnection<P>;

@@ -5,0 +5,0 @@ constructor(rpc: RpcConnection<P>);

@@ -5,5 +5,5 @@ import { Chain } from "@wormhole-foundation/sdk-base";

export declare function makeChainAddress<C extends Chain>(chain: C): ChainAddress<C>;
export declare function makeUniversalChainAddress(chain: Chain): ChainAddress<Chain>;
export declare function makeUniversalChainAddress<C extends Chain>(chain: C): ChainAddress<C>;
export declare function makeUniversalAddress(chain: Chain): UniversalAddress;
export declare function makeNativeAddress<T extends Chain>(chain: T): NativeAddress<T>;
//# sourceMappingURL=address.d.ts.map
import { Chain, ChainToPlatform, Network, Platform, PlatformToChains, explorer, tokens } from "@wormhole-foundation/sdk-base";
import { ChainAddress, UniversalOrNative } from "./address";
import { Contracts } from "./contracts";
/** Alias for string, used to look up transaction details */
export type TxHash = string;
/** The sequence number assigned to a given message by the core bridge */
export type SequenceId = bigint;
/** A signed transaction in its canonical format */
export type SignedTx = any;
/**
* An address representing an asset
* @remarks the string literal 'native' is used to represent the native gas token
*/
export type TokenAddress<C extends Chain> = UniversalOrNative<C> | "native";
export declare function isNative(thing: any): thing is "native";
/** Utility to create a TokenId with the address set to the string "native" */
export declare function nativeTokenId<C extends Chain>(chain: C): TokenId<C>;
/**
* A TokenId is a unique identifier for a token on a given chain
*
* @interface TokenId
*/
export type TokenId<C extends Chain = Chain> = {

@@ -16,3 +29,8 @@ chain: C;

export declare function isSameToken(a: TokenId, b: TokenId): boolean;
/** Utility function to return the string representation of a ChainAddress or TokenId */
export declare function canonicalAddress(ca: ChainAddress | TokenId): string;
/**
* Given a token id, address, or the const string 'native' return
* a TokenId representing either the token itself or the wrapped version
*/
export declare function resolveWrappedToken<N extends Network, C extends Chain>(network: N, chain: C, token: TokenId<C> | TokenAddress<C>): [boolean, TokenId<C>];

@@ -22,2 +40,3 @@ export type Balances = {

};
/** Fully qualified Transaction ID */
export type TransactionId<C extends Chain = Chain> = {

@@ -28,2 +47,3 @@ chain: C;

export declare function isTransactionIdentifier(thing: TransactionId | any): thing is TransactionId;
/** Configuration for a given Chain */
export type ChainConfig<N extends Network, C extends Chain> = {

@@ -33,8 +53,20 @@ key: C;

platform: ChainToPlatform<C>;
/** Wormhole Chain Id for this chain */
chainId: number;
/** Contract addresses for this chain */
contracts: Contracts;
/** Number of blocks before a transaction is considered final */
finalityThreshold: number;
/** Average block time in milliseconds */
blockTime: number;
/** Number of decimal places for the native gas token (e.g. 18 for ETH) */
nativeTokenDecimals: number;
/**
* Native chain id may be eip155 or genesis hash or network moninker or something else
* depending on the platform
*/
nativeChainId: string | bigint;
/**
* Rpc address for this chain
*/
rpc: string;

@@ -41,0 +73,0 @@ tokenMap?: tokens.ChainTokens;

@@ -9,3 +9,3 @@ import { chainToPlatform, chains, decimals, explorer, finality, isChain, nativeChainIds, rpc, toChainId, tokens, } from "@wormhole-foundation/sdk-base";

}
// Utility to create a TokenId with the address set to the string "native"
/** Utility to create a TokenId with the address set to the string "native" */
export function nativeTokenId(chain) {

@@ -27,2 +27,3 @@ return { chain, address: "native" };

}
/** Utility function to return the string representation of a ChainAddress or TokenId */
export function canonicalAddress(ca) {

@@ -34,4 +35,6 @@ if (isTokenId(ca) && isNative(ca.address))

}
// Given a token id, address, or the const string 'native' return
// a TokenId representing either the token itself or the wrapped version
/**
* Given a token id, address, or the const string 'native' return
* a TokenId representing either the token itself or the wrapped version
*/
export function resolveWrappedToken(network, chain, token) {

@@ -38,0 +41,0 @@ let tokenAddr;

import { PlatformAddressFormat } from "@wormhole-foundation/sdk-base";
import { Address, NativeAddress, toNative } from "./address";
/**
* The UniversalAddress represents an address that has been parsed into its
* byte representation and possibly modified to ensure it is exactly 32 bytes long
*/
export declare class UniversalAddress implements Address {

@@ -4,0 +8,0 @@ static readonly byteSize = 32;

@@ -8,2 +8,6 @@ import { encoding, serializeLayout, throws, } from "@wormhole-foundation/sdk-base";

];
/**
* The UniversalAddress represents an address that has been parsed into its
* byte representation and possibly modified to ensure it is exactly 32 bytes long
*/
export class UniversalAddress {

@@ -10,0 +14,0 @@ static byteSize = 32;

import { Chain, Network } from "@wormhole-foundation/sdk-base";
/**
* An unsigned transaction is a transaction that has not been signed
* along with details about the transaction
*/
export interface UnsignedTransaction<N extends Network = Network, C extends Chain = Chain> {

@@ -3,0 +7,0 @@ readonly transaction: any;

@@ -129,2 +129,9 @@ import { LayoutToType } from "@wormhole-foundation/sdk-base";

type VAABase = LayoutToType<typeof baseLayout>;
/**
* A VAA is a Verifiable Action Assertion, a signed message that contains
* information about an action that has occurred on a chain.
*
* See {@link https://docs.wormhole.com/wormhole/explore-wormhole/vaa | this link} for more.
*
*/
export interface VAA<PL extends PayloadLiteral = PayloadLiteral> extends VAABase {

@@ -138,2 +145,3 @@ readonly protocolName: DecomposeLiteral<PL>[0];

export type DistributiveVAA<PL extends PayloadLiteral> = PL extends PayloadLiteral ? VAA<PL> : never;
/** A utility type that maps a protocol and payload name to its defined structure */
export type ProtocolVAA<PN extends ProtocolName, PayloadName extends string> = ComposeLiteral<PN, PayloadName, PayloadLiteral> extends infer PL extends PayloadLiteral ? DistributiveVAA<PL> : never;

@@ -140,0 +148,0 @@ export type DistributivePayload<PL extends PayloadLiteral> = PL extends PayloadLiteral ? Payload<PL> : never;

{
"name": "@wormhole-foundation/sdk-definitions",
"version": "0.4.0-beta.9",
"version": "0.4.0-beta.10",
"repository": {

@@ -33,4 +33,4 @@ "type": "git",

"@noble/hashes": "^1.3.1",
"@wormhole-foundation/sdk-base": "^0.4.0-beta.9"
"@wormhole-foundation/sdk-base": "^0.4.0-beta.10"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc