-
Notifications
You must be signed in to change notification settings - Fork 69
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
28 changed files
with
976 additions
and
2,765 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,49 @@ | ||
{ | ||
"name": "@wormhole-foundation/connect-sdk-algorand", | ||
"version": "0.3.0-beta.3", | ||
"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", | ||
"algorand" | ||
], | ||
"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" | ||
}, | ||
"dependencies": { | ||
"@wormhole-foundation/connect-sdk": "^0.3.0-beta.3", | ||
"algosdk": "2.7.0" | ||
} | ||
} |
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,49 @@ | ||
{ | ||
"name": "@wormhole-foundation/connect-sdk-algorand-core", | ||
"version": "0.3.0-beta.3", | ||
"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", | ||
"algorand" | ||
], | ||
"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" | ||
}, | ||
"dependencies": { | ||
"@wormhole-foundation/connect-sdk": "^0.3.0-beta.3", | ||
"@wormhole-foundation/connect-sdk-algorand": "^0.3.0-beta.3" | ||
} | ||
} |
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,68 @@ | ||
import { | ||
AccountAddress, | ||
ChainId, | ||
ChainsConfig, | ||
Contracts, | ||
Network, | ||
PayloadLiteral, | ||
UnsignedTransaction, | ||
VAA, | ||
WormholeCore, | ||
WormholeMessageId, | ||
toChainId, | ||
} from "@wormhole-foundation/connect-sdk"; | ||
import { | ||
AlgorandChains, | ||
AlgorandPlatform, | ||
AlgorandPlatformType, | ||
AnyAlgorandAddress, | ||
} from "@wormhole-foundation/connect-sdk-algorand"; | ||
import { Algodv2 } from "algosdk"; | ||
|
||
export class AlgorandWormholeCore<N extends Network, C extends AlgorandChains> | ||
implements WormholeCore<N, AlgorandPlatformType, C> | ||
{ | ||
readonly chainId: ChainId; | ||
readonly coreBridge: string; | ||
|
||
private constructor( | ||
readonly network: N, | ||
readonly chain: C, | ||
readonly connection: Algodv2, | ||
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; | ||
} | ||
verifyMessage( | ||
sender: AccountAddress<C>, | ||
vaa: VAA<PayloadLiteral>, | ||
): AsyncGenerator<UnsignedTransaction<N, C>, any, unknown> { | ||
throw new Error("Method not implemented."); | ||
} | ||
|
||
static async fromRpc<N extends Network>( | ||
connection: Algodv2, | ||
config: ChainsConfig<N, AlgorandPlatformType>, | ||
): Promise<AlgorandWormholeCore<N, AlgorandChains>> { | ||
const [network, chain] = await AlgorandPlatform.chainFromRpc(connection); | ||
const conf = config[chain]!; | ||
if (conf.network !== network) | ||
throw new Error(`Network mismatch: ${conf.network} !== ${network}`); | ||
return new AlgorandWormholeCore(network as N, chain, connection, conf.contracts); | ||
} | ||
|
||
async *publishMessage( | ||
sender: AnyAlgorandAddress, | ||
message: string | Uint8Array, | ||
): AsyncGenerator<UnsignedTransaction<N, C>> { | ||
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,15 @@ | ||
import { _platform } from "@wormhole-foundation/connect-sdk-algorand"; | ||
import { registerProtocol } from "@wormhole-foundation/connect-sdk"; | ||
import { AlgorandWormholeCore } from "./core"; | ||
|
||
declare global { | ||
namespace WormholeNamespace { | ||
export interface PlatformToProtocolMapping { | ||
Algorand: {}; | ||
} | ||
} | ||
} | ||
|
||
registerProtocol(_platform, "WormholeCore", AlgorandWormholeCore); | ||
|
||
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,49 @@ | ||
{ | ||
"name": "@wormhole-foundation/connect-sdk-algorand-tokenbridge", | ||
"version": "0.3.0-beta.3", | ||
"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", | ||
"algorand" | ||
], | ||
"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" | ||
}, | ||
"dependencies": { | ||
"@wormhole-foundation/connect-sdk": "^0.3.0-beta.3", | ||
"@wormhole-foundation/connect-sdk-algorand": "^0.3.0-beta.3" | ||
} | ||
} |
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,16 @@ | ||
import { _platform } from "@wormhole-foundation/connect-sdk-algorand"; | ||
import { registerProtocol } from "@wormhole-foundation/connect-sdk"; | ||
import { AlgorandTokenBridge } from "./tokenBridge"; | ||
//import { AlgorandAutomaticTokenBridge } from "./automaticTokenBridge"; | ||
|
||
declare global { | ||
namespace WormholeNamespace { | ||
export interface PlatformToProtocolMapping { | ||
Algorand: {}; | ||
} | ||
} | ||
} | ||
|
||
registerProtocol(_platform, "TokenBridge", AlgorandTokenBridge); | ||
|
||
export * from "./tokenBridge"; |
Oops, something went wrong.