@wormhole-foundation/sdk-aptos-core 0.5.0-alpha.3 → 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.
@@ -0,0 +1,20 @@
1
+ import type { ChainId, ChainsConfig, Contracts, Network, UnsignedTransaction, VAA, WormholeCore, WormholeMessageId } from "@wormhole-foundation/sdk-connect";
2
+ import type { AnyAptosAddress, AptosChains, AptosPlatformType } from "@wormhole-foundation/sdk-aptos";
3
+ import type { AptosClient } from "aptos";
4
+ export declare class AptosWormholeCore<N extends Network, C extends AptosChains> implements WormholeCore<N, C> {
5
+ readonly network: N;
6
+ readonly chain: C;
7
+ readonly connection: AptosClient;
8
+ readonly contracts: Contracts;
9
+ readonly chainId: ChainId;
10
+ readonly coreBridge: string;
11
+ private constructor();
12
+ getGuardianSetIndex(): Promise<number>;
13
+ getMessageFee(): Promise<bigint>;
14
+ static fromRpc<N extends Network>(connection: AptosClient, config: ChainsConfig<N, AptosPlatformType>): Promise<AptosWormholeCore<N, AptosChains>>;
15
+ publishMessage(sender: AnyAptosAddress, message: string | Uint8Array): AsyncGenerator<UnsignedTransaction<N, C>>;
16
+ verifyMessage(sender: AnyAptosAddress, vaa: VAA): AsyncGenerator<never, void, unknown>;
17
+ parseTransaction(txid: string): Promise<WormholeMessageId[]>;
18
+ parseMessages(txid: string): Promise<VAA[]>;
19
+ }
20
+ //# sourceMappingURL=core.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/core.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,YAAY,EACZ,SAAS,EACT,OAAO,EACP,mBAAmB,EACnB,GAAG,EACH,YAAY,EACZ,iBAAiB,EAClB,MAAM,kCAAkC,CAAC;AAE1C,OAAO,KAAK,EACV,eAAe,EACf,WAAW,EACX,iBAAiB,EAClB,MAAM,gCAAgC,CAAC;AAExC,OAAO,KAAK,EAAE,WAAW,EAAS,MAAM,OAAO,CAAC;AAEhD,qBAAa,iBAAiB,CAAC,CAAC,SAAS,OAAO,EAAE,CAAC,SAAS,WAAW,CACrE,YAAW,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC;IAM3B,QAAQ,CAAC,OAAO,EAAE,CAAC;IACnB,QAAQ,CAAC,KAAK,EAAE,CAAC;IACjB,QAAQ,CAAC,UAAU,EAAE,WAAW;IAChC,QAAQ,CAAC,SAAS,EAAE,SAAS;IAP/B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAE5B,OAAO;IAYP,mBAAmB,IAAI,OAAO,CAAC,MAAM,CAAC;IAGtC,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;WAInB,OAAO,CAAC,CAAC,SAAS,OAAO,EACpC,UAAU,EAAE,WAAW,EACvB,MAAM,EAAE,YAAY,CAAC,CAAC,EAAE,iBAAiB,CAAC,GACzC,OAAO,CAAC,iBAAiB,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC;IAQtC,cAAc,CACnB,MAAM,EAAE,eAAe,EACvB,OAAO,EAAE,MAAM,GAAG,UAAU,GAC3B,cAAc,CAAC,mBAAmB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAGrC,aAAa,CAAC,MAAM,EAAE,eAAe,EAAE,GAAG,EAAE,GAAG;IAIhD,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAW5D,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;CAqClD"}
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AptosWormholeCore = void 0;
4
+ const sdk_connect_1 = require("@wormhole-foundation/sdk-connect");
5
+ const sdk_aptos_1 = require("@wormhole-foundation/sdk-aptos");
6
+ class AptosWormholeCore {
7
+ network;
8
+ chain;
9
+ connection;
10
+ contracts;
11
+ chainId;
12
+ coreBridge;
13
+ constructor(network, chain, connection, contracts) {
14
+ this.network = network;
15
+ this.chain = chain;
16
+ this.connection = connection;
17
+ this.contracts = contracts;
18
+ this.chainId = (0, sdk_connect_1.toChainId)(chain);
19
+ const coreBridgeAddress = contracts.coreBridge;
20
+ if (!coreBridgeAddress)
21
+ throw new Error(`CoreBridge contract Address for chain ${chain} not found`);
22
+ this.coreBridge = coreBridgeAddress;
23
+ }
24
+ getGuardianSetIndex() {
25
+ throw new Error("Method not implemented.");
26
+ }
27
+ getMessageFee() {
28
+ throw new Error("Method not implemented.");
29
+ }
30
+ static async fromRpc(connection, config) {
31
+ const [network, chain] = await sdk_aptos_1.AptosPlatform.chainFromRpc(connection);
32
+ const conf = config[chain];
33
+ if (conf.network !== network)
34
+ throw new Error(`Network mismatch: ${conf.network} !== ${network}`);
35
+ return new AptosWormholeCore(network, chain, connection, conf.contracts);
36
+ }
37
+ async *publishMessage(sender, message) {
38
+ throw new Error("Method not implemented.");
39
+ }
40
+ async *verifyMessage(sender, vaa) {
41
+ throw new Error("Not implemented.");
42
+ }
43
+ async parseTransaction(txid) {
44
+ const msgs = await this.parseMessages(txid);
45
+ return msgs.map((message) => {
46
+ return {
47
+ chain: message.emitterChain,
48
+ emitter: message.emitterAddress,
49
+ sequence: message.sequence,
50
+ };
51
+ });
52
+ }
53
+ async parseMessages(txid) {
54
+ const transaction = await this.connection.getTransactionByHash(txid);
55
+ if (transaction.type !== "user_transaction")
56
+ throw new Error(`${txid} is not a user_transaction`);
57
+ const userTransaction = transaction;
58
+ const messages = userTransaction.events.filter((event) => event.type.endsWith("WormholeMessage"));
59
+ if (!messages || messages.length === 0)
60
+ throw new Error(`WormholeMessage not found for ${txid}`);
61
+ return messages.map((message) => {
62
+ const msg = message.data;
63
+ const emitter = new sdk_connect_1.UniversalAddress(BigInt(msg.sender).toString(16).padStart(64, "0"));
64
+ return (0, sdk_connect_1.createVAA)("Uint8Array", {
65
+ guardianSet: 0,
66
+ emitterChain: this.chain,
67
+ emitterAddress: emitter,
68
+ sequence: BigInt(msg.sequence),
69
+ timestamp: Number(msg.timestamp),
70
+ consistencyLevel: msg.consistency_level,
71
+ nonce: Number(msg.nonce),
72
+ signatures: [],
73
+ payload: sdk_connect_1.encoding.hex.decode(msg.payload),
74
+ });
75
+ });
76
+ }
77
+ }
78
+ exports.AptosWormholeCore = AptosWormholeCore;
79
+ //# sourceMappingURL=core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.js","sourceRoot":"","sources":["../../src/core.ts"],"names":[],"mappings":";;;AAUA,kEAAoG;AAMpG,8DAA+D;AAG/D,MAAa,iBAAiB;IAOjB;IACA;IACA;IACA;IAPF,OAAO,CAAU;IACjB,UAAU,CAAS;IAE5B,YACW,OAAU,EACV,KAAQ,EACR,UAAuB,EACvB,SAAoB;QAHpB,YAAO,GAAP,OAAO,CAAG;QACV,UAAK,GAAL,KAAK,CAAG;QACR,eAAU,GAAV,UAAU,CAAa;QACvB,cAAS,GAAT,SAAS,CAAW;QAE7B,IAAI,CAAC,OAAO,GAAG,IAAA,uBAAS,EAAC,KAAK,CAAC,CAAC;QAChC,MAAM,iBAAiB,GAAG,SAAS,CAAC,UAAU,CAAC;QAC/C,IAAI,CAAC,iBAAiB;YACpB,MAAM,IAAI,KAAK,CAAC,yCAAyC,KAAK,YAAY,CAAC,CAAC;QAC9E,IAAI,CAAC,UAAU,GAAG,iBAAiB,CAAC;IACtC,CAAC;IACD,mBAAmB;QACjB,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IACD,aAAa;QACX,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,OAAO,CAClB,UAAuB,EACvB,MAA0C;QAE1C,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,GAAG,MAAM,yBAAa,CAAC,YAAY,CAAC,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 var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ const sdk_connect_1 = require("@wormhole-foundation/sdk-connect");
18
+ const core_js_1 = require("./core.js");
19
+ (0, sdk_connect_1.registerProtocol)("Aptos", "WormholeCore", core_js_1.AptosWormholeCore);
20
+ __exportStar(require("./core.js"), exports);
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kEAAoE;AACpE,uCAA8C;AAE9C,IAAA,8BAAgB,EAAC,OAAO,EAAE,cAAc,EAAE,2BAAiB,CAAC,CAAC;AAE7D,4CAA0B"}
@@ -1,2 +1,2 @@
1
- export { AptosWormholeCore } from "./core.js";
1
+ export * from "./core.js";
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAKA,cAAc,WAAW,CAAC"}
package/dist/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { registerProtocol } from "@wormhole-foundation/sdk-connect";
2
2
  import { AptosWormholeCore } from "./core.js";
3
3
  registerProtocol("Aptos", "WormholeCore", AptosWormholeCore);
4
- export { AptosWormholeCore } from "./core.js";
4
+ export * from "./core.js";
5
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C,gBAAgB,CAAC,OAAO,EAAE,cAAc,EAAE,iBAAiB,CAAC,CAAC;AAE7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C,gBAAgB,CAAC,OAAO,EAAE,cAAc,EAAE,iBAAiB,CAAC,CAAC;AAE7D,cAAc,WAAW,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wormhole-foundation/sdk-aptos-core",
3
- "version": "0.5.0-alpha.3",
3
+ "version": "0.5.0-alpha.4",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/wormhole-foundation/connect-sdk.git"
@@ -18,7 +18,8 @@
18
18
  "types": "./dist/esm/index.d.ts",
19
19
  "description": "SDK for Solana, used in conjunction with @wormhole-foundation/connect-sdk",
20
20
  "files": [
21
- "dist/esm"
21
+ "dist/esm",
22
+ "dist/cjs"
22
23
  ],
23
24
  "keywords": [
24
25
  "wormhole",
@@ -33,18 +34,26 @@
33
34
  "sideEffects": true,
34
35
  "scripts": {
35
36
  "build:cjs": "tsc -p ./tsconfig.cjs.json",
36
- "build": "tsc -p ./tsconfig.esm.json",
37
+ "build": "npm run build:esm && npm run build:cjs",
37
38
  "rebuild": "npm run clean && npm run build",
38
39
  "clean": "rm -rf ./dist && rm -rf ./.turbo",
39
40
  "lint": "npm run prettier && eslint --fix ./src --ext .ts",
40
- "prettier": "prettier --write ./src"
41
+ "prettier": "prettier --write ./src",
42
+ "build:esm": "tsc -p ./tsconfig.esm.json"
41
43
  },
42
44
  "devDependencies": {
43
45
  "nock": "^13.3.3"
44
46
  },
45
47
  "dependencies": {
46
- "@wormhole-foundation/sdk-connect": "0.5.0-alpha.3",
47
- "@wormhole-foundation/sdk-aptos": "0.5.0-alpha.3"
48
+ "@wormhole-foundation/sdk-connect": "0.5.0-alpha.4",
49
+ "@wormhole-foundation/sdk-aptos": "0.5.0-alpha.4"
48
50
  },
49
- "type": "module"
51
+ "type": "module",
52
+ "exports": {
53
+ ".": {
54
+ "import": "./dist/esm/index.js",
55
+ "types": "./dist/esm/index.d.ts",
56
+ "require": "./dist/cjs/index.js"
57
+ }
58
+ }
50
59
  }