@wormhole-foundation/sdk-definitions 0.4.0-beta.1 → 0.4.0-beta.11
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 +24 -0
- package/dist/cjs/address.d.ts.map +1 -1
- package/dist/cjs/address.js +3 -5
- package/dist/cjs/address.js.map +1 -1
- package/dist/cjs/attestation.d.ts +18 -0
- package/dist/cjs/attestation.d.ts.map +1 -1
- package/dist/cjs/attestation.js.map +1 -1
- package/dist/cjs/chain.d.ts +154 -21
- package/dist/cjs/chain.d.ts.map +1 -1
- package/dist/cjs/chain.js +137 -19
- package/dist/cjs/chain.js.map +1 -1
- package/dist/cjs/contracts.d.ts +9 -0
- package/dist/cjs/contracts.d.ts.map +1 -1
- package/dist/cjs/contracts.js +8 -0
- package/dist/cjs/contracts.js.map +1 -1
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/layout-items/chain.d.ts +4 -90
- package/dist/cjs/layout-items/chain.d.ts.map +1 -1
- package/dist/cjs/payloads/automaticTokenBridge.d.ts +4 -4
- package/dist/cjs/payloads/bam.d.ts +12 -12
- package/dist/cjs/payloads/governance.d.ts +42 -42
- package/dist/cjs/payloads/relayer.d.ts +10 -10
- package/dist/cjs/payloads/tokenBridge.d.ts +14 -14
- package/dist/cjs/platform.d.ts +35 -3
- package/dist/cjs/platform.d.ts.map +1 -1
- package/dist/cjs/platform.js +6 -4
- package/dist/cjs/platform.js.map +1 -1
- package/dist/cjs/protocol.d.ts +2 -1
- package/dist/cjs/protocol.d.ts.map +1 -1
- package/dist/cjs/protocol.js +1 -1
- package/dist/cjs/protocol.js.map +1 -1
- package/dist/cjs/protocols/circleBridge.d.ts +59 -4
- package/dist/cjs/protocols/circleBridge.d.ts.map +1 -1
- package/dist/cjs/protocols/circleBridge.js.map +1 -1
- package/dist/cjs/protocols/core.d.ts +34 -3
- package/dist/cjs/protocols/core.d.ts.map +1 -1
- package/dist/cjs/protocols/ibc.d.ts +28 -4
- package/dist/cjs/protocols/ibc.d.ts.map +1 -1
- package/dist/cjs/protocols/ibc.js.map +1 -1
- package/dist/cjs/protocols/portico.d.ts +13 -3
- package/dist/cjs/protocols/portico.d.ts.map +1 -1
- package/dist/cjs/protocols/portico.js.map +1 -1
- package/dist/cjs/protocols/relayer.d.ts +9 -0
- package/dist/cjs/protocols/relayer.d.ts.map +1 -1
- package/dist/cjs/protocols/tokenBridge.d.ts +104 -4
- package/dist/cjs/protocols/tokenBridge.d.ts.map +1 -1
- package/dist/cjs/protocols/tokenBridge.js +3 -0
- package/dist/cjs/protocols/tokenBridge.js.map +1 -1
- package/dist/cjs/signature.d.ts +1 -0
- package/dist/cjs/signature.d.ts.map +1 -1
- package/dist/cjs/signature.js +1 -2
- package/dist/cjs/signature.js.map +1 -1
- package/dist/cjs/signer.d.ts +35 -1
- package/dist/cjs/signer.d.ts.map +1 -1
- package/dist/cjs/signer.js +24 -1
- package/dist/cjs/signer.js.map +1 -1
- package/dist/cjs/testing/mocks/chain.d.ts +4 -3
- package/dist/cjs/testing/mocks/chain.d.ts.map +1 -1
- package/dist/cjs/testing/mocks/chain.js.map +1 -1
- package/dist/cjs/testing/mocks/platform.d.ts +3 -3
- package/dist/cjs/testing/mocks/platform.d.ts.map +1 -1
- package/dist/cjs/testing/mocks/platform.js +1 -0
- package/dist/cjs/testing/mocks/platform.js.map +1 -1
- package/dist/cjs/testing/mocks/tokenBridge.d.ts +3 -3
- package/dist/cjs/testing/mocks/tokenBridge.d.ts.map +1 -1
- package/dist/cjs/testing/utils/address.d.ts +1 -1
- package/dist/cjs/testing/utils/address.d.ts.map +1 -1
- package/dist/cjs/testing/utils/address.js.map +1 -1
- package/dist/cjs/types.d.ts +32 -0
- package/dist/cjs/types.d.ts.map +1 -1
- package/dist/cjs/types.js +10 -7
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/universalAddress.d.ts +4 -0
- package/dist/cjs/universalAddress.d.ts.map +1 -1
- package/dist/cjs/universalAddress.js +4 -0
- package/dist/cjs/universalAddress.js.map +1 -1
- package/dist/cjs/unsignedTransaction.d.ts +4 -0
- package/dist/cjs/unsignedTransaction.d.ts.map +1 -1
- package/dist/cjs/vaa/vaa.d.ts +12 -4
- package/dist/cjs/vaa/vaa.d.ts.map +1 -1
- package/dist/esm/address.d.ts +24 -0
- package/dist/esm/address.d.ts.map +1 -1
- package/dist/esm/address.js +3 -5
- package/dist/esm/address.js.map +1 -1
- package/dist/esm/attestation.d.ts +18 -0
- package/dist/esm/attestation.d.ts.map +1 -1
- package/dist/esm/attestation.js.map +1 -1
- package/dist/esm/chain.d.ts +154 -21
- package/dist/esm/chain.d.ts.map +1 -1
- package/dist/esm/chain.js +137 -19
- package/dist/esm/chain.js.map +1 -1
- package/dist/esm/contracts.d.ts +9 -0
- package/dist/esm/contracts.d.ts.map +1 -1
- package/dist/esm/contracts.js +8 -0
- package/dist/esm/contracts.js.map +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/layout-items/chain.d.ts +4 -90
- package/dist/esm/layout-items/chain.d.ts.map +1 -1
- package/dist/esm/payloads/automaticTokenBridge.d.ts +4 -4
- package/dist/esm/payloads/bam.d.ts +12 -12
- package/dist/esm/payloads/governance.d.ts +42 -42
- package/dist/esm/payloads/relayer.d.ts +10 -10
- package/dist/esm/payloads/tokenBridge.d.ts +14 -14
- package/dist/esm/platform.d.ts +35 -3
- package/dist/esm/platform.d.ts.map +1 -1
- package/dist/esm/platform.js +6 -4
- package/dist/esm/platform.js.map +1 -1
- package/dist/esm/protocol.d.ts +2 -1
- package/dist/esm/protocol.d.ts.map +1 -1
- package/dist/esm/protocol.js +1 -1
- package/dist/esm/protocol.js.map +1 -1
- package/dist/esm/protocols/circleBridge.d.ts +59 -4
- package/dist/esm/protocols/circleBridge.d.ts.map +1 -1
- package/dist/esm/protocols/circleBridge.js.map +1 -1
- package/dist/esm/protocols/core.d.ts +34 -3
- package/dist/esm/protocols/core.d.ts.map +1 -1
- package/dist/esm/protocols/ibc.d.ts +28 -4
- package/dist/esm/protocols/ibc.d.ts.map +1 -1
- package/dist/esm/protocols/ibc.js.map +1 -1
- package/dist/esm/protocols/portico.d.ts +13 -3
- package/dist/esm/protocols/portico.d.ts.map +1 -1
- package/dist/esm/protocols/portico.js.map +1 -1
- package/dist/esm/protocols/relayer.d.ts +9 -0
- package/dist/esm/protocols/relayer.d.ts.map +1 -1
- package/dist/esm/protocols/tokenBridge.d.ts +104 -4
- package/dist/esm/protocols/tokenBridge.d.ts.map +1 -1
- package/dist/esm/protocols/tokenBridge.js +4 -1
- package/dist/esm/protocols/tokenBridge.js.map +1 -1
- package/dist/esm/signature.d.ts +1 -0
- package/dist/esm/signature.d.ts.map +1 -1
- package/dist/esm/signature.js +1 -2
- package/dist/esm/signature.js.map +1 -1
- package/dist/esm/signer.d.ts +35 -1
- package/dist/esm/signer.d.ts.map +1 -1
- package/dist/esm/signer.js +21 -0
- package/dist/esm/signer.js.map +1 -1
- package/dist/esm/testing/mocks/chain.d.ts +4 -3
- package/dist/esm/testing/mocks/chain.d.ts.map +1 -1
- package/dist/esm/testing/mocks/chain.js.map +1 -1
- package/dist/esm/testing/mocks/platform.d.ts +3 -3
- package/dist/esm/testing/mocks/platform.d.ts.map +1 -1
- package/dist/esm/testing/mocks/platform.js +1 -0
- package/dist/esm/testing/mocks/platform.js.map +1 -1
- package/dist/esm/testing/mocks/tokenBridge.d.ts +3 -3
- package/dist/esm/testing/mocks/tokenBridge.d.ts.map +1 -1
- package/dist/esm/testing/utils/address.d.ts +1 -1
- package/dist/esm/testing/utils/address.d.ts.map +1 -1
- package/dist/esm/testing/utils/address.js.map +1 -1
- package/dist/esm/types.d.ts +32 -0
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/esm/types.js +10 -7
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/universalAddress.d.ts +4 -0
- package/dist/esm/universalAddress.d.ts.map +1 -1
- package/dist/esm/universalAddress.js +4 -0
- package/dist/esm/universalAddress.js.map +1 -1
- package/dist/esm/unsignedTransaction.d.ts +4 -0
- package/dist/esm/unsignedTransaction.d.ts.map +1 -1
- package/dist/esm/vaa/vaa.d.ts +12 -4
- package/dist/esm/vaa/vaa.d.ts.map +1 -1
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +2 -2
package/dist/cjs/address.d.ts
CHANGED
|
@@ -1,9 +1,24 @@
|
|
|
1
1
|
import { Chain, ChainToPlatform, Platform } from "@wormhole-foundation/sdk-base";
|
|
2
2
|
import { UniversalAddress } from "./universalAddress";
|
|
3
|
+
/**
|
|
4
|
+
* Address is the base interface all address types must implement.
|
|
5
|
+
*
|
|
6
|
+
* Represents a parsed address
|
|
7
|
+
*/
|
|
3
8
|
export interface Address {
|
|
9
|
+
/**
|
|
10
|
+
* unwrap returns the underlying native address type, e.g.:
|
|
11
|
+
* a Uint8Array for UniversalAddress
|
|
12
|
+
* a checksum hex string string for EVM(ethers)
|
|
13
|
+
* a PublicKey for Solana
|
|
14
|
+
* etc.
|
|
15
|
+
*/
|
|
4
16
|
unwrap(): unknown;
|
|
17
|
+
/** Return the address in its canonical string format */
|
|
5
18
|
toString(): string;
|
|
19
|
+
/** Return the bytes for the address */
|
|
6
20
|
toUint8Array(): Uint8Array;
|
|
21
|
+
/** Return an Address that has been converted to its Universal representation */
|
|
7
22
|
toUniversalAddress(): UniversalAddress;
|
|
8
23
|
}
|
|
9
24
|
declare global {
|
|
@@ -13,10 +28,18 @@ declare global {
|
|
|
13
28
|
}
|
|
14
29
|
}
|
|
15
30
|
export type MappedPlatforms = keyof WormholeNamespace.PlatformToNativeAddressMapping;
|
|
31
|
+
/** Utility type to map platform to its native address implementation */
|
|
16
32
|
type GetNativeAddress<P extends Platform> = P extends MappedPlatforms ? WormholeNamespace.PlatformToNativeAddressMapping[P] : never;
|
|
33
|
+
/** An address that has been parsed into its Nativfe Address type */
|
|
17
34
|
export type NativeAddress<C extends Chain> = GetNativeAddress<ChainToPlatform<C>>;
|
|
35
|
+
/** A union type representing a parsed address */
|
|
18
36
|
export type UniversalOrNative<C extends Chain> = UniversalAddress | NativeAddress<C>;
|
|
37
|
+
/** An address that represents an account */
|
|
19
38
|
export type AccountAddress<C extends Chain> = UniversalOrNative<C>;
|
|
39
|
+
/**
|
|
40
|
+
* ChainAddress represents the parsed address for a given chain
|
|
41
|
+
* and comes with the context of which chain its relevant for
|
|
42
|
+
*/
|
|
20
43
|
export type ChainAddress<C extends Chain = Chain> = {
|
|
21
44
|
readonly chain: C;
|
|
22
45
|
readonly address: UniversalOrNative<C>;
|
|
@@ -24,6 +47,7 @@ export type ChainAddress<C extends Chain = Chain> = {
|
|
|
24
47
|
type NativeAddressCtr = new (ua: UniversalAddress | string | Uint8Array) => Address;
|
|
25
48
|
export declare function registerNative<P extends Platform>(platform: P, ctr: NativeAddressCtr): void;
|
|
26
49
|
export declare function nativeIsRegistered<C extends Chain>(chain: C): boolean;
|
|
50
|
+
/** Parse an address into its NativeAddress representation */
|
|
27
51
|
export declare function toNative<C extends Chain>(chain: C, ua: UniversalAddress | string | Uint8Array): NativeAddress<C>;
|
|
28
52
|
export declare function toUniversal<C extends Chain>(chain: C, address: string | Uint8Array): UniversalAddress;
|
|
29
53
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../../src/address.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,eAAe,EACf,QAAQ,EAGT,MAAM,+BAA+B,CAAC;AAUvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,MAAM,WAAW,OAAO;
|
|
1
|
+
{"version":3,"file":"address.d.ts","sour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xC,CAAC;AAEF,KAAK,gBAAgB,GAAG,KAAK,EAAE,EAAE,gBAAgB,GAAG,MAAM,GAAG,UAAU,KAAK,OAAO,CAAC;AAIpF,wBAAgB,cAAc,CAAC,CAAC,SAAS,QAAQ,EAAE,QAAQ,EAAE,CAAC,EAAE,GAAG,EAAE,gBAAgB,GAAG,IAAI,CAG3F;AAED,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,KAAK,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAGrE;AAED,6DAA6D;AAC7D,wBAAgB,QAAQ,CAAC,CAAC,SAAS,KAAK,EACtC,KAAK,EAAE,CAAC,EACR,EAAE,EAAE,gBAAgB,GAAG,MAAM,GAAG,UAAU,GACzC,aAAa,CAAC,CAAC,CAAC,CAKlB;AAED,wBAAgB,WAAW,CAAC,CAAC,SAAS,KAAK,EACzC,KAAK,EAAE,CAAC,EACR,OAAO,EAAE,MAAM,GAAG,UAAU,GAC3B,gBAAgB,CAGlB"}
|
package/dist/cjs/address.js
CHANGED
|
@@ -13,11 +13,8 @@ const sdk_base_1 = require("@wormhole-foundation/sdk-base");
|
|
|
13
13
|
const universalAddress_1 = require("./universalAddress");
|
|
14
14
|
const nativeFactory = new Map();
|
|
15
15
|
function registerNative(platform, ctr) {
|
|
16
|
-
if (nativeFactory.has(platform))
|
|
17
|
-
|
|
18
|
-
//throw new Error(`Native address type for platform ${platform} has already registered`);
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
16
|
+
if (nativeFactory.has(platform))
|
|
17
|
+
return; //throw new Error(`Native address type for platform ${platform} has already registered`);
|
|
21
18
|
nativeFactory.set(platform, ctr);
|
|
22
19
|
}
|
|
23
20
|
exports.registerNative = registerNative;
|
|
@@ -26,6 +23,7 @@ function nativeIsRegistered(chain) {
|
|
|
26
23
|
return nativeFactory.has(platform);
|
|
27
24
|
}
|
|
28
25
|
exports.nativeIsRegistered = nativeIsRegistered;
|
|
26
|
+
/** Parse an address into its NativeAddress representation */
|
|
29
27
|
function toNative(chain, ua) {
|
|
30
28
|
const platform = sdk_base_1.chainToPlatform.get(chain);
|
|
31
29
|
const nativeCtr = nativeFactory.get(platform);
|
package/dist/cjs/address.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"address.js","sourceRoot":"","sources":["../../src/address.ts"],"names":[],"mappings":";;;AAAA,4DAMuC;AAEvC,+BAA+B;AAC/B,8FAA8F;AAC9F,gDAAgD;AAChD,iGAAiG;AACjG,iGAAiG;AACjG,8FAA8F;AAC9F,6FAA6F;AAC7F,oDAAoD;AACpD,yDAAsD;
|
|
1
|
+
{"version":3,"file":"address.js","sourceRoot":"","sources":["../../src/address.ts"],"names":[],"mappings":";;;AAAA,4DAMuC;AAEvC,+BAA+B;AAC/B,8FAA8F;AAC9F,gDAAgD;AAChD,iGAAiG;AACjG,iGAAiG;AACjG,8FAA8F;AAC9F,6FAA6F;AAC7F,oDAAoD;AACpD,yDAAsD;AAyDtD,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,mCAAgB,CAAC,OAAO,EAAE,kCAAuB,CAAC,GAAG,CAAC,QAAQ,CAAE,CAAC,CAAC;AAC/E,CAAC;AAND,kCAMC"}
|
|
@@ -7,8 +7,17 @@ import { AutomaticTokenBridge, TokenBridge } from "./protocols/tokenBridge";
|
|
|
7
7
|
import { SequenceId } from "./types";
|
|
8
8
|
import { UniversalAddress } from "./universalAddress";
|
|
9
9
|
import { VAA } from "./vaa";
|
|
10
|
+
/**
|
|
11
|
+
* The Identifier of an attestation, useful to look up the full attestation
|
|
12
|
+
*/
|
|
10
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
|
+
*/
|
|
11
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
|
+
*/
|
|
12
21
|
export type WormholeMessageId = {
|
|
13
22
|
chain: Chain;
|
|
14
23
|
emitter: UniversalAddress;
|
|
@@ -16,12 +25,21 @@ export type WormholeMessageId = {
|
|
|
16
25
|
};
|
|
17
26
|
export declare function isWormholeMessageId(thing: WormholeMessageId | any): thing is WormholeMessageId;
|
|
18
27
|
export type getWormholeAttestation = (id: WormholeMessageId) => Promise<VAA>;
|
|
28
|
+
/**
|
|
29
|
+
* Circle Message Identifier
|
|
30
|
+
* Used to fetch a Circle attestation
|
|
31
|
+
*/
|
|
19
32
|
export type CircleMessageId = {
|
|
20
33
|
hash: string;
|
|
21
34
|
};
|
|
22
35
|
export declare function isCircleMessageId(thing: CircleMessageId | any): thing is CircleMessageId;
|
|
36
|
+
/** Attestation from circle attestation api */
|
|
23
37
|
export type CircleAttestation = string;
|
|
24
38
|
export type getCircleAttestation = (id: CircleMessageId) => Promise<CircleAttestation>;
|
|
39
|
+
/**
|
|
40
|
+
* Ibc Message Identifier
|
|
41
|
+
* Used to fetch a Ibc attestation
|
|
42
|
+
*/
|
|
25
43
|
export type IbcMessageId = {
|
|
26
44
|
chain: Chain;
|
|
27
45
|
srcPort: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attestation.d.ts","sourceRoot":"","sources":["../../src/attestation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC5E,O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|
|
|
1
|
-
{"version":3,"file":"attestation.js","sourceRoot":"","sources":["../../src/attestation.ts"],"names":[],"mappings":";;;
|
|
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"}
|
package/dist/cjs/chain.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Chain, Network, Platform,
|
|
1
|
+
import { Chain, Network, Platform, tokens } from "@wormhole-foundation/sdk-base";
|
|
2
|
+
import { ChainToPlatform } from "@wormhole-foundation/sdk-base/src";
|
|
2
3
|
import { ChainAddress, UniversalOrNative } from "./address";
|
|
3
4
|
import { WormholeMessageId } from "./attestation";
|
|
4
5
|
import { PlatformContext } from "./platform";
|
|
@@ -6,48 +7,180 @@ import { ProtocolName } from "./protocol";
|
|
|
6
7
|
import { AutomaticCircleBridge, CircleBridge } from "./protocols/circleBridge";
|
|
7
8
|
import { WormholeCore } from "./protocols/core";
|
|
8
9
|
import { IbcBridge } from "./protocols/ibc";
|
|
10
|
+
import { PorticoBridge } from "./protocols/portico";
|
|
9
11
|
import { AutomaticTokenBridge, TokenBridge } from "./protocols/tokenBridge";
|
|
10
12
|
import { RpcConnection } from "./rpc";
|
|
11
|
-
import { ChainConfig, SignedTx,
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
import { ChainConfig, SignedTx, TokenAddress, TokenId } from "./types";
|
|
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>> {
|
|
14
20
|
readonly network: N;
|
|
15
|
-
readonly platform: PlatformContext<N, P>;
|
|
16
21
|
readonly chain: C;
|
|
17
22
|
readonly config: ChainConfig<N, C>;
|
|
23
|
+
readonly platform: PlatformContext<N, P>;
|
|
18
24
|
protected rpc?: RpcConnection<P>;
|
|
19
|
-
protected coreBridge?: WormholeCore<N,
|
|
20
|
-
protected tokenBridge?: TokenBridge<N,
|
|
21
|
-
protected autoTokenBridge?: AutomaticTokenBridge<N,
|
|
22
|
-
protected circleBridge?: CircleBridge<N,
|
|
23
|
-
protected autoCircleBridge?: AutomaticCircleBridge<N,
|
|
24
|
-
protected ibcBridge?: IbcBridge<N,
|
|
25
|
-
protected porticoBridge?: PorticoBridge<N,
|
|
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>;
|
|
26
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
|
+
*/
|
|
27
39
|
getRpc(): Promise<RpcConnection<P>>;
|
|
28
|
-
|
|
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
|
+
*/
|
|
29
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
|
+
*/
|
|
30
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
|
+
*/
|
|
31
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
|
+
*/
|
|
32
74
|
parseTransaction(txid: string): Promise<WormholeMessageId[]>;
|
|
33
|
-
|
|
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
|
+
*/
|
|
34
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
|
+
*/
|
|
35
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
|
+
*/
|
|
36
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
|
+
*/
|
|
37
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
|
+
*/
|
|
38
119
|
supportsWormholeCore: () => boolean;
|
|
39
|
-
|
|
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
|
+
*/
|
|
40
129
|
supportsTokenBridge: () => boolean;
|
|
41
|
-
|
|
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
|
+
*/
|
|
42
139
|
supportsAutomaticTokenBridge: () => boolean;
|
|
43
|
-
|
|
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
|
+
*/
|
|
44
149
|
supportsCircleBridge: () => boolean;
|
|
45
|
-
|
|
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
|
+
*/
|
|
46
159
|
supportsAutomaticCircleBridge: () => boolean;
|
|
47
|
-
|
|
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
|
+
*/
|
|
48
169
|
supportsIbcBridge: () => boolean;
|
|
49
|
-
|
|
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
|
+
*/
|
|
50
179
|
supportsPorticoBridge: () => boolean;
|
|
51
|
-
|
|
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>>;
|
|
52
185
|
}
|
|
53
186
|
//# sourceMappingURL=chain.d.ts.map
|
package/dist/cjs/chain.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chain.d.ts","sourceRoot":"","sources":["../../src/chain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"chain.d.ts","sourceRoot":"","sources":["../../src/chain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CA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;CAMvD"}
|
package/dist/cjs/chain.js
CHANGED
|
@@ -4,11 +4,16 @@ exports.ChainContext = void 0;
|
|
|
4
4
|
const sdk_base_1 = require("@wormhole-foundation/sdk-base");
|
|
5
5
|
const address_1 = require("./address");
|
|
6
6
|
const protocol_1 = require("./protocol");
|
|
7
|
+
/**
|
|
8
|
+
* A ChainContext provides a consistent interface for interacting with a chain.
|
|
9
|
+
* It holds the configuration for the chain and cached RPC and protocol clients.
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
7
12
|
class ChainContext {
|
|
8
13
|
network;
|
|
9
|
-
platform;
|
|
10
14
|
chain;
|
|
11
15
|
config;
|
|
16
|
+
platform;
|
|
12
17
|
// Cached Protocol clients
|
|
13
18
|
rpc;
|
|
14
19
|
coreBridge;
|
|
@@ -25,38 +30,81 @@ class ChainContext {
|
|
|
25
30
|
this.network = this.config.network;
|
|
26
31
|
this.rpc = rpc;
|
|
27
32
|
}
|
|
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
|
+
*/
|
|
28
39
|
getRpc() {
|
|
29
40
|
this.rpc = this.rpc ? this.rpc : this.platform.getRpc(this.chain);
|
|
30
41
|
return this.rpc;
|
|
31
42
|
}
|
|
32
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Get the number of decimals for a token
|
|
45
|
+
*
|
|
46
|
+
* @param token the token to get the decimals for
|
|
47
|
+
* @returns the number of decimals for the token
|
|
48
|
+
*/
|
|
33
49
|
async getDecimals(token) {
|
|
34
50
|
// try to find it in the token cache first
|
|
35
51
|
if (this.config.tokenMap) {
|
|
36
52
|
const found = sdk_base_1.tokens.getTokenByAddress(this.network, this.chain, token.toString());
|
|
37
53
|
if (found)
|
|
38
|
-
return
|
|
54
|
+
return found.decimals;
|
|
39
55
|
}
|
|
40
|
-
return this.platform.utils().getDecimals(this.chain, this.getRpc(), token);
|
|
56
|
+
return this.platform.utils().getDecimals(this.chain, await this.getRpc(), token);
|
|
41
57
|
}
|
|
42
|
-
|
|
58
|
+
/**
|
|
59
|
+
* Get the balance of a token for a given address
|
|
60
|
+
*
|
|
61
|
+
* @param walletAddr the address to get the balance for
|
|
62
|
+
* @param token the token to get the balance for
|
|
63
|
+
* @returns the balance of the token for the address
|
|
64
|
+
*
|
|
65
|
+
*/
|
|
43
66
|
async getBalance(walletAddr, token) {
|
|
44
67
|
return this.platform.utils().getBalance(this.chain, await this.getRpc(), walletAddr, token);
|
|
45
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* Get the latest block number seen by the chain according to the RPC
|
|
71
|
+
*
|
|
72
|
+
* @returns the latest block number
|
|
73
|
+
*/
|
|
46
74
|
async getLatestBlock() {
|
|
47
|
-
return this.platform.utils().getLatestBlock(this.getRpc());
|
|
75
|
+
return this.platform.utils().getLatestBlock(await this.getRpc());
|
|
48
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* Get the latest _finalized_ block number seen by the chain according to the RPC
|
|
79
|
+
*
|
|
80
|
+
* @returns the latest finalized block number
|
|
81
|
+
*/
|
|
49
82
|
async getLatestFinalizedBlock() {
|
|
50
|
-
return this.platform.utils().getLatestFinalizedBlock(this.getRpc());
|
|
83
|
+
return this.platform.utils().getLatestFinalizedBlock(await this.getRpc());
|
|
51
84
|
}
|
|
52
|
-
|
|
85
|
+
/**
|
|
86
|
+
* Parse the Wormhole Core messages from a transaction
|
|
87
|
+
*
|
|
88
|
+
* @param txid the transaction to parse
|
|
89
|
+
* @returns the Wormhole Core messages emitted by the transaction
|
|
90
|
+
*/
|
|
53
91
|
async parseTransaction(txid) {
|
|
54
92
|
return this.platform.parseWormholeMessages(this.chain, await this.getRpc(), txid);
|
|
55
93
|
}
|
|
56
|
-
|
|
94
|
+
/**
|
|
95
|
+
* Send a transaction and wait for it to be confirmed
|
|
96
|
+
*
|
|
97
|
+
* @param stxns the signed transaction to send
|
|
98
|
+
* @returns the transaction hashes of the sent transactions
|
|
99
|
+
*/
|
|
57
100
|
async sendWait(stxns) {
|
|
58
101
|
return this.platform.utils().sendWait(this.chain, await this.getRpc(), stxns);
|
|
59
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* Get the token data from the local cache if available
|
|
105
|
+
* @param symbol the symbol of the token to get
|
|
106
|
+
* @returns the token data if available
|
|
107
|
+
*/
|
|
60
108
|
getToken(symbol) {
|
|
61
109
|
if (!this.config.tokenMap)
|
|
62
110
|
return;
|
|
@@ -64,6 +112,11 @@ class ChainContext {
|
|
|
64
112
|
return;
|
|
65
113
|
return this.config.tokenMap[symbol];
|
|
66
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* Get the token id of the wrapped token for the native gas token
|
|
117
|
+
*
|
|
118
|
+
* @returns the wrapped token for the native gas token
|
|
119
|
+
*/
|
|
67
120
|
async getNativeWrappedTokenId() {
|
|
68
121
|
// see if we have it configured
|
|
69
122
|
if (this.config.wrappedNative) {
|
|
@@ -74,66 +127,131 @@ class ChainContext {
|
|
|
74
127
|
const tb = await this.getTokenBridge();
|
|
75
128
|
return { chain: this.chain, address: await tb.getWrappedNative() };
|
|
76
129
|
}
|
|
77
|
-
|
|
130
|
+
/**
|
|
131
|
+
* Get the token account for a given address and token
|
|
132
|
+
*
|
|
133
|
+
* @remarks
|
|
134
|
+
* This is really only useful in the context of Solana but in order
|
|
135
|
+
* to provide a consistent interface, we provide it here.
|
|
136
|
+
*
|
|
137
|
+
* @param address the address to get the token account for
|
|
138
|
+
* @param token the token to get the token account for
|
|
139
|
+
* @returns the token account for the address and token
|
|
140
|
+
*/
|
|
78
141
|
async getTokenAccount(address, token) {
|
|
79
142
|
// Noop by default, override in implementation if necessary
|
|
80
143
|
return { chain: this.chain, address };
|
|
81
144
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
145
|
+
/**
|
|
146
|
+
* Check to see if a given protocol is supported by this chain
|
|
147
|
+
* by checking if it is registered in the platform and the configuration
|
|
148
|
+
* is available and correct
|
|
149
|
+
*
|
|
150
|
+
* @param protocolName the name of the Protocol to check for support
|
|
151
|
+
* @returns a boolean indicating if this protocol is supported
|
|
152
|
+
*/
|
|
86
153
|
supportsProtocol(protocolName) {
|
|
87
154
|
return (0, protocol_1.protocolIsRegistered)(this.chain, protocolName);
|
|
88
155
|
}
|
|
156
|
+
/**
|
|
157
|
+
* Check to see if the Wormhole Core protocol is supported by this chain
|
|
158
|
+
* @returns a boolean indicating if this chain supports the Wormhole Core protocol
|
|
159
|
+
*/
|
|
89
160
|
supportsWormholeCore = () => this.supportsProtocol("WormholeCore");
|
|
161
|
+
/**
|
|
162
|
+
* Get the Wormhole Core protocol client for this chain
|
|
163
|
+
* @returns the Wormhole Core protocol client for this chain
|
|
164
|
+
*/
|
|
90
165
|
async getWormholeCore() {
|
|
91
166
|
this.coreBridge = this.coreBridge
|
|
92
167
|
? this.coreBridge
|
|
93
168
|
: await this.platform.getProtocol("WormholeCore", await this.getRpc());
|
|
94
169
|
return this.coreBridge;
|
|
95
170
|
}
|
|
171
|
+
/**
|
|
172
|
+
* Check to see if the Token Bridge protocol is supported by this chain
|
|
173
|
+
* @returns a boolean indicating if this chain supports the Token Bridge protocol
|
|
174
|
+
*/
|
|
96
175
|
supportsTokenBridge = () => this.supportsProtocol("TokenBridge");
|
|
176
|
+
/**
|
|
177
|
+
* Get the Token Bridge protocol client for this chain
|
|
178
|
+
* @returns the Token Bridge protocol client for this chain
|
|
179
|
+
*/
|
|
97
180
|
async getTokenBridge() {
|
|
98
181
|
this.tokenBridge = this.tokenBridge
|
|
99
182
|
? this.tokenBridge
|
|
100
183
|
: await this.platform.getProtocol("TokenBridge", await this.getRpc());
|
|
101
184
|
return this.tokenBridge;
|
|
102
185
|
}
|
|
103
|
-
|
|
186
|
+
/**
|
|
187
|
+
* Check to see if the Automatic Token Bridge protocol is supported by this chain
|
|
188
|
+
* @returns a boolean indicating if this chain supports the Automatic Token Bridge protocol
|
|
189
|
+
*/
|
|
104
190
|
supportsAutomaticTokenBridge = () => this.supportsProtocol("AutomaticTokenBridge");
|
|
191
|
+
/**
|
|
192
|
+
* Get the Automatic Token Bridge protocol client for this chain
|
|
193
|
+
* @returns the Automatic Token Bridge protocol client for this chain
|
|
194
|
+
*/
|
|
105
195
|
async getAutomaticTokenBridge() {
|
|
106
196
|
this.autoTokenBridge = this.autoTokenBridge
|
|
107
197
|
? this.autoTokenBridge
|
|
108
198
|
: await this.platform.getProtocol("AutomaticTokenBridge", await this.getRpc());
|
|
109
199
|
return this.autoTokenBridge;
|
|
110
200
|
}
|
|
111
|
-
|
|
201
|
+
/**
|
|
202
|
+
* Check to see if the Circle Bridge protocol is supported by this chain
|
|
203
|
+
* @returns a boolean indicating if this chain supports the Circle Bridge protocol
|
|
204
|
+
*/
|
|
112
205
|
supportsCircleBridge = () => this.supportsProtocol("CircleBridge");
|
|
206
|
+
/**
|
|
207
|
+
* Get the Circle Bridge protocol client for this chain
|
|
208
|
+
* @returns the Circle Bridge protocol client for this chain
|
|
209
|
+
*/
|
|
113
210
|
async getCircleBridge() {
|
|
114
211
|
this.circleBridge = this.circleBridge
|
|
115
212
|
? this.circleBridge
|
|
116
213
|
: await this.platform.getProtocol("CircleBridge", await this.getRpc());
|
|
117
214
|
return this.circleBridge;
|
|
118
215
|
}
|
|
119
|
-
|
|
216
|
+
/**
|
|
217
|
+
* Check to see if the Automatic Circle Bridge protocol is supported by this chain
|
|
218
|
+
* @returns a boolean indicating if this chain supports the Automatic Circle Bridge protocol
|
|
219
|
+
*/
|
|
120
220
|
supportsAutomaticCircleBridge = () => this.supportsProtocol("AutomaticCircleBridge");
|
|
221
|
+
/**
|
|
222
|
+
* Get the Automatic Circle Bridge protocol client for this chain
|
|
223
|
+
* @returns the Automatic Circle Bridge protocol client for this chain
|
|
224
|
+
*/
|
|
121
225
|
async getAutomaticCircleBridge() {
|
|
122
226
|
this.autoCircleBridge = this.autoCircleBridge
|
|
123
227
|
? this.autoCircleBridge
|
|
124
228
|
: await this.platform.getProtocol("AutomaticCircleBridge", await this.getRpc());
|
|
125
229
|
return this.autoCircleBridge;
|
|
126
230
|
}
|
|
127
|
-
|
|
231
|
+
/**
|
|
232
|
+
* Check to see if the IBC Bridge protocol is supported by this chain
|
|
233
|
+
* @returns a boolean indicating if this chain supports the IBC Bridge protocol
|
|
234
|
+
*/
|
|
128
235
|
supportsIbcBridge = () => this.supportsProtocol("IbcBridge");
|
|
236
|
+
/**
|
|
237
|
+
* Get the IBC Bridge protocol client for this chain
|
|
238
|
+
* @returns the IBC Bridge protocol client for this chain
|
|
239
|
+
*/
|
|
129
240
|
async getIbcBridge() {
|
|
130
241
|
this.ibcBridge = this.ibcBridge
|
|
131
242
|
? this.ibcBridge
|
|
132
243
|
: await this.platform.getProtocol("IbcBridge", await this.getRpc());
|
|
133
244
|
return this.ibcBridge;
|
|
134
245
|
}
|
|
135
|
-
|
|
246
|
+
/**
|
|
247
|
+
* Check to see if the Portico Bridge protocol is supported by this chain
|
|
248
|
+
* @returns a boolean indicating if this chain supports the Portico Bridge protocol
|
|
249
|
+
*/
|
|
136
250
|
supportsPorticoBridge = () => this.supportsProtocol("PorticoBridge");
|
|
251
|
+
/**
|
|
252
|
+
* Get the Portico Bridge protocol client for this chain
|
|
253
|
+
* @returns the Portico Bridge protocol client for this chain
|
|
254
|
+
*/
|
|
137
255
|
async getPorticoBridge() {
|
|
138
256
|
this.porticoBridge = this.porticoBridge
|
|
139
257
|
? this.porticoBridge
|