-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
21315a2
commit ed01b70
Showing
23 changed files
with
8,669 additions
and
673 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -128,3 +128,6 @@ dist | |
.yarn/build-state.yml | ||
.yarn/install-state.gz | ||
.pnp.* | ||
|
||
.nx | ||
**/packages/*/build/ |
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,7 @@ | ||
# Oraichain Ton Bridge Relayer | ||
|
||
# patch a package: | ||
|
||
```bash | ||
yarn patch-package | ||
``` |
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,19 @@ | ||
// jest.config.js | ||
module.exports = { | ||
transform: { | ||
"^.+\\.ts?$": ["@swc/jest"] | ||
}, | ||
testEnvironment: "node", | ||
modulePathIgnorePatterns: ["<rootDir>/dist/", "<rootDir>/packages/contracts-demo/src/ton-rocks-js"], | ||
collectCoverage: true, | ||
coverageReporters: ["cobertura", "html"], | ||
coveragePathIgnorePatterns: [ | ||
"<rootDir>/packages/contracts-sdk", | ||
"<rootDir>/packages/contracts-build", | ||
"<rootDir>/packages/.+/build", // ignore every build/ of every sub directory of packages | ||
"<rootDir>/packages/.+/dist", | ||
"<rootDir>/node_modules/", | ||
"<rootDir>/packages/.+/node_modules/", | ||
"<rootDir>/packages/.+/tests/" | ||
] | ||
}; |
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,10 @@ | ||
{ | ||
"$schema": "node_modules/lerna/schemas/lerna-schema.json", | ||
"npmClient": "yarn", | ||
"version": "1.0.7", | ||
"command": { | ||
"publish": { | ||
"registry": "https://registry.npmjs.org/" | ||
} | ||
} | ||
} |
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,25 @@ | ||
{ | ||
"tasksRunnerOptions": { | ||
"default": { | ||
"options": {} | ||
} | ||
}, | ||
"targetDefaults": { | ||
"build": { | ||
"dependsOn": ["^build"], | ||
"cache": true | ||
}, | ||
"cli": { | ||
"packageManager": "yarn" | ||
}, | ||
"test": { | ||
"cache": true | ||
} | ||
}, | ||
"namedInputs": { | ||
"default": ["{projectRoot}/**/*", "sharedGlobals"], | ||
"sharedGlobals": [], | ||
"production": ["default"] | ||
}, | ||
"cacheDirectory": "node_modules/.cache" | ||
} |
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,61 @@ | ||
{ | ||
"name": "root", | ||
"private": "true", | ||
"license": "MIT", | ||
"scripts": { | ||
"postinstall": "patch-package", | ||
"test": "yarn build && jest", | ||
"clean": "lerna clean --yes && lerna exec -- rimraf build/ dist/ cache/", | ||
"build": "lerna run build --concurrency 1", | ||
"build-tsc": "tsc -p", | ||
"deploy": "yarn publish --access public", | ||
"prepare": "husky install", | ||
"build:docker": "lerna run build --concurrency 1" | ||
}, | ||
"workspaces": [ | ||
"packages/*" | ||
], | ||
"engines": { | ||
"node": ">=18.18.0" | ||
}, | ||
"dependencies": { | ||
"@cosmjs/amino": "0.31.3", | ||
"@cosmjs/cosmwasm-stargate": "0.31.3", | ||
"@cosmjs/crypto": "0.31.3", | ||
"@cosmjs/proto-signing": "0.31.3", | ||
"@cosmjs/stargate": "0.31.3", | ||
"@cosmjs/tendermint-rpc": "0.31.3", | ||
"buffer": "^6.0.3" | ||
}, | ||
"devDependencies": { | ||
"@babel/traverse": "7.24.1", | ||
"@cosmjs/encoding": "0.31.3", | ||
"@oraichain/cw-simulate": "^2.8.68", | ||
"@swc/core": "^1.4.11", | ||
"@swc/jest": "^0.2.36", | ||
"@types/jest": "^29.5.12", | ||
"@types/lodash": "^4.17.0", | ||
"@types/node": "^20.11.30", | ||
"@typescript-eslint/eslint-plugin": "^7.3.1", | ||
"@typescript-eslint/parser": "^7.3.1", | ||
"cosmjs-types": "0.8.0", | ||
"cz-conventional-changelog": "^3.3.0", | ||
"dotenv": "^16.4.5", | ||
"eslint": "^8.57.0", | ||
"eslint-import-resolver-typescript": "^3.6.1", | ||
"eslint-plugin-import": "^2.29.1", | ||
"eslint-plugin-security": "^2.1.1", | ||
"husky": "^9.0.11", | ||
"jest": "^29.7.0", | ||
"lerna": "^8.1.3", | ||
"nx": "19.2.1", | ||
"patch-package": "^8.0.0", | ||
"rimraf": "^5.0.5", | ||
"ts-jest": "^29.1.4", | ||
"ts-node": "^10.9.2", | ||
"ts-node-dev": "^2.0.0", | ||
"typedoc": "^0.25.12", | ||
"typescript": "5.4.5" | ||
}, | ||
"version": "1.0.1" | ||
} |
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,3 @@ | ||
# tonbridge-utils | ||
|
||
Most files are from `https://github.com/oraichain/ton-trustless-bridge-relayer/tree/master/src/lib/ton-rocks-js` and `https://github.com/oraichain/ton-trustless-bridge-relayer/tree/master/src/lib` |
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,17 @@ | ||
{ | ||
"name": "@oraichain/tonbridge-relayer-common", | ||
"version": "1.0.0", | ||
"main": "build/index.js", | ||
"license": "MIT", | ||
"scripts": { | ||
"build": "tsc -p tsconfig.json" | ||
}, | ||
"files": [ | ||
"src/*", | ||
"build/" | ||
], | ||
"dependencies": { | ||
"@ton/ton": "^13.11.1", | ||
"@ton/core": "^0.56.3" | ||
} | ||
} |
Empty file.
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 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"outDir": "build", | ||
"declaration": true, | ||
"rootDir": "src" | ||
}, | ||
"include": [ | ||
"src/**/*.ts" | ||
, "src/types/Block.ts" ], | ||
"exclude": [ | ||
"node_modules/" | ||
] | ||
} |
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,17 @@ | ||
{ | ||
"name": "@oraichain/tonbridge-relayer-to-ton", | ||
"version": "1.0.0", | ||
"main": "build/index.js", | ||
"files": [ | ||
"build/" | ||
], | ||
"scripts": { | ||
"build": "tsc -p tsconfig.json" | ||
}, | ||
"license": "MIT", | ||
"dependencies": {}, | ||
"devDependencies": {}, | ||
"resolutions": { | ||
"bech32": "1.1.4" | ||
} | ||
} |
Empty file.
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,17 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"outDir": "build", | ||
"declaration": true, | ||
"strict": false, | ||
"rootDir": "src" | ||
}, | ||
"include": [ | ||
"src/**/*.ts", | ||
"@types/**/*.ts" | ||
], | ||
"exclude": [ | ||
"node_modules/" | ||
] | ||
} |
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,13 @@ | ||
{ | ||
"name": "@oraichain/tonbridge-relayer-to-cw", | ||
"version": "1.0.0", | ||
"main": "build/index.js", | ||
"files": [ | ||
"build/", | ||
"@types" | ||
], | ||
"scripts": { | ||
"build": "tsc -p tsconfig.json" | ||
}, | ||
"license": "MIT" | ||
} |
Empty file.
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 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"outDir": "build", | ||
"declaration": true, | ||
"rootDir": "src" | ||
}, | ||
"include": [ | ||
"src/**/*.ts", | ||
"@types/**/*.ts" | ||
], | ||
"exclude": [ | ||
"node_modules/" | ||
] | ||
} |
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,45 @@ | ||
diff --git a/node_modules/@cosmjs/cosmwasm-stargate/build/cosmwasmclient.d.ts b/node_modules/@cosmjs/cosmwasm-stargate/build/cosmwasmclient.d.ts | ||
index 3aebdc5..d5cbeec 100644 | ||
--- a/node_modules/@cosmjs/cosmwasm-stargate/build/cosmwasmclient.d.ts | ||
+++ b/node_modules/@cosmjs/cosmwasm-stargate/build/cosmwasmclient.d.ts | ||
@@ -56,6 +56,7 @@ export declare class CosmWasmClient { | ||
*/ | ||
static create(tmClient: TendermintClient): Promise<CosmWasmClient>; | ||
protected constructor(tmClient: TendermintClient | undefined); | ||
+ public setQueryClientWithHeight(height?: number): void; | ||
protected getTmClient(): TendermintClient | undefined; | ||
protected forceGetTmClient(): TendermintClient; | ||
protected getQueryClient(): (QueryClient & AuthExtension & BankExtension & TxExtension & WasmExtension) | undefined; | ||
diff --git a/node_modules/@cosmjs/cosmwasm-stargate/build/cosmwasmclient.js b/node_modules/@cosmjs/cosmwasm-stargate/build/cosmwasmclient.js | ||
index 8f6305b..90cedba 100644 | ||
--- a/node_modules/@cosmjs/cosmwasm-stargate/build/cosmwasmclient.js | ||
+++ b/node_modules/@cosmjs/cosmwasm-stargate/build/cosmwasmclient.js | ||
@@ -46,6 +46,13 @@ class CosmWasmClient { | ||
this.queryClient = stargate_1.QueryClient.withExtensions(tmClient, stargate_1.setupAuthExtension, stargate_1.setupBankExtension, modules_1.setupWasmExtension, stargate_1.setupTxExtension); | ||
} | ||
} | ||
+ | ||
+ setQueryClientWithHeight(height = undefined) { | ||
+ if (this.tmClient) { | ||
+ this.queryClient = stargate_1.QueryClient.withExtensionsWithHeight(this.tmClient, height, stargate_1.setupAuthExtension, stargate_1.setupBankExtension, modules_1.setupWasmExtension, stargate_1.setupTxExtension); | ||
+ } | ||
+ } | ||
+ | ||
getTmClient() { | ||
return this.tmClient; | ||
} | ||
diff --git a/node_modules/@cosmjs/cosmwasm-stargate/build/modules/wasm/queries.js b/node_modules/@cosmjs/cosmwasm-stargate/build/modules/wasm/queries.js | ||
index c060369..41029c3 100644 | ||
--- a/node_modules/@cosmjs/cosmwasm-stargate/build/modules/wasm/queries.js | ||
+++ b/node_modules/@cosmjs/cosmwasm-stargate/build/modules/wasm/queries.js | ||
@@ -8,8 +8,8 @@ const encoding_1 = require("@cosmjs/encoding"); | ||
const stargate_1 = require("@cosmjs/stargate"); | ||
const query_1 = require("cosmjs-types/cosmwasm/wasm/v1/query"); | ||
const long_1 = __importDefault(require("long")); | ||
-function setupWasmExtension(base) { | ||
- const rpc = (0, stargate_1.createProtobufRpcClient)(base); | ||
+function setupWasmExtension(base, height) { | ||
+ const rpc = (0, stargate_1.createProtobufRpcClient)(base, height); | ||
// Use this service to get easy typed access to query methods | ||
// This cannot be used for proof verification | ||
const queryService = new query_1.QueryClientImpl(rpc); |
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,72 @@ | ||
diff --git a/node_modules/@cosmjs/stargate/build/queryclient/queryclient.js b/node_modules/@cosmjs/stargate/build/queryclient/queryclient.js | ||
index ebf0c7c..afa645f 100644 | ||
--- a/node_modules/@cosmjs/stargate/build/queryclient/queryclient.js | ||
+++ b/node_modules/@cosmjs/stargate/build/queryclient/queryclient.js | ||
@@ -32,6 +32,24 @@ class QueryClient { | ||
} | ||
return client; | ||
} | ||
+ | ||
+ static withExtensionsWithHeight(tmClient, height, ...extensionSetups) { | ||
+ const client = new QueryClient(tmClient, height); | ||
+ const extensions = extensionSetups.map((setupExtension) => setupExtension(client, height)); | ||
+ for (const extension of extensions) { | ||
+ (0, utils_1.assert)((0, utils_1.isNonNullObject)(extension), `Extension must be a non-null object`); | ||
+ for (const [moduleKey, moduleValue] of Object.entries(extension)) { | ||
+ (0, utils_1.assert)((0, utils_1.isNonNullObject)(moduleValue), `Module must be a non-null object. Found type ${typeof moduleValue} for module "${moduleKey}".`); | ||
+ const current = client[moduleKey] || {}; | ||
+ client[moduleKey] = { | ||
+ ...current, | ||
+ ...moduleValue, | ||
+ }; | ||
+ } | ||
+ } | ||
+ return client; | ||
+ } | ||
+ | ||
constructor(tmClient) { | ||
this.tmClient = tmClient; | ||
} | ||
diff --git a/node_modules/@cosmjs/stargate/build/queryclient/utils.d.ts b/node_modules/@cosmjs/stargate/build/queryclient/utils.d.ts | ||
index 5317078..75d149e 100644 | ||
--- a/node_modules/@cosmjs/stargate/build/queryclient/utils.d.ts | ||
+++ b/node_modules/@cosmjs/stargate/build/queryclient/utils.d.ts | ||
@@ -19,7 +19,7 @@ export declare function createPagination(paginationKey?: Uint8Array): PageReques | ||
export interface ProtobufRpcClient { | ||
request(service: string, method: string, data: Uint8Array): Promise<Uint8Array>; | ||
} | ||
-export declare function createProtobufRpcClient(base: QueryClient): ProtobufRpcClient; | ||
+export declare function createProtobufRpcClient(base: QueryClient, height?: number): ProtobufRpcClient; | ||
/** | ||
* Takes a uint64 value as string, number, Long or Uint64 and returns an unsigned Long instance | ||
* of it. | ||
diff --git a/node_modules/@cosmjs/stargate/build/queryclient/utils.js b/node_modules/@cosmjs/stargate/build/queryclient/utils.js | ||
index 6f4ecaa..7816bad 100644 | ||
--- a/node_modules/@cosmjs/stargate/build/queryclient/utils.js | ||
+++ b/node_modules/@cosmjs/stargate/build/queryclient/utils.js | ||
@@ -28,11 +28,11 @@ function createPagination(paginationKey) { | ||
return paginationKey ? pagination_1.PageRequest.fromPartial({ key: paginationKey }) : undefined; | ||
} | ||
exports.createPagination = createPagination; | ||
-function createProtobufRpcClient(base) { | ||
+function createProtobufRpcClient(base, height = undefined) { | ||
return { | ||
request: async (service, method, data) => { | ||
const path = `/${service}/${method}`; | ||
- const response = await base.queryAbci(path, data, undefined); | ||
+ const response = await base.queryAbci(path, data, height); | ||
return response.value; | ||
}, | ||
}; | ||
diff --git a/node_modules/@cosmjs/stargate/build/stargateclient.js b/node_modules/@cosmjs/stargate/build/stargateclient.js | ||
index 3268b13..70bbbec 100644 | ||
--- a/node_modules/@cosmjs/stargate/build/stargateclient.js | ||
+++ b/node_modules/@cosmjs/stargate/build/stargateclient.js | ||
@@ -299,6 +299,7 @@ class StargateClient { | ||
return results.txs.map((tx) => { | ||
const txMsgData = abci_1.TxMsgData.decode(tx.result.data ?? new Uint8Array()); | ||
return { | ||
+ ...tx, | ||
height: tx.height, | ||
txIndex: tx.index, | ||
hash: (0, encoding_1.toHex)(tx.hash).toUpperCase(), |
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,37 @@ | ||
diff --git a/node_modules/@cosmjs/tendermint-rpc/build/rpcclients/http.js b/node_modules/@cosmjs/tendermint-rpc/build/rpcclients/http.js | ||
index 8c72817..2b810d2 100644 | ||
--- a/node_modules/@cosmjs/tendermint-rpc/build/rpcclients/http.js | ||
+++ b/node_modules/@cosmjs/tendermint-rpc/build/rpcclients/http.js | ||
@@ -34,9 +34,11 @@ function isExperimental(nodeJsFunc) { | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types | ||
async function http(method, url, headers, request) { | ||
+ const timeout = Number(process.env.HTTP_TIMEOUT || 30000); | ||
if (typeof fetch === "function" && !isExperimental(fetch)) { | ||
const settings = { | ||
method: method, | ||
+ signal: AbortSignal.timeout(timeout), | ||
body: request ? JSON.stringify(request) : undefined, | ||
headers: { | ||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
@@ -50,7 +52,7 @@ async function http(method, url, headers, request) { | ||
} | ||
else { | ||
return axios_1.default | ||
- .request({ url: url, method: method, data: request, headers: headers }) | ||
+ .request({ url: url, method: method, data: request, headers: headers, timeout: timeout }) | ||
.then((res) => res.data); | ||
} | ||
} | ||
diff --git a/node_modules/@cosmjs/tendermint-rpc/build/tendermint34/adaptor/responses.js b/node_modules/@cosmjs/tendermint-rpc/build/tendermint34/adaptor/responses.js | ||
index a426641..9f33204 100644 | ||
--- a/node_modules/@cosmjs/tendermint-rpc/build/tendermint34/adaptor/responses.js | ||
+++ b/node_modules/@cosmjs/tendermint-rpc/build/tendermint34/adaptor/responses.js | ||
@@ -320,6 +320,7 @@ function decodeTxProof(data) { | ||
} | ||
function decodeTxResponse(data) { | ||
return { | ||
+ ...data, | ||
tx: (0, encoding_1.fromBase64)((0, encodings_1.assertNotEmpty)(data.tx)), | ||
result: decodeTxData((0, encodings_1.assertObject)(data.tx_result)), | ||
height: (0, inthelpers_1.apiToSmallInt)((0, encodings_1.assertNotEmpty)(data.height)), |
Oops, something went wrong.