-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
1,267 additions
and
3,670 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"env": { | ||
"node": true | ||
}, | ||
"root": true, | ||
"parser": "@typescript-eslint/parser", | ||
"plugins": ["@typescript-eslint"], | ||
"extends": [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
"prettier" | ||
], | ||
"rules": { | ||
"comma-dangle": ["error", "always-multiline"], | ||
"semi": ["error", "always"], | ||
"@typescript-eslint/explicit-module-boundary-types": ["error"], | ||
"@typescript-eslint/no-non-null-assertion": ["error"], | ||
"@typescript-eslint/no-explicit-any": ["error", { "ignoreRestArgs": true }] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
{ | ||
"name": "@wormhole-foundation/connect-sdk-sui", | ||
"version": "0.2.5", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/wormhole-foundation/connect-sdk.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/wormhole-foundation/connect-sdk/issues" | ||
}, | ||
"homepage": "https://github.com/wormhole-foundation/connect-sdk#readme", | ||
"directories": { | ||
"test": "tests" | ||
}, | ||
"license": "Apache-2.0", | ||
"main": "./dist/cjs/index.js", | ||
"module": "./dist/esm/index.js", | ||
"types": "./dist/esm/index.d.ts", | ||
"author": "", | ||
"description": "SDK for EVM chains, used in conjunction with @wormhole-foundation/connect-sdk", | ||
"files": [ | ||
"dist/**/*", | ||
"src/**/*" | ||
], | ||
"keywords": [ | ||
"wormhole", | ||
"sdk", | ||
"typescript", | ||
"connect", | ||
"sui" | ||
], | ||
"engines": { | ||
"node": ">=16" | ||
}, | ||
"sideEffects": false, | ||
"scripts": { | ||
"build:cjs": "tsc -p ./tsconfig.cjs.json", | ||
"build:esm": "tsc -p ./tsconfig.esm.json", | ||
"build": "npm run build:cjs && npm run build:esm", | ||
"rebuild": "npm run clean && npm run build:cjs && npm run build:esm", | ||
"clean": "rm -rf ./dist && rm -f ./*.tsbuildinfo", | ||
"lint": "npm run prettier && eslint --fix", | ||
"prettier": "prettier --write ./src", | ||
"bump:beta": "bump prerelease", | ||
"test": "jest --config ./jest.config.ts" | ||
}, | ||
"dependencies": { | ||
"@wormhole-foundation/connect-sdk": "^0.2.5", | ||
"@mysten/sui.js": "^0.32.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{ | ||
"name": "@wormhole-foundation/connect-sdk-sui-core", | ||
"version": "0.2.5", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/wormhole-foundation/connect-sdk.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/wormhole-foundation/connect-sdk/issues" | ||
}, | ||
"homepage": "https://github.com/wormhole-foundation/connect-sdk#readme", | ||
"directories": { | ||
"test": "tests" | ||
}, | ||
"license": "Apache-2.0", | ||
"main": "./dist/cjs/index.js", | ||
"module": "./dist/esm/index.js", | ||
"types": "./dist/esm/index.d.ts", | ||
"author": "", | ||
"description": "SDK for Sui chains, used in conjunction with @wormhole-foundation/connect-sdk", | ||
"files": [ | ||
"dist/**/*", | ||
"src/**/*" | ||
], | ||
"keywords": [ | ||
"wormhole", | ||
"sdk", | ||
"typescript", | ||
"connect", | ||
"sui" | ||
], | ||
"engines": { | ||
"node": ">=16" | ||
}, | ||
"sideEffects": false, | ||
"scripts": { | ||
"build:cjs": "tsc -p ./tsconfig.cjs.json", | ||
"build:esm": "tsc -p ./tsconfig.esm.json", | ||
"build": "npm run build:cjs && npm run build:esm", | ||
"rebuild": "npm run clean && npm run build:cjs && npm run build:esm", | ||
"clean": "rm -rf ./dist && rm -f ./*.tsbuildinfo", | ||
"lint": "npm run prettier && eslint --fix", | ||
"bump:beta": "bump prerelease", | ||
"prettier": "prettier --write ./src" | ||
}, | ||
"dependencies": { | ||
"@wormhole-foundation/connect-sdk": "^0.2.5", | ||
"@wormhole-foundation/connect-sdk-sui": "^0.2.5" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { JsonRpcProvider } from "@mysten/sui.js"; | ||
import { | ||
AccountAddress, | ||
ChainId, | ||
ChainsConfig, | ||
Contracts, | ||
Network, | ||
PayloadLiteral, | ||
VAA, | ||
WormholeCore, | ||
WormholeMessageId, | ||
toChainId, | ||
} from "@wormhole-foundation/connect-sdk"; | ||
import { | ||
AnySuiAddress, | ||
SuiChains, | ||
SuiPlatform, | ||
SuiPlatformType, | ||
} from "@wormhole-foundation/connect-sdk-sui"; | ||
|
||
export class SuiWormholeCore<N extends Network, C extends SuiChains> | ||
implements WormholeCore<N, SuiPlatformType, C> | ||
{ | ||
readonly chainId: ChainId; | ||
readonly coreBridge: string; | ||
|
||
private constructor( | ||
readonly network: N, | ||
readonly chain: C, | ||
readonly connection: JsonRpcProvider, | ||
readonly contracts: Contracts, | ||
) { | ||
this.chainId = toChainId(chain); | ||
const coreBridgeAddress = contracts.coreBridge; | ||
if (!coreBridgeAddress) | ||
throw new Error(`CoreBridge contract Address for chain ${chain} not found`); | ||
this.coreBridge = coreBridgeAddress; | ||
} | ||
|
||
static async fromRpc<N extends Network>( | ||
connection: JsonRpcProvider, | ||
config: ChainsConfig<N, SuiPlatformType>, | ||
): Promise<SuiWormholeCore<N, SuiChains>> { | ||
const [network, chain] = await SuiPlatform.chainFromRpc(connection); | ||
const conf = config[chain]!; | ||
if (conf.network !== network) | ||
throw new Error(`Network mismatch: ${conf.network} !== ${network}`); | ||
return new SuiWormholeCore(network as N, chain, connection, conf.contracts); | ||
} | ||
|
||
async *verifyMessage(sender: AccountAddress<C>, vaa: VAA<PayloadLiteral>) { | ||
throw new Error("Method not implemented."); | ||
} | ||
|
||
async *publishMessage(sender: AnySuiAddress, message: string | Uint8Array) { | ||
throw new Error("Method not implemented."); | ||
} | ||
|
||
async parseTransaction(txid: string): Promise<WormholeMessageId[]> { | ||
throw new Error("Not implemented"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { registerProtocol } from "@wormhole-foundation/connect-sdk"; | ||
import { SuiWormholeCore } from "./core"; | ||
|
||
declare global { | ||
namespace Wormhole { | ||
export interface PlatformToProtocolMapping { | ||
Sui: {}; | ||
} | ||
} | ||
} | ||
|
||
registerProtocol("Sui", "WormholeCore", SuiWormholeCore); | ||
|
||
export * from "./core"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"extends": "../../../../tsconfig.cjs.json", | ||
"include": ["src"], | ||
"compilerOptions": { | ||
"outDir": "dist/cjs", | ||
"rootDir": "src" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"extends": "../../../../tsconfig.esm.json", | ||
"include": ["src"], | ||
"compilerOptions": { | ||
"outDir": "dist/esm", | ||
"rootDir": "src" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"extends": ["../../../../typedoc.base.json"], | ||
"entryPoints": ["src/index.ts"], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{ | ||
"name": "@wormhole-foundation/connect-sdk-sui-tokenbridge", | ||
"version": "0.2.5", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/wormhole-foundation/connect-sdk.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/wormhole-foundation/connect-sdk/issues" | ||
}, | ||
"homepage": "https://github.com/wormhole-foundation/connect-sdk#readme", | ||
"directories": { | ||
"test": "tests" | ||
}, | ||
"license": "Apache-2.0", | ||
"main": "./dist/cjs/index.js", | ||
"module": "./dist/esm/index.js", | ||
"types": "./dist/esm/index.d.ts", | ||
"author": "", | ||
"description": "SDK for Sui chains, used in conjunction with @wormhole-foundation/connect-sdk", | ||
"files": [ | ||
"dist/**/*", | ||
"src/**/*" | ||
], | ||
"keywords": [ | ||
"wormhole", | ||
"sdk", | ||
"typescript", | ||
"connect", | ||
"sui" | ||
], | ||
"engines": { | ||
"node": ">=16" | ||
}, | ||
"sideEffects": false, | ||
"scripts": { | ||
"build:cjs": "tsc -p ./tsconfig.cjs.json", | ||
"build:esm": "tsc -p ./tsconfig.esm.json", | ||
"build": "npm run build:cjs && npm run build:esm", | ||
"rebuild": "npm run clean && npm run build:cjs && npm run build:esm", | ||
"clean": "rm -rf ./dist && rm -f ./*.tsbuildinfo", | ||
"lint": "npm run prettier && eslint --fix", | ||
"bump:beta": "bump prerelease", | ||
"prettier": "prettier --write ./src" | ||
}, | ||
"dependencies": { | ||
"@wormhole-foundation/connect-sdk": "^0.2.5", | ||
"@wormhole-foundation/connect-sdk-sui": "^0.2.5" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { registerProtocol } from "@wormhole-foundation/connect-sdk"; | ||
import { SuiTokenBridge } from "./tokenBridge"; | ||
//import { SuiAutomaticTokenBridge } from "./automaticTokenBridge"; | ||
|
||
declare global { | ||
namespace Wormhole { | ||
export interface PlatformToProtocolMapping { | ||
Sui: {}; | ||
} | ||
} | ||
} | ||
|
||
registerProtocol("Sui", "TokenBridge", SuiTokenBridge); | ||
|
||
export * from "./tokenBridge"; |
Oops, something went wrong.