From 7583efd1aa6d13ebcff5fdbc5d29dca2d3248376 Mon Sep 17 00:00:00 2001 From: RetricSu Date: Tue, 27 Jul 2021 11:32:25 +0800 Subject: [PATCH 1/4] feat: add poly_getChainInfo rpc --- README.md | 1 + .../api-server/src/methods/modules/poly.ts | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/README.md b/README.md index aff70529..8c69a409 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ DATABASE_URL=postgres://username:password@localhost:5432/your_db GODWOKEN_JSON_RPC= ETH_ACCOUNT_LOCK_HASH= ROLLUP_TYPE_HASH= +ROLLUP_CONFIG_HASH= CHAIN_ID= CREATOR_ACCOUNT_ID= ADDRESS_STORE_PATH_ABSOLUTE= diff --git a/packages/api-server/src/methods/modules/poly.ts b/packages/api-server/src/methods/modules/poly.ts index 5061299a..36f3c8af 100644 --- a/packages/api-server/src/methods/modules/poly.ts +++ b/packages/api-server/src/methods/modules/poly.ts @@ -164,4 +164,23 @@ export class Poly { message: "ETH_ACCOUNT_LOCK_HASH not found!", }); } + + async getChainInfo(args: [], callback: Callback) { + try { + const chainInfo = { + rollupScriptHash: process.env.ROLLUP_TYPE_HASH, + rollupConfigHash: process.env.ROLLUP_CONFIG_HASH, + ethAccountLockTypeHash: process.env.ETH_ACCOUNT_LOCK_HASH, + polyjuiceContractTypeHash: process.env.POLYJUICE_VALIDATOR_TYPE_HASH, + polyjuiceCreatorId: process.env.CREATOR_ACCOUNT_ID, + chainId: process.env.CHAIN_ID, + }; + callback(null, chainInfo); + } catch (error) { + callback({ + code: WEB3_ERROR, + message: error.message, + }); + } + } } From 280fdbf5801234a0b6441660439a8408635d6fb5 Mon Sep 17 00:00:00 2001 From: RetricSu Date: Tue, 27 Jul 2021 11:35:36 +0800 Subject: [PATCH 2/4] feat: add poly_getRollupConfigHash rpc --- packages/api-server/src/methods/modules/poly.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/api-server/src/methods/modules/poly.ts b/packages/api-server/src/methods/modules/poly.ts index 36f3c8af..720a8abe 100644 --- a/packages/api-server/src/methods/modules/poly.ts +++ b/packages/api-server/src/methods/modules/poly.ts @@ -155,6 +155,16 @@ export class Poly { }); } + async getRollupConfigHash(args: [], callback: Callback) { + if (process.env.ROLLUP_TYPE_HASH) + callback(null, process.env.ROLLUP_CONFIG_HASH!); + else + callback({ + code: WEB3_ERROR, + message: "ROLLUP_CONFIG_HASH not found!", + }); + } + async getEthAccountLockHash(args: [], callback: Callback) { if (process.env.ETH_ACCOUNT_LOCK_HASH) callback(null, process.env.ETH_ACCOUNT_LOCK_HASH!); From d7203c4033359076bf15fff6f573996be30ef70a Mon Sep 17 00:00:00 2001 From: RetricSu Date: Tue, 27 Jul 2021 14:57:52 +0800 Subject: [PATCH 3/4] add poly rpc to README --- README.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8c69a409..b452fa78 100644 --- a/README.md +++ b/README.md @@ -112,8 +112,16 @@ yarn workspace @godwoken-web3/api-server start - gw_submit_withdrawal_request ### poly -- poly_ethAddressToPolyjuiceAddress -- poly_polyjuiceAddressToEthAddress +- poly_getEthAddressByGodwokenShortAddress +- poly_saveEthAddressGodwokenShortAddressMapping +- poly_getChainInfo +- poly_getDefaultFromAddress +- poly_getContractValidatorTypeHash +- poly_getRollupTypeHash +- poly_getRollupConfigHash +- poly_getEthAccountLockHash +- poly_getCreatorId + ## Examples ### web3_clientVersion From 188c5842de401eb4bdc4cf7d1ecdcdcc2d9cb282 Mon Sep 17 00:00:00 2001 From: RetricSu Date: Tue, 27 Jul 2021 15:14:54 +0800 Subject: [PATCH 4/4] remove outdated poly address rpc --- .../api-server/src/methods/modules/poly.ts | 48 ------------------- 1 file changed, 48 deletions(-) diff --git a/packages/api-server/src/methods/modules/poly.ts b/packages/api-server/src/methods/modules/poly.ts index 720a8abe..d097b33b 100644 --- a/packages/api-server/src/methods/modules/poly.ts +++ b/packages/api-server/src/methods/modules/poly.ts @@ -1,7 +1,3 @@ -import { - ethAddressToPolyjuiceAddress, - polyjuiceAddressToEthAddress, -} from "../../convert-tx"; import { RPC } from "ckb-js-toolkit"; import { Callback } from "../types"; import { middleware, validators } from "../validator"; @@ -17,18 +13,6 @@ export class Poly { this.rpc = new RPC(process.env.GODWOKEN_JSON_RPC as string); this.hashMap = new HashMap(); - this.ethAddressToPolyjuiceAddress = middleware( - this.ethAddressToPolyjuiceAddress.bind(this), - 1, - [validators.address] - ); - - this.polyjuiceAddressToEthAddress = middleware( - this.polyjuiceAddressToEthAddress.bind(this), - 1, - [validators.address] - ); - this.getEthAddressByGodwokenShortAddress = middleware( this.getEthAddressByGodwokenShortAddress.bind(this), 1, @@ -42,38 +26,6 @@ export class Poly { ); } - async ethAddressToPolyjuiceAddress(args: [string], callback: Callback) { - try { - const ethAddress = args[0]; - const polyjuiceAddress = await ethAddressToPolyjuiceAddress( - ethAddress, - this.rpc - ); - callback(null, polyjuiceAddress); - } catch (error) { - callback({ - code: WEB3_ERROR, - message: error.message, - }); - } - } - - async polyjuiceAddressToEthAddress(args: [string], callback: Callback) { - try { - const polyjuiceAddress = args[0]; - const ethAddress = await polyjuiceAddressToEthAddress( - polyjuiceAddress, - this.rpc - ); - callback(null, ethAddress); - } catch (error) { - callback({ - code: WEB3_ERROR, - message: error.message, - }); - } - } - async getEthAddressByGodwokenShortAddress( args: [string], callback: Callback