@wormhole-foundation/sdk-definitions 0.5.0-alpha.2 → 0.5.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/address.d.ts +49 -0
- package/dist/cjs/address.d.ts.map +1 -0
- package/dist/cjs/address.js +40 -0
- package/dist/cjs/address.js.map +1 -0
- package/dist/cjs/attestation.d.ts +52 -0
- package/dist/cjs/attestation.d.ts.map +1 -0
- package/dist/cjs/attestation.js +23 -0
- package/dist/cjs/attestation.js.map +1 -0
- package/dist/cjs/chain.d.ts +186 -0
- package/dist/cjs/chain.d.ts.map +1 -0
- package/dist/cjs/chain.js +267 -0
- package/dist/cjs/chain.js.map +1 -0
- package/dist/cjs/contracts.d.ts +24 -0
- package/dist/cjs/contracts.d.ts.map +1 -0
- package/dist/cjs/contracts.js +36 -0
- package/dist/cjs/contracts.js.map +1 -0
- package/dist/cjs/index.d.ts +18 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +47 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/layout-items/amount.d.ts +5 -0
- package/dist/cjs/layout-items/amount.d.ts.map +1 -0
- package/dist/cjs/layout-items/amount.js +8 -0
- package/dist/cjs/layout-items/amount.js.map +1 -0
- package/dist/cjs/layout-items/chain.d.ts +67 -0
- package/dist/cjs/layout-items/chain.d.ts.map +1 -0
- package/dist/cjs/layout-items/chain.js +33 -0
- package/dist/cjs/layout-items/chain.js.map +1 -0
- package/dist/cjs/layout-items/circle.d.ts +9 -0
- package/dist/cjs/layout-items/circle.d.ts.map +1 -0
- package/dist/cjs/layout-items/circle.js +12 -0
- package/dist/cjs/layout-items/circle.js.map +1 -0
- package/dist/cjs/layout-items/guardianSet.d.ts +5 -0
- package/dist/cjs/layout-items/guardianSet.d.ts.map +1 -0
- package/dist/cjs/layout-items/guardianSet.js +8 -0
- package/dist/cjs/layout-items/guardianSet.js.map +1 -0
- package/dist/cjs/layout-items/index.d.ts +9 -0
- package/dist/cjs/layout-items/index.d.ts.map +1 -0
- package/dist/cjs/layout-items/index.js +25 -0
- package/dist/cjs/layout-items/index.js.map +1 -0
- package/dist/cjs/layout-items/payloadId.d.ts +8 -0
- package/dist/cjs/layout-items/payloadId.d.ts.map +1 -0
- package/dist/cjs/layout-items/payloadId.js +12 -0
- package/dist/cjs/layout-items/payloadId.js.map +1 -0
- package/dist/cjs/layout-items/sequence.d.ts +5 -0
- package/dist/cjs/layout-items/sequence.d.ts.map +1 -0
- package/dist/cjs/layout-items/sequence.js +8 -0
- package/dist/cjs/layout-items/sequence.js.map +1 -0
- package/dist/cjs/layout-items/signature.d.ts +41 -0
- package/dist/cjs/layout-items/signature.d.ts.map +1 -0
- package/dist/cjs/layout-items/signature.js +18 -0
- package/dist/cjs/layout-items/signature.js.map +1 -0
- package/dist/cjs/layout-items/universalAddress.d.ts +10 -0
- package/dist/cjs/layout-items/universalAddress.d.ts.map +1 -0
- package/dist/cjs/layout-items/universalAddress.js +13 -0
- package/dist/cjs/layout-items/universalAddress.js.map +1 -0
- package/dist/cjs/platform.d.ts +65 -0
- package/dist/cjs/platform.d.ts.map +1 -0
- package/dist/cjs/platform.js +30 -0
- package/dist/cjs/platform.js.map +1 -0
- package/dist/cjs/protocol.d.ts +19 -0
- package/dist/cjs/protocol.d.ts.map +1 -0
- package/dist/cjs/protocol.js +41 -0
- package/dist/cjs/protocol.js.map +1 -0
- package/dist/cjs/protocols/circleBridge/automaticCircleBridgeLayout.d.ts +217 -0
- package/dist/cjs/protocols/circleBridge/automaticCircleBridgeLayout.d.ts.map +1 -0
- package/dist/cjs/protocols/circleBridge/automaticCircleBridgeLayout.js +41 -0
- package/dist/cjs/protocols/circleBridge/automaticCircleBridgeLayout.js.map +1 -0
- package/dist/cjs/protocols/circleBridge/circleBridge.d.ts +126 -0
- package/dist/cjs/protocols/circleBridge/circleBridge.d.ts.map +1 -0
- package/dist/cjs/protocols/circleBridge/circleBridge.js +38 -0
- package/dist/cjs/protocols/circleBridge/circleBridge.js.map +1 -0
- package/dist/cjs/protocols/circleBridge/circleBridgeLayout.d.ts +172 -0
- package/dist/cjs/protocols/circleBridge/circleBridgeLayout.d.ts.map +1 -0
- package/dist/cjs/protocols/circleBridge/circleBridgeLayout.js +38 -0
- package/dist/cjs/protocols/circleBridge/circleBridgeLayout.js.map +1 -0
- package/dist/cjs/protocols/circleBridge/index.d.ts +5 -0
- package/dist/cjs/protocols/circleBridge/index.d.ts.map +1 -0
- package/dist/cjs/protocols/circleBridge/index.js +20 -0
- package/dist/cjs/protocols/circleBridge/index.js.map +1 -0
- package/dist/cjs/protocols/core/core.d.ts +63 -0
- package/dist/cjs/protocols/core/core.d.ts.map +1 -0
- package/dist/cjs/protocols/core/core.js +4 -0
- package/dist/cjs/protocols/core/core.js.map +1 -0
- package/dist/cjs/protocols/core/governanceLayout.d.ts +590 -0
- package/dist/cjs/protocols/core/governanceLayout.d.ts.map +1 -0
- package/dist/cjs/protocols/core/governanceLayout.js +194 -0
- package/dist/cjs/protocols/core/governanceLayout.js.map +1 -0
- package/dist/cjs/protocols/core/index.d.ts +3 -0
- package/dist/cjs/protocols/core/index.d.ts.map +1 -0
- package/dist/cjs/protocols/core/index.js +18 -0
- package/dist/cjs/protocols/core/index.js.map +1 -0
- package/dist/cjs/protocols/ibc/ibc.d.ts +94 -0
- package/dist/cjs/protocols/ibc/ibc.d.ts.map +1 -0
- package/dist/cjs/protocols/ibc/ibc.js +79 -0
- package/dist/cjs/protocols/ibc/ibc.js.map +1 -0
- package/dist/cjs/protocols/ibc/index.d.ts +3 -0
- package/dist/cjs/protocols/ibc/index.d.ts.map +1 -0
- package/dist/cjs/protocols/ibc/index.js +18 -0
- package/dist/cjs/protocols/ibc/index.js.map +1 -0
- package/dist/cjs/protocols/index.d.ts +8 -0
- package/dist/cjs/protocols/index.d.ts.map +1 -0
- package/dist/cjs/protocols/index.js +24 -0
- package/dist/cjs/protocols/index.js.map +1 -0
- package/dist/cjs/protocols/nftBridge/index.d.ts +2 -0
- package/dist/cjs/protocols/nftBridge/index.d.ts.map +1 -0
- package/dist/cjs/protocols/nftBridge/index.js +18 -0
- package/dist/cjs/protocols/nftBridge/index.js.map +1 -0
- package/dist/cjs/protocols/nftBridge/nftBridge.d.ts +11 -0
- package/dist/cjs/protocols/nftBridge/nftBridge.d.ts.map +1 -0
- package/dist/cjs/protocols/nftBridge/nftBridge.js +4 -0
- package/dist/cjs/protocols/nftBridge/nftBridge.js.map +1 -0
- package/dist/cjs/protocols/ntt/index.d.ts +4 -0
- package/dist/cjs/protocols/ntt/index.d.ts.map +1 -0
- package/dist/cjs/protocols/ntt/index.js +19 -0
- package/dist/cjs/protocols/ntt/index.js.map +1 -0
- package/dist/cjs/protocols/ntt/ntt.d.ts +43 -0
- package/dist/cjs/protocols/ntt/ntt.d.ts.map +1 -0
- package/dist/cjs/protocols/ntt/ntt.js +15 -0
- package/dist/cjs/protocols/ntt/ntt.js.map +1 -0
- package/dist/cjs/protocols/ntt/nttLayout.d.ts +223 -0
- package/dist/cjs/protocols/ntt/nttLayout.d.ts.map +1 -0
- package/dist/cjs/protocols/ntt/nttLayout.js +42 -0
- package/dist/cjs/protocols/ntt/nttLayout.js.map +1 -0
- package/dist/cjs/protocols/portico/index.d.ts +3 -0
- package/dist/cjs/protocols/portico/index.d.ts.map +1 -0
- package/dist/cjs/protocols/portico/index.js +19 -0
- package/dist/cjs/protocols/portico/index.js.map +1 -0
- package/dist/cjs/protocols/portico/portico.d.ts +58 -0
- package/dist/cjs/protocols/portico/portico.d.ts.map +1 -0
- package/dist/cjs/protocols/portico/portico.js +25 -0
- package/dist/cjs/protocols/portico/portico.js.map +1 -0
- package/dist/cjs/protocols/portico/porticoLayout.d.ts +229 -0
- package/dist/cjs/protocols/portico/porticoLayout.d.ts.map +1 -0
- package/dist/cjs/protocols/portico/porticoLayout.js +41 -0
- package/dist/cjs/protocols/portico/porticoLayout.js.map +1 -0
- package/dist/cjs/protocols/relayer/index.d.ts +3 -0
- package/dist/cjs/protocols/relayer/index.d.ts.map +1 -0
- package/dist/cjs/protocols/relayer/index.js +18 -0
- package/dist/cjs/protocols/relayer/index.js.map +1 -0
- package/dist/cjs/protocols/relayer/relayer.d.ts +20 -0
- package/dist/cjs/protocols/relayer/relayer.d.ts.map +1 -0
- package/dist/cjs/protocols/relayer/relayer.js +4 -0
- package/dist/cjs/protocols/relayer/relayer.js.map +1 -0
- package/dist/cjs/protocols/relayer/relayerLayout.d.ts +411 -0
- package/dist/cjs/protocols/relayer/relayerLayout.d.ts.map +1 -0
- package/dist/cjs/protocols/relayer/relayerLayout.js +75 -0
- package/dist/cjs/protocols/relayer/relayerLayout.js.map +1 -0
- package/dist/cjs/protocols/tokenBridge/automaticTokenBridgeLayout.d.ts +115 -0
- package/dist/cjs/protocols/tokenBridge/automaticTokenBridgeLayout.d.ts.map +1 -0
- package/dist/cjs/protocols/tokenBridge/automaticTokenBridgeLayout.js +21 -0
- package/dist/cjs/protocols/tokenBridge/automaticTokenBridgeLayout.js.map +1 -0
- package/dist/cjs/protocols/tokenBridge/index.d.ts +5 -0
- package/dist/cjs/protocols/tokenBridge/index.d.ts.map +1 -0
- package/dist/cjs/protocols/tokenBridge/index.js +20 -0
- package/dist/cjs/protocols/tokenBridge/index.js.map +1 -0
- package/dist/cjs/protocols/tokenBridge/tokenBridge.d.ts +177 -0
- package/dist/cjs/protocols/tokenBridge/tokenBridge.d.ts.map +1 -0
- package/dist/cjs/protocols/tokenBridge/tokenBridge.js +34 -0
- package/dist/cjs/protocols/tokenBridge/tokenBridge.js.map +1 -0
- package/dist/cjs/protocols/tokenBridge/tokenBridgeLayout.d.ts +231 -0
- package/dist/cjs/protocols/tokenBridge/tokenBridgeLayout.d.ts.map +1 -0
- package/dist/cjs/protocols/tokenBridge/tokenBridgeLayout.js +65 -0
- package/dist/cjs/protocols/tokenBridge/tokenBridgeLayout.js.map +1 -0
- package/dist/cjs/registry.d.ts +9 -0
- package/dist/cjs/registry.d.ts.map +1 -0
- package/dist/cjs/registry.js +3 -0
- package/dist/cjs/registry.js.map +1 -0
- package/dist/cjs/rpc.d.ts +3 -0
- package/dist/cjs/rpc.d.ts.map +1 -0
- package/dist/cjs/rpc.js +3 -0
- package/dist/cjs/rpc.js.map +1 -0
- package/dist/cjs/signature.d.ts +10 -0
- package/dist/cjs/signature.d.ts.map +1 -0
- package/dist/cjs/signature.js +24 -0
- package/dist/cjs/signature.js.map +1 -0
- package/dist/cjs/signer.d.ts +53 -0
- package/dist/cjs/signer.d.ts.map +1 -0
- package/dist/cjs/signer.js +51 -0
- package/dist/cjs/signer.js.map +1 -0
- package/dist/cjs/testing/index.d.ts +3 -0
- package/dist/cjs/testing/index.d.ts.map +1 -0
- package/dist/cjs/testing/index.js +29 -0
- package/dist/cjs/testing/index.js.map +1 -0
- package/dist/cjs/testing/mocks/api.d.ts +7 -0
- package/dist/cjs/testing/mocks/api.d.ts.map +1 -0
- package/dist/cjs/testing/mocks/api.js +14 -0
- package/dist/cjs/testing/mocks/api.js.map +1 -0
- package/dist/cjs/testing/mocks/chain.d.ts +8 -0
- package/dist/cjs/testing/mocks/chain.d.ts.map +1 -0
- package/dist/cjs/testing/mocks/chain.js +15 -0
- package/dist/cjs/testing/mocks/chain.js.map +1 -0
- package/dist/cjs/testing/mocks/index.d.ts +5 -0
- package/dist/cjs/testing/mocks/index.d.ts.map +1 -0
- package/dist/cjs/testing/mocks/index.js +21 -0
- package/dist/cjs/testing/mocks/index.js.map +1 -0
- package/dist/cjs/testing/mocks/platform.d.ts +15 -0
- package/dist/cjs/testing/mocks/platform.d.ts.map +1 -0
- package/dist/cjs/testing/mocks/platform.js +98 -0
- package/dist/cjs/testing/mocks/platform.js.map +1 -0
- package/dist/cjs/testing/mocks/rpc.d.ts +7 -0
- package/dist/cjs/testing/mocks/rpc.d.ts.map +1 -0
- package/dist/cjs/testing/mocks/rpc.js +14 -0
- package/dist/cjs/testing/mocks/rpc.js.map +1 -0
- package/dist/cjs/testing/mocks/tokenBridge.d.ts +17 -0
- package/dist/cjs/testing/mocks/tokenBridge.d.ts.map +1 -0
- package/dist/cjs/testing/mocks/tokenBridge.js +41 -0
- package/dist/cjs/testing/mocks/tokenBridge.js.map +1 -0
- package/dist/cjs/testing/utils/address.d.ts +9 -0
- package/dist/cjs/testing/utils/address.d.ts.map +1 -0
- package/dist/cjs/testing/utils/address.js +68 -0
- package/dist/cjs/testing/utils/address.js.map +1 -0
- package/dist/cjs/testing/utils/index.d.ts +3 -0
- package/dist/cjs/testing/utils/index.d.ts.map +1 -0
- package/dist/cjs/testing/utils/index.js +25 -0
- package/dist/cjs/testing/utils/index.js.map +1 -0
- package/dist/cjs/testing/utils/vaa.d.ts +10 -0
- package/dist/cjs/testing/utils/vaa.d.ts.map +1 -0
- package/dist/cjs/testing/utils/vaa.js +16 -0
- package/dist/cjs/testing/utils/vaa.js.map +1 -0
- package/dist/cjs/types.d.ts +79 -0
- package/dist/cjs/types.d.ts.map +1 -0
- package/dist/cjs/types.js +116 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/cjs/universalAddress.d.ts +23 -0
- package/dist/cjs/universalAddress.d.ts.map +1 -0
- package/dist/cjs/universalAddress.js +74 -0
- package/dist/cjs/universalAddress.js.map +1 -0
- package/dist/cjs/unsignedTransaction.d.ts +13 -0
- package/dist/cjs/unsignedTransaction.d.ts.map +1 -0
- package/dist/cjs/unsignedTransaction.js +3 -0
- package/dist/cjs/unsignedTransaction.js.map +1 -0
- package/dist/cjs/utils.d.ts +5 -0
- package/dist/cjs/utils.d.ts.map +1 -0
- package/dist/cjs/utils.js +12 -0
- package/dist/cjs/utils.js.map +1 -0
- package/dist/cjs/vaa/create.d.ts +8 -0
- package/dist/cjs/vaa/create.d.ts.map +1 -0
- package/dist/cjs/vaa/create.js +27 -0
- package/dist/cjs/vaa/create.js.map +1 -0
- package/dist/cjs/vaa/functions.d.ts +33 -0
- package/dist/cjs/vaa/functions.d.ts.map +1 -0
- package/dist/cjs/vaa/functions.js +132 -0
- package/dist/cjs/vaa/functions.js.map +1 -0
- package/dist/cjs/vaa/index.d.ts +5 -0
- package/dist/cjs/vaa/index.d.ts.map +1 -0
- package/dist/cjs/vaa/index.js +21 -0
- package/dist/cjs/vaa/index.js.map +1 -0
- package/dist/cjs/vaa/registration.d.ts +19 -0
- package/dist/cjs/vaa/registration.d.ts.map +1 -0
- package/dist/cjs/vaa/registration.js +19 -0
- package/dist/cjs/vaa/registration.js.map +1 -0
- package/dist/cjs/vaa/vaa.d.ts +190 -0
- package/dist/cjs/vaa/vaa.d.ts.map +1 -0
- package/dist/cjs/vaa/vaa.js +31 -0
- package/dist/cjs/vaa/vaa.js.map +1 -0
- package/dist/esm/index.d.ts +16 -25
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +16 -13
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/layout-items/chain.d.ts +2 -2
- package/dist/esm/layout-items/index.d.ts +8 -8
- package/dist/esm/layout-items/index.d.ts.map +1 -1
- package/dist/esm/layout-items/index.js +8 -8
- package/dist/esm/layout-items/index.js.map +1 -1
- package/dist/esm/protocol.d.ts +1 -1
- package/dist/esm/protocols/circleBridge/index.d.ts +4 -4
- package/dist/esm/protocols/circleBridge/index.d.ts.map +1 -1
- package/dist/esm/protocols/circleBridge/index.js +3 -3
- package/dist/esm/protocols/circleBridge/index.js.map +1 -1
- package/dist/esm/protocols/core/governanceLayout.d.ts +42 -42
- package/dist/esm/protocols/ibc/index.d.ts +2 -2
- package/dist/esm/protocols/ibc/index.d.ts.map +1 -1
- package/dist/esm/protocols/ibc/index.js +1 -1
- package/dist/esm/protocols/ibc/index.js.map +1 -1
- package/dist/esm/protocols/index.d.ts +7 -12
- package/dist/esm/protocols/index.d.ts.map +1 -1
- package/dist/esm/protocols/index.js +7 -6
- package/dist/esm/protocols/index.js.map +1 -1
- package/dist/esm/protocols/ntt/index.d.ts +3 -3
- package/dist/esm/protocols/ntt/index.d.ts.map +1 -1
- package/dist/esm/protocols/ntt/index.js +2 -2
- package/dist/esm/protocols/ntt/index.js.map +1 -1
- package/dist/esm/protocols/ntt/nttLayout.d.ts +4 -4
- package/dist/esm/protocols/portico/index.d.ts +2 -2
- package/dist/esm/protocols/portico/index.d.ts.map +1 -1
- package/dist/esm/protocols/portico/index.js +2 -2
- package/dist/esm/protocols/portico/index.js.map +1 -1
- package/dist/esm/protocols/relayer/index.d.ts +2 -2
- package/dist/esm/protocols/relayer/index.d.ts.map +1 -1
- package/dist/esm/protocols/relayer/index.js +1 -1
- package/dist/esm/protocols/relayer/index.js.map +1 -1
- package/dist/esm/protocols/relayer/relayerLayout.d.ts +16 -16
- package/dist/esm/protocols/tokenBridge/automaticTokenBridgeLayout.d.ts +4 -4
- package/dist/esm/protocols/tokenBridge/index.d.ts +4 -4
- package/dist/esm/protocols/tokenBridge/index.d.ts.map +1 -1
- package/dist/esm/protocols/tokenBridge/index.js +3 -3
- package/dist/esm/protocols/tokenBridge/index.js.map +1 -1
- package/dist/esm/protocols/tokenBridge/tokenBridgeLayout.d.ts +14 -14
- package/dist/esm/testing/mocks/index.d.ts +4 -4
- package/dist/esm/testing/mocks/index.d.ts.map +1 -1
- package/dist/esm/testing/mocks/index.js +4 -4
- package/dist/esm/testing/mocks/index.js.map +1 -1
- package/dist/esm/testing/utils/index.d.ts +1 -1
- package/dist/esm/testing/utils/index.d.ts.map +1 -1
- package/dist/esm/testing/utils/index.js +1 -1
- package/dist/esm/testing/utils/index.js.map +1 -1
- package/dist/esm/vaa/functions.d.ts +2 -1
- package/dist/esm/vaa/functions.d.ts.map +1 -1
- package/dist/esm/vaa/functions.js.map +1 -1
- package/dist/esm/vaa/index.d.ts +4 -6
- package/dist/esm/vaa/index.d.ts.map +1 -1
- package/dist/esm/vaa/index.js +4 -3
- package/dist/esm/vaa/index.js.map +1 -1
- package/dist/esm/vaa/registration.d.ts +2 -2
- package/dist/esm/vaa/registration.d.ts.map +1 -1
- package/dist/esm/vaa/registration.js.map +1 -1
- package/dist/esm/vaa/vaa.d.ts +6 -5
- package/dist/esm/vaa/vaa.d.ts.map +1 -1
- package/dist/esm/vaa/vaa.js.map +1 -1
- package/package.json +6 -4
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { Chain, ChainToPlatform, Platform } from "@wormhole-foundation/sdk-base";
|
|
2
|
+
import type { WormholeRegistry } from "./registry.js";
|
|
3
|
+
import { UniversalAddress } from "./universalAddress.js";
|
|
4
|
+
/**
|
|
5
|
+
* Address is the base interface all address types must implement.
|
|
6
|
+
*
|
|
7
|
+
* Represents a parsed address
|
|
8
|
+
*/
|
|
9
|
+
export interface Address {
|
|
10
|
+
/**
|
|
11
|
+
* unwrap returns the underlying native address type, e.g.:
|
|
12
|
+
* a Uint8Array for UniversalAddress
|
|
13
|
+
* a checksum hex string string for EVM(ethers)
|
|
14
|
+
* a PublicKey for Solana
|
|
15
|
+
* etc.
|
|
16
|
+
*/
|
|
17
|
+
unwrap(): unknown;
|
|
18
|
+
/** Return the address in its canonical string format */
|
|
19
|
+
toString(): string;
|
|
20
|
+
/** Return the bytes for the address */
|
|
21
|
+
toUint8Array(): Uint8Array;
|
|
22
|
+
/** Return an Address that has been converted to its Universal representation */
|
|
23
|
+
toUniversalAddress(): UniversalAddress;
|
|
24
|
+
}
|
|
25
|
+
export type MappedPlatforms = keyof WormholeRegistry.PlatformToNativeAddressMapping;
|
|
26
|
+
/** Utility type to map platform to its native address implementation */
|
|
27
|
+
type GetNativeAddress<P extends Platform> = P extends MappedPlatforms ? WormholeRegistry.PlatformToNativeAddressMapping[P] : never;
|
|
28
|
+
/** An address that has been parsed into its Nativfe Address type */
|
|
29
|
+
export type NativeAddress<C extends Chain> = GetNativeAddress<ChainToPlatform<C>>;
|
|
30
|
+
/** A union type representing a parsed address */
|
|
31
|
+
export type UniversalOrNative<C extends Chain> = UniversalAddress | NativeAddress<C>;
|
|
32
|
+
/** An address that represents an account */
|
|
33
|
+
export type AccountAddress<C extends Chain> = UniversalOrNative<C>;
|
|
34
|
+
/**
|
|
35
|
+
* ChainAddress represents the parsed address for a given chain
|
|
36
|
+
* and comes with the context of which chain its relevant for
|
|
37
|
+
*/
|
|
38
|
+
export type ChainAddress<C extends Chain = Chain> = {
|
|
39
|
+
readonly chain: C;
|
|
40
|
+
readonly address: UniversalOrNative<C>;
|
|
41
|
+
};
|
|
42
|
+
type NativeAddressCtr = new (ua: UniversalAddress | string | Uint8Array) => Address;
|
|
43
|
+
export declare function registerNative<P extends Platform>(platform: P, ctr: NativeAddressCtr): void;
|
|
44
|
+
export declare function nativeIsRegistered<C extends Chain>(chain: C): boolean;
|
|
45
|
+
/** Parse an address into its NativeAddress representation */
|
|
46
|
+
export declare function toNative<C extends Chain>(chain: C, ua: UniversalAddress | string | Uint8Array): NativeAddress<C>;
|
|
47
|
+
export declare function toUniversal<C extends Chain>(chain: C, address: string | Uint8Array): UniversalAddress;
|
|
48
|
+
export {};
|
|
49
|
+
//# sourceMappingURL=address.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../../src/address.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAEtF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAUtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD;;;;GAIG;AACH,MAAM,WAAW,OAAO;IACtB;;;;;;OAMG;IACH,MAAM,IAAI,OAAO,CAAC;IAClB,wDAAwD;IACxD,QAAQ,IAAI,MAAM,CAAC;IACnB,uCAAuC;IACvC,YAAY,IAAI,UAAU,CAAC;IAC3B,gFAAgF;IAChF,kBAAkB,IAAI,gBAAgB,CAAC;CACxC;AAED,MAAM,MAAM,eAAe,GAAG,MAAM,gBAAgB,CAAC,8BAA8B,CAAC;AAEpF,wEAAwE;AACxE,KAAK,gBAAgB,CAAC,CAAC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AGlB"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toUniversal = exports.toNative = exports.nativeIsRegistered = exports.registerNative = void 0;
|
|
4
|
+
const sdk_base_1 = require("@wormhole-foundation/sdk-base");
|
|
5
|
+
//TODO BRRRR circular include!!
|
|
6
|
+
//I have yet to figure out how to get the equivalent of a forward declaration to work (without
|
|
7
|
+
// yet again having to rely on global scope...)
|
|
8
|
+
//I first tried `declare class UniversalAddress {};` but this actually introduces a new, separate
|
|
9
|
+
// type in this module rather than telling the compiler that we already have this type elsewhere
|
|
10
|
+
//I could also create an interface via `interface IUnverisalAddress {}` but that seems like an
|
|
11
|
+
// even worse solution, as is just throwing everything into this file here and just brushing
|
|
12
|
+
// things under the rug by not separating them out.
|
|
13
|
+
const universalAddress_js_1 = require("./universalAddress.js");
|
|
14
|
+
const nativeFactory = new Map();
|
|
15
|
+
function registerNative(platform, ctr) {
|
|
16
|
+
if (nativeFactory.has(platform))
|
|
17
|
+
return; //throw new Error(`Native address type for platform ${platform} has already registered`);
|
|
18
|
+
nativeFactory.set(platform, ctr);
|
|
19
|
+
}
|
|
20
|
+
exports.registerNative = registerNative;
|
|
21
|
+
function nativeIsRegistered(chain) {
|
|
22
|
+
const platform = sdk_base_1.chainToPlatform.get(chain);
|
|
23
|
+
return nativeFactory.has(platform);
|
|
24
|
+
}
|
|
25
|
+
exports.nativeIsRegistered = nativeIsRegistered;
|
|
26
|
+
/** Parse an address into its NativeAddress representation */
|
|
27
|
+
function toNative(chain, ua) {
|
|
28
|
+
const platform = sdk_base_1.chainToPlatform.get(chain);
|
|
29
|
+
const nativeCtr = nativeFactory.get(platform);
|
|
30
|
+
if (!nativeCtr)
|
|
31
|
+
throw new Error(`No native address type registered for platform ${platform}`);
|
|
32
|
+
return new nativeCtr(ua);
|
|
33
|
+
}
|
|
34
|
+
exports.toNative = toNative;
|
|
35
|
+
function toUniversal(chain, address) {
|
|
36
|
+
const platform = sdk_base_1.chainToPlatform.get(chain);
|
|
37
|
+
return new universalAddress_js_1.UniversalAddress(address, sdk_base_1.platformToAddressFormat.get(platform));
|
|
38
|
+
}
|
|
39
|
+
exports.toUniversal = toUniversal;
|
|
40
|
+
//# sourceMappingURL=address.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"address.js","sourceRoot":"","sources":["../../src/address.ts"],"names":[],"mappings":";;;AACA,4DAAyF;AAGzF,+BAA+B;AAC/B,8FAA8F;AAC9F,gDAAgD;AAChD,iGAAiG;AACjG,iGAAiG;AACjG,8FAA8F;AAC9F,6FAA6F;AAC7F,oDAAoD;AACpD,+DAAyD;AAmDzD,MAAM,aAAa,GAAG,IAAI,GAAG,EAA8B,CAAC;AAE5D,SAAgB,cAAc,CAAqB,QAAW,EAAE,GAAqB;IACnF,IAAI,aAAa,CAAC,GAAG,CAAC,QAAQ,CAAC;QAAE,OAAO,CAAC,yFAAyF;IAClI,aAAa,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;AACnC,CAAC;AAHD,wCAGC;AAED,SAAgB,kBAAkB,CAAkB,KAAQ;IAC1D,MAAM,QAAQ,GAAa,0BAAe,CAAC,GAAG,CAAC,KAAK,CAAE,CAAC;IACvD,OAAO,aAAa,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AACrC,CAAC;AAHD,gDAGC;AAED,6DAA6D;AAC7D,SAAgB,QAAQ,CACtB,KAAQ,EACR,EAA0C;IAE1C,MAAM,QAAQ,GAAa,0BAAe,CAAC,GAAG,CAAC,KAAK,CAAE,CAAC;IACvD,MAAM,SAAS,GAAG,aAAa,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC9C,IAAI,CAAC,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,kDAAkD,QAAQ,EAAE,CAAC,CAAC;IAC9F,OAAO,IAAI,SAAS,CAAC,EAAE,CAAgC,CAAC;AAC1D,CAAC;AARD,4BAQC;AAED,SAAgB,WAAW,CACzB,KAAQ,EACR,OAA4B;IAE5B,MAAM,QAAQ,GAAa,0BAAe,CAAC,GAAG,CAAC,KAAK,CAAE,CAAC;IACvD,OAAO,IAAI,sCAAgB,CAAC,OAAO,EAAE,kCAAuB,CAAC,GAAG,CAAC,QAAQ,CAAE,CAAC,CAAC;AAC/E,CAAC;AAND,kCAMC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Chain } from "@wormhole-foundation/sdk-base";
|
|
2
|
+
import type { ProtocolName } from "./protocol.js";
|
|
3
|
+
import type { AutomaticCircleBridge, CircleBridge } from "./protocols/circleBridge/circleBridge.js";
|
|
4
|
+
import type { IbcTransferData } from "./protocols/ibc/ibc.js";
|
|
5
|
+
import type { PorticoBridge } from "./protocols/portico/portico.js";
|
|
6
|
+
import type { AutomaticTokenBridge, TokenBridge } from "./protocols/tokenBridge/tokenBridge.js";
|
|
7
|
+
import type { SequenceId } from "./types.js";
|
|
8
|
+
import type { UniversalAddress } from "./universalAddress.js";
|
|
9
|
+
import type { VAA } from "./vaa/index.js";
|
|
10
|
+
/**
|
|
11
|
+
* The Identifier of an attestation, useful to look up the full attestation
|
|
12
|
+
*/
|
|
13
|
+
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;
|
|
14
|
+
/**
|
|
15
|
+
* The full attestation that represents evidence of a transaction
|
|
16
|
+
*/
|
|
17
|
+
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;
|
|
18
|
+
/**
|
|
19
|
+
* Wormhole Message Identifier used to fetch a VAA
|
|
20
|
+
*/
|
|
21
|
+
export type WormholeMessageId = {
|
|
22
|
+
chain: Chain;
|
|
23
|
+
emitter: UniversalAddress;
|
|
24
|
+
sequence: SequenceId;
|
|
25
|
+
};
|
|
26
|
+
export declare function isWormholeMessageId(thing: WormholeMessageId | any): thing is WormholeMessageId;
|
|
27
|
+
export type getWormholeAttestation = (id: WormholeMessageId) => Promise<VAA>;
|
|
28
|
+
/**
|
|
29
|
+
* Circle Message Identifier
|
|
30
|
+
* Used to fetch a Circle attestation
|
|
31
|
+
*/
|
|
32
|
+
export type CircleMessageId = {
|
|
33
|
+
hash: string;
|
|
34
|
+
};
|
|
35
|
+
export declare function isCircleMessageId(thing: CircleMessageId | any): thing is CircleMessageId;
|
|
36
|
+
/** Attestation from circle attestation api */
|
|
37
|
+
export type CircleAttestation = string;
|
|
38
|
+
export type getCircleAttestation = (id: CircleMessageId) => Promise<CircleAttestation>;
|
|
39
|
+
/**
|
|
40
|
+
* Ibc Message Identifier
|
|
41
|
+
* Used to fetch a Ibc attestation
|
|
42
|
+
*/
|
|
43
|
+
export type IbcMessageId = {
|
|
44
|
+
chain: Chain;
|
|
45
|
+
srcPort: string;
|
|
46
|
+
srcChannel: string;
|
|
47
|
+
dstPort: string;
|
|
48
|
+
dstChannel: string;
|
|
49
|
+
sequence: number;
|
|
50
|
+
};
|
|
51
|
+
export declare function isIbcMessageId(thing: IbcMessageId | any): thing is IbcMessageId;
|
|
52
|
+
//# sourceMappingURL=attestation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attestation.d.ts","sourceRoot":"","sources":["../../src/attestation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,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GAAG,GACjB,KAAK,CAAC;AAEV;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,KAAK,EAAE,KAAK,CAAC;IACb,OAAO,EAAE,gBAAgB,CAAC;IAC1B,QAAQ,EAAE,UAAU,CAAC;CACtB,CAAC;AACF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,iBAAiB,GAAG,GAAG,GAAG,KAAK,IAAI,iBAAiB,CAM9F;AAED,MAAM,MAAM,sBAAsB,GAAG,CAAC,EAAE,EAAE,iBAAiB,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;AAE7E;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AACF,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,eAAe,GAAG,GAAG,GAAG,KAAK,IAAI,eAAe,CAExF;AAED,8CAA8C;AAC9C,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC;AAEvC,MAAM,MAAM,oBAAoB,GAAG,CAAC,EAAE,EAAE,eAAe,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAEvF;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,EAAE,KAAK,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AACF,wBAAgB,cAAc,CAAC,KAAK,EAAE,YAAY,GAAG,GAAG,GAAG,KAAK,IAAI,YAAY,CAS/E"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isIbcMessageId = exports.isCircleMessageId = exports.isWormholeMessageId = void 0;
|
|
4
|
+
function isWormholeMessageId(thing) {
|
|
5
|
+
return (thing.sequence !== undefined &&
|
|
6
|
+
thing.emitter !== undefined &&
|
|
7
|
+
thing.chain !== undefined);
|
|
8
|
+
}
|
|
9
|
+
exports.isWormholeMessageId = isWormholeMessageId;
|
|
10
|
+
function isCircleMessageId(thing) {
|
|
11
|
+
return thing.hash !== undefined;
|
|
12
|
+
}
|
|
13
|
+
exports.isCircleMessageId = isCircleMessageId;
|
|
14
|
+
function isIbcMessageId(thing) {
|
|
15
|
+
return (thing.dstChannel !== undefined &&
|
|
16
|
+
thing.srcChannel !== undefined &&
|
|
17
|
+
thing.chain !== undefined &&
|
|
18
|
+
thing.srcPort !== undefined &&
|
|
19
|
+
thing.dstPort !== undefined &&
|
|
20
|
+
thing.sequence !== undefined);
|
|
21
|
+
}
|
|
22
|
+
exports.isIbcMessageId = isIbcMessageId;
|
|
23
|
+
//# sourceMappingURL=attestation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attestation.js","sourceRoot":"","sources":["../../src/attestation.ts"],"names":[],"mappings":";;;AAuDA,SAAgB,mBAAmB,CAAC,KAA8B;IAChE,OAAO,CACe,KAAM,CAAC,QAAQ,KAAK,SAAS;QAC7B,KAAM,CAAC,OAAO,KAAK,SAAS;QAC5B,KAAM,CAAC,KAAK,KAAK,SAAS,CAC/C,CAAC;AACJ,CAAC;AAND,kDAMC;AAWD,SAAgB,iBAAiB,CAAC,KAA4B;IAC5D,OAAyB,KAAM,CAAC,IAAI,KAAK,SAAS,CAAC;AACrD,CAAC;AAFD,8CAEC;AAmBD,SAAgB,cAAc,CAAC,KAAyB;IACtD,OAAO,CACU,KAAM,CAAC,UAAU,KAAK,SAAS;QAC/B,KAAM,CAAC,UAAU,KAAK,SAAS;QAC/B,KAAM,CAAC,KAAK,KAAK,SAAS;QAC1B,KAAM,CAAC,OAAO,KAAK,SAAS;QAC5B,KAAM,CAAC,OAAO,KAAK,SAAS;QAC5B,KAAM,CAAC,QAAQ,KAAK,SAAS,CAC7C,CAAC;AACJ,CAAC;AATD,wCASC"}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import type { Chain, ChainToPlatform, Network, Platform } from "@wormhole-foundation/sdk-base";
|
|
2
|
+
import { tokens } from "@wormhole-foundation/sdk-base";
|
|
3
|
+
import type { ChainAddress, UniversalOrNative } from "./address.js";
|
|
4
|
+
import type { WormholeMessageId } from "./attestation.js";
|
|
5
|
+
import type { PlatformContext } from "./platform.js";
|
|
6
|
+
import type { ProtocolName } from "./protocol.js";
|
|
7
|
+
import type { AutomaticCircleBridge, CircleBridge } from "./protocols/circleBridge/circleBridge.js";
|
|
8
|
+
import type { WormholeCore } from "./protocols/core/core.js";
|
|
9
|
+
import type { IbcBridge } from "./protocols/ibc/ibc.js";
|
|
10
|
+
import type { PorticoBridge } from "./protocols/portico/portico.js";
|
|
11
|
+
import type { AutomaticTokenBridge, TokenBridge } from "./protocols/tokenBridge/tokenBridge.js";
|
|
12
|
+
import type { RpcConnection } from "./rpc.js";
|
|
13
|
+
import type { ChainConfig, SignedTx, TokenAddress, TokenId } from "./types.js";
|
|
14
|
+
/**
|
|
15
|
+
* A ChainContext provides a consistent interface for interacting with a chain.
|
|
16
|
+
* It holds the configuration for the chain and cached RPC and protocol clients.
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
19
|
+
export declare abstract class ChainContext<N extends Network, C extends Chain = Chain, P extends Platform = ChainToPlatform<C>> {
|
|
20
|
+
readonly network: N;
|
|
21
|
+
readonly chain: C;
|
|
22
|
+
readonly config: ChainConfig<N, C>;
|
|
23
|
+
readonly platform: PlatformContext<N, P>;
|
|
24
|
+
protected rpc?: RpcConnection<P>;
|
|
25
|
+
protected coreBridge?: WormholeCore<N, C>;
|
|
26
|
+
protected tokenBridge?: TokenBridge<N, C>;
|
|
27
|
+
protected autoTokenBridge?: AutomaticTokenBridge<N, C>;
|
|
28
|
+
protected circleBridge?: CircleBridge<N, C>;
|
|
29
|
+
protected autoCircleBridge?: AutomaticCircleBridge<N, C>;
|
|
30
|
+
protected ibcBridge?: IbcBridge<N, C>;
|
|
31
|
+
protected porticoBridge?: PorticoBridge<N, C>;
|
|
32
|
+
constructor(chain: C, platform: PlatformContext<N, P>, rpc?: RpcConnection<P>);
|
|
33
|
+
/**
|
|
34
|
+
* Get an RPC connection for this chain, uses the configuration passed in
|
|
35
|
+
* the initial constructor
|
|
36
|
+
*
|
|
37
|
+
* @returns the RPC connection for this chain
|
|
38
|
+
*/
|
|
39
|
+
getRpc(): Promise<RpcConnection<P>>;
|
|
40
|
+
/**
|
|
41
|
+
* Get the number of decimals for a token
|
|
42
|
+
*
|
|
43
|
+
* @param token the token to get the decimals for
|
|
44
|
+
* @returns the number of decimals for the token
|
|
45
|
+
*/
|
|
46
|
+
getDecimals(token: TokenAddress<C>): Promise<number>;
|
|
47
|
+
/**
|
|
48
|
+
* Get the balance of a token for a given address
|
|
49
|
+
*
|
|
50
|
+
* @param walletAddr the address to get the balance for
|
|
51
|
+
* @param token the token to get the balance for
|
|
52
|
+
* @returns the balance of the token for the address
|
|
53
|
+
*
|
|
54
|
+
*/
|
|
55
|
+
getBalance(walletAddr: string, token: TokenAddress<C>): Promise<bigint | null>;
|
|
56
|
+
/**
|
|
57
|
+
* Get the latest block number seen by the chain according to the RPC
|
|
58
|
+
*
|
|
59
|
+
* @returns the latest block number
|
|
60
|
+
*/
|
|
61
|
+
getLatestBlock(): Promise<number>;
|
|
62
|
+
/**
|
|
63
|
+
* Get the latest _finalized_ block number seen by the chain according to the RPC
|
|
64
|
+
*
|
|
65
|
+
* @returns the latest finalized block number
|
|
66
|
+
*/
|
|
67
|
+
getLatestFinalizedBlock(): Promise<number>;
|
|
68
|
+
/**
|
|
69
|
+
* Parse the Wormhole Core messages from a transaction
|
|
70
|
+
*
|
|
71
|
+
* @param txid the transaction to parse
|
|
72
|
+
* @returns the Wormhole Core messages emitted by the transaction
|
|
73
|
+
*/
|
|
74
|
+
parseTransaction(txid: string): Promise<WormholeMessageId[]>;
|
|
75
|
+
/**
|
|
76
|
+
* Send a transaction and wait for it to be confirmed
|
|
77
|
+
*
|
|
78
|
+
* @param stxns the signed transaction to send
|
|
79
|
+
* @returns the transaction hashes of the sent transactions
|
|
80
|
+
*/
|
|
81
|
+
sendWait(stxns: SignedTx[]): Promise<string[]>;
|
|
82
|
+
/**
|
|
83
|
+
* Get the token data from the local cache if available
|
|
84
|
+
* @param symbol the symbol of the token to get
|
|
85
|
+
* @returns the token data if available
|
|
86
|
+
*/
|
|
87
|
+
getToken(symbol: tokens.TokenSymbol): tokens.Token | undefined;
|
|
88
|
+
/**
|
|
89
|
+
* Get the token id of the wrapped token for the native gas token
|
|
90
|
+
*
|
|
91
|
+
* @returns the wrapped token for the native gas token
|
|
92
|
+
*/
|
|
93
|
+
getNativeWrappedTokenId(): Promise<TokenId<C>>;
|
|
94
|
+
/**
|
|
95
|
+
* Get the token account for a given address and token
|
|
96
|
+
*
|
|
97
|
+
* @remarks
|
|
98
|
+
* This is really only useful in the context of Solana but in order
|
|
99
|
+
* to provide a consistent interface, we provide it here.
|
|
100
|
+
*
|
|
101
|
+
* @param address the address to get the token account for
|
|
102
|
+
* @param token the token to get the token account for
|
|
103
|
+
* @returns the token account for the address and token
|
|
104
|
+
*/
|
|
105
|
+
getTokenAccount(address: UniversalOrNative<C>, token: TokenAddress<C>): Promise<ChainAddress<C>>;
|
|
106
|
+
/**
|
|
107
|
+
* Check to see if a given protocol is supported by this chain
|
|
108
|
+
* by checking if it is registered in the platform and the configuration
|
|
109
|
+
* is available and correct
|
|
110
|
+
*
|
|
111
|
+
* @param protocolName the name of the Protocol to check for support
|
|
112
|
+
* @returns a boolean indicating if this protocol is supported
|
|
113
|
+
*/
|
|
114
|
+
supportsProtocol(protocolName: ProtocolName): boolean;
|
|
115
|
+
/**
|
|
116
|
+
* Check to see if the Wormhole Core protocol is supported by this chain
|
|
117
|
+
* @returns a boolean indicating if this chain supports the Wormhole Core protocol
|
|
118
|
+
*/
|
|
119
|
+
supportsWormholeCore: () => boolean;
|
|
120
|
+
/**
|
|
121
|
+
* Get the Wormhole Core protocol client for this chain
|
|
122
|
+
* @returns the Wormhole Core protocol client for this chain
|
|
123
|
+
*/
|
|
124
|
+
getWormholeCore(): Promise<WormholeCore<N, C>>;
|
|
125
|
+
/**
|
|
126
|
+
* Check to see if the Token Bridge protocol is supported by this chain
|
|
127
|
+
* @returns a boolean indicating if this chain supports the Token Bridge protocol
|
|
128
|
+
*/
|
|
129
|
+
supportsTokenBridge: () => boolean;
|
|
130
|
+
/**
|
|
131
|
+
* Get the Token Bridge protocol client for this chain
|
|
132
|
+
* @returns the Token Bridge protocol client for this chain
|
|
133
|
+
*/
|
|
134
|
+
getTokenBridge(): Promise<TokenBridge<N, C>>;
|
|
135
|
+
/**
|
|
136
|
+
* Check to see if the Automatic Token Bridge protocol is supported by this chain
|
|
137
|
+
* @returns a boolean indicating if this chain supports the Automatic Token Bridge protocol
|
|
138
|
+
*/
|
|
139
|
+
supportsAutomaticTokenBridge: () => boolean;
|
|
140
|
+
/**
|
|
141
|
+
* Get the Automatic Token Bridge protocol client for this chain
|
|
142
|
+
* @returns the Automatic Token Bridge protocol client for this chain
|
|
143
|
+
*/
|
|
144
|
+
getAutomaticTokenBridge(): Promise<AutomaticTokenBridge<N, C>>;
|
|
145
|
+
/**
|
|
146
|
+
* Check to see if the Circle Bridge protocol is supported by this chain
|
|
147
|
+
* @returns a boolean indicating if this chain supports the Circle Bridge protocol
|
|
148
|
+
*/
|
|
149
|
+
supportsCircleBridge: () => boolean;
|
|
150
|
+
/**
|
|
151
|
+
* Get the Circle Bridge protocol client for this chain
|
|
152
|
+
* @returns the Circle Bridge protocol client for this chain
|
|
153
|
+
*/
|
|
154
|
+
getCircleBridge(): Promise<CircleBridge<N, C>>;
|
|
155
|
+
/**
|
|
156
|
+
* Check to see if the Automatic Circle Bridge protocol is supported by this chain
|
|
157
|
+
* @returns a boolean indicating if this chain supports the Automatic Circle Bridge protocol
|
|
158
|
+
*/
|
|
159
|
+
supportsAutomaticCircleBridge: () => boolean;
|
|
160
|
+
/**
|
|
161
|
+
* Get the Automatic Circle Bridge protocol client for this chain
|
|
162
|
+
* @returns the Automatic Circle Bridge protocol client for this chain
|
|
163
|
+
*/
|
|
164
|
+
getAutomaticCircleBridge(): Promise<AutomaticCircleBridge<N, C>>;
|
|
165
|
+
/**
|
|
166
|
+
* Check to see if the IBC Bridge protocol is supported by this chain
|
|
167
|
+
* @returns a boolean indicating if this chain supports the IBC Bridge protocol
|
|
168
|
+
*/
|
|
169
|
+
supportsIbcBridge: () => boolean;
|
|
170
|
+
/**
|
|
171
|
+
* Get the IBC Bridge protocol client for this chain
|
|
172
|
+
* @returns the IBC Bridge protocol client for this chain
|
|
173
|
+
*/
|
|
174
|
+
getIbcBridge(): Promise<IbcBridge<N, C>>;
|
|
175
|
+
/**
|
|
176
|
+
* Check to see if the Portico Bridge protocol is supported by this chain
|
|
177
|
+
* @returns a boolean indicating if this chain supports the Portico Bridge protocol
|
|
178
|
+
*/
|
|
179
|
+
supportsPorticoBridge: () => boolean;
|
|
180
|
+
/**
|
|
181
|
+
* Get the Portico Bridge protocol client for this chain
|
|
182
|
+
* @returns the Portico Bridge protocol client for this chain
|
|
183
|
+
*/
|
|
184
|
+
getPorticoBridge(): Promise<PorticoBridge<N, C>>;
|
|
185
|
+
}
|
|
186
|
+
//# sourceMappingURL=chain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chain.d.ts","sourceRoot":"","sources":["../../src/chain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAC/F,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,KAAK,EAAE,eAAe,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
|
|
3
|
+
exports.ChainContext = void 0;
|
|
4
|
+
const sdk_base_1 = require("@wormhole-foundation/sdk-base");
|
|
5
|
+
const address_js_1 = require("./address.js");
|
|
6
|
+
const protocol_js_1 = require("./protocol.js");
|
|
7
|
+
const types_js_1 = require("./types.js");
|
|
8
|
+
/**
|
|
9
|
+
* A ChainContext provides a consistent interface for interacting with a chain.
|
|
10
|
+
* It holds the configuration for the chain and cached RPC and protocol clients.
|
|
11
|
+
*
|
|
12
|
+
*/
|
|
13
|
+
class ChainContext {
|
|
14
|
+
network;
|
|
15
|
+
chain;
|
|
16
|
+
config;
|
|
17
|
+
platform;
|
|
18
|
+
// Cached Protocol clients
|
|
19
|
+
rpc;
|
|
20
|
+
coreBridge;
|
|
21
|
+
tokenBridge;
|
|
22
|
+
autoTokenBridge;
|
|
23
|
+
circleBridge;
|
|
24
|
+
autoCircleBridge;
|
|
25
|
+
ibcBridge;
|
|
26
|
+
porticoBridge;
|
|
27
|
+
constructor(chain, platform, rpc) {
|
|
28
|
+
this.config = platform.config[chain];
|
|
29
|
+
this.platform = platform;
|
|
30
|
+
this.chain = this.config.key;
|
|
31
|
+
this.network = this.config.network;
|
|
32
|
+
this.rpc = rpc;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Get an RPC connection for this chain, uses the configuration passed in
|
|
36
|
+
* the initial constructor
|
|
37
|
+
*
|
|
38
|
+
* @returns the RPC connection for this chain
|
|
39
|
+
*/
|
|
40
|
+
getRpc() {
|
|
41
|
+
this.rpc = this.rpc ? this.rpc : this.platform.getRpc(this.chain);
|
|
42
|
+
return this.rpc;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Get the number of decimals for a token
|
|
46
|
+
*
|
|
47
|
+
* @param token the token to get the decimals for
|
|
48
|
+
* @returns the number of decimals for the token
|
|
49
|
+
*/
|
|
50
|
+
async getDecimals(token) {
|
|
51
|
+
if ((0, types_js_1.isNative)(token))
|
|
52
|
+
return this.config.nativeTokenDecimals;
|
|
53
|
+
// try to find it in the token cache first
|
|
54
|
+
if (this.config.tokenMap) {
|
|
55
|
+
const tokenAddress = (0, types_js_1.canonicalAddress)({ chain: this.chain, address: token });
|
|
56
|
+
const found = sdk_base_1.tokens.getTokenByAddress(this.network, this.chain, tokenAddress);
|
|
57
|
+
if (found)
|
|
58
|
+
return found.decimals;
|
|
59
|
+
}
|
|
60
|
+
return this.platform.utils().getDecimals(this.chain, await this.getRpc(), token);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Get the balance of a token for a given address
|
|
64
|
+
*
|
|
65
|
+
* @param walletAddr the address to get the balance for
|
|
66
|
+
* @param token the token to get the balance for
|
|
67
|
+
* @returns the balance of the token for the address
|
|
68
|
+
*
|
|
69
|
+
*/
|
|
70
|
+
async getBalance(walletAddr, token) {
|
|
71
|
+
return this.platform.utils().getBalance(this.chain, await this.getRpc(), walletAddr, token);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Get the latest block number seen by the chain according to the RPC
|
|
75
|
+
*
|
|
76
|
+
* @returns the latest block number
|
|
77
|
+
*/
|
|
78
|
+
async getLatestBlock() {
|
|
79
|
+
return this.platform.utils().getLatestBlock(await this.getRpc());
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Get the latest _finalized_ block number seen by the chain according to the RPC
|
|
83
|
+
*
|
|
84
|
+
* @returns the latest finalized block number
|
|
85
|
+
*/
|
|
86
|
+
async getLatestFinalizedBlock() {
|
|
87
|
+
return this.platform.utils().getLatestFinalizedBlock(await this.getRpc());
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Parse the Wormhole Core messages from a transaction
|
|
91
|
+
*
|
|
92
|
+
* @param txid the transaction to parse
|
|
93
|
+
* @returns the Wormhole Core messages emitted by the transaction
|
|
94
|
+
*/
|
|
95
|
+
async parseTransaction(txid) {
|
|
96
|
+
return this.platform.parseWormholeMessages(this.chain, await this.getRpc(), txid);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Send a transaction and wait for it to be confirmed
|
|
100
|
+
*
|
|
101
|
+
* @param stxns the signed transaction to send
|
|
102
|
+
* @returns the transaction hashes of the sent transactions
|
|
103
|
+
*/
|
|
104
|
+
async sendWait(stxns) {
|
|
105
|
+
return this.platform.utils().sendWait(this.chain, await this.getRpc(), stxns);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Get the token data from the local cache if available
|
|
109
|
+
* @param symbol the symbol of the token to get
|
|
110
|
+
* @returns the token data if available
|
|
111
|
+
*/
|
|
112
|
+
getToken(symbol) {
|
|
113
|
+
if (!this.config.tokenMap)
|
|
114
|
+
return;
|
|
115
|
+
if (!(symbol in this.config.tokenMap))
|
|
116
|
+
return;
|
|
117
|
+
return this.config.tokenMap[symbol];
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Get the token id of the wrapped token for the native gas token
|
|
121
|
+
*
|
|
122
|
+
* @returns the wrapped token for the native gas token
|
|
123
|
+
*/
|
|
124
|
+
async getNativeWrappedTokenId() {
|
|
125
|
+
// see if we have it configured
|
|
126
|
+
if (this.config.wrappedNative) {
|
|
127
|
+
const { address } = this.config.wrappedNative;
|
|
128
|
+
return { chain: this.chain, address: (0, address_js_1.toNative)(this.chain, address) };
|
|
129
|
+
}
|
|
130
|
+
// otherwise grab it from the token bridge fn
|
|
131
|
+
const tb = await this.getTokenBridge();
|
|
132
|
+
return { chain: this.chain, address: await tb.getWrappedNative() };
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Get the token account for a given address and token
|
|
136
|
+
*
|
|
137
|
+
* @remarks
|
|
138
|
+
* This is really only useful in the context of Solana but in order
|
|
139
|
+
* to provide a consistent interface, we provide it here.
|
|
140
|
+
*
|
|
141
|
+
* @param address the address to get the token account for
|
|
142
|
+
* @param token the token to get the token account for
|
|
143
|
+
* @returns the token account for the address and token
|
|
144
|
+
*/
|
|
145
|
+
async getTokenAccount(address, token) {
|
|
146
|
+
// Noop by default, override in implementation if necessary
|
|
147
|
+
return { chain: this.chain, address };
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Check to see if a given protocol is supported by this chain
|
|
151
|
+
* by checking if it is registered in the platform and the configuration
|
|
152
|
+
* is available and correct
|
|
153
|
+
*
|
|
154
|
+
* @param protocolName the name of the Protocol to check for support
|
|
155
|
+
* @returns a boolean indicating if this protocol is supported
|
|
156
|
+
*/
|
|
157
|
+
supportsProtocol(protocolName) {
|
|
158
|
+
return (0, protocol_js_1.protocolIsRegistered)(this.chain, protocolName);
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Check to see if the Wormhole Core protocol is supported by this chain
|
|
162
|
+
* @returns a boolean indicating if this chain supports the Wormhole Core protocol
|
|
163
|
+
*/
|
|
164
|
+
supportsWormholeCore = () => this.supportsProtocol("WormholeCore");
|
|
165
|
+
/**
|
|
166
|
+
* Get the Wormhole Core protocol client for this chain
|
|
167
|
+
* @returns the Wormhole Core protocol client for this chain
|
|
168
|
+
*/
|
|
169
|
+
async getWormholeCore() {
|
|
170
|
+
this.coreBridge = this.coreBridge
|
|
171
|
+
? this.coreBridge
|
|
172
|
+
: await this.platform.getProtocol("WormholeCore", await this.getRpc());
|
|
173
|
+
return this.coreBridge;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Check to see if the Token Bridge protocol is supported by this chain
|
|
177
|
+
* @returns a boolean indicating if this chain supports the Token Bridge protocol
|
|
178
|
+
*/
|
|
179
|
+
supportsTokenBridge = () => this.supportsProtocol("TokenBridge");
|
|
180
|
+
/**
|
|
181
|
+
* Get the Token Bridge protocol client for this chain
|
|
182
|
+
* @returns the Token Bridge protocol client for this chain
|
|
183
|
+
*/
|
|
184
|
+
async getTokenBridge() {
|
|
185
|
+
this.tokenBridge = this.tokenBridge
|
|
186
|
+
? this.tokenBridge
|
|
187
|
+
: await this.platform.getProtocol("TokenBridge", await this.getRpc());
|
|
188
|
+
return this.tokenBridge;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Check to see if the Automatic Token Bridge protocol is supported by this chain
|
|
192
|
+
* @returns a boolean indicating if this chain supports the Automatic Token Bridge protocol
|
|
193
|
+
*/
|
|
194
|
+
supportsAutomaticTokenBridge = () => this.supportsProtocol("AutomaticTokenBridge");
|
|
195
|
+
/**
|
|
196
|
+
* Get the Automatic Token Bridge protocol client for this chain
|
|
197
|
+
* @returns the Automatic Token Bridge protocol client for this chain
|
|
198
|
+
*/
|
|
199
|
+
async getAutomaticTokenBridge() {
|
|
200
|
+
this.autoTokenBridge = this.autoTokenBridge
|
|
201
|
+
? this.autoTokenBridge
|
|
202
|
+
: await this.platform.getProtocol("AutomaticTokenBridge", await this.getRpc());
|
|
203
|
+
return this.autoTokenBridge;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Check to see if the Circle Bridge protocol is supported by this chain
|
|
207
|
+
* @returns a boolean indicating if this chain supports the Circle Bridge protocol
|
|
208
|
+
*/
|
|
209
|
+
supportsCircleBridge = () => this.supportsProtocol("CircleBridge");
|
|
210
|
+
/**
|
|
211
|
+
* Get the Circle Bridge protocol client for this chain
|
|
212
|
+
* @returns the Circle Bridge protocol client for this chain
|
|
213
|
+
*/
|
|
214
|
+
async getCircleBridge() {
|
|
215
|
+
this.circleBridge = this.circleBridge
|
|
216
|
+
? this.circleBridge
|
|
217
|
+
: await this.platform.getProtocol("CircleBridge", await this.getRpc());
|
|
218
|
+
return this.circleBridge;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Check to see if the Automatic Circle Bridge protocol is supported by this chain
|
|
222
|
+
* @returns a boolean indicating if this chain supports the Automatic Circle Bridge protocol
|
|
223
|
+
*/
|
|
224
|
+
supportsAutomaticCircleBridge = () => this.supportsProtocol("AutomaticCircleBridge");
|
|
225
|
+
/**
|
|
226
|
+
* Get the Automatic Circle Bridge protocol client for this chain
|
|
227
|
+
* @returns the Automatic Circle Bridge protocol client for this chain
|
|
228
|
+
*/
|
|
229
|
+
async getAutomaticCircleBridge() {
|
|
230
|
+
this.autoCircleBridge = this.autoCircleBridge
|
|
231
|
+
? this.autoCircleBridge
|
|
232
|
+
: await this.platform.getProtocol("AutomaticCircleBridge", await this.getRpc());
|
|
233
|
+
return this.autoCircleBridge;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Check to see if the IBC Bridge protocol is supported by this chain
|
|
237
|
+
* @returns a boolean indicating if this chain supports the IBC Bridge protocol
|
|
238
|
+
*/
|
|
239
|
+
supportsIbcBridge = () => this.supportsProtocol("IbcBridge");
|
|
240
|
+
/**
|
|
241
|
+
* Get the IBC Bridge protocol client for this chain
|
|
242
|
+
* @returns the IBC Bridge protocol client for this chain
|
|
243
|
+
*/
|
|
244
|
+
async getIbcBridge() {
|
|
245
|
+
this.ibcBridge = this.ibcBridge
|
|
246
|
+
? this.ibcBridge
|
|
247
|
+
: await this.platform.getProtocol("IbcBridge", await this.getRpc());
|
|
248
|
+
return this.ibcBridge;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Check to see if the Portico Bridge protocol is supported by this chain
|
|
252
|
+
* @returns a boolean indicating if this chain supports the Portico Bridge protocol
|
|
253
|
+
*/
|
|
254
|
+
supportsPorticoBridge = () => this.supportsProtocol("PorticoBridge");
|
|
255
|
+
/**
|
|
256
|
+
* Get the Portico Bridge protocol client for this chain
|
|
257
|
+
* @returns the Portico Bridge protocol client for this chain
|
|
258
|
+
*/
|
|
259
|
+
async getPorticoBridge() {
|
|
260
|
+
this.porticoBridge = this.porticoBridge
|
|
261
|
+
? this.porticoBridge
|
|
262
|
+
: await this.platform.getProtocol("PorticoBridge", await this.getRpc());
|
|
263
|
+
return this.porticoBridge;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
exports.ChainContext = ChainContext;
|
|
267
|
+
//# sourceMappingURL=chain.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chain.js","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