diff --git a/doc/index.md b/doc/index.md index 6410ba4..2c8d1a3 100644 --- a/doc/index.md +++ b/doc/index.md @@ -22,9 +22,10 @@ | v0.12.1 | 2023. 05. 03 | add support coin group for syncAccount | | v0.13.0 | 2023. 05. 16 | add Tezos & Vechain & Near & Havah transaction function | | v0.13.1 | 2023. 05. 17 | Fixed fee display issue | -| v0.14.0 | 2023. 05. 25 | add Polkadot & Comsmos & Coreum & Near Token | -| v0.14.1 | 2023. 05. 25 | Fix Polkadot decimals | +| v0.14.0 | 2023. 05. 25 | add Polkadot & Comsmos & Coreum & Near Token | +| v0.14.1 | 2023. 05. 25 | Fix Polkadot decimals | | v0.14.2 | 2023. 11. 20 | add Algorand transaction function | +| v0.14.3 | 2023. 12. 13 | add Parachain(Astar) transaction function | ## 1. INTRODUCTION @@ -503,6 +504,42 @@ The address string format is depend on the coin type. For some coin type(ex. TEZOS), include pubkey as a property of the response parameter. +For ss58 addresses used by the Substrate ecosystems such as Astar, prefix is added. +The value of prefix is the prefix for each network defined in [ss58-registry](https://github.com/paritytech/ss58-registry). + +```js +var coinType = DcentWebConnector.coinType.PARA +var keyPath = "m/44'/810'/0'/0/0" // key path of the Astar's account +var prefix = 5 // The address prefix of Astar + +var result +try{ + // Get the address corresponding to keyPath & prefix + result = await DcentWebConnector.getAddress(coinType, keyPath, prefix) +}catch(e){ + result = e +} +``` + +Please note that `Astar EVM` features an EVM (Ethereum Virtual Machine) compatible runtime environment, so it is the same as getting the address of ETHEREUM account. + +Returned response object has: + +```json +{ + "header": { + "version": "1.0", + "response_from": "para", + "status": "success" + }, + "body": { + "command": "get_address", + "parameter": { + "address": "YzsEz5dG8TDqG49pGaejLrFoD4oeNTEX7yWt4qcCV4TA9LB" + } + } +} +``` ### Get XPUB @@ -797,7 +834,6 @@ The D'CENT Web SDK provides functions for signing transaction of coins. - nonce - gasPrice - gasLimit - - value - key path for signing - chain ID - contract information : @@ -1683,7 +1719,7 @@ For broadcast the sign transaction, you must reconstruct transaction include `Tx - This fuction for : - - POLCKADOT(DOT) + - POLKADOT(DOT) - Parameters : - unsignedTx: unsigned hexadecimal tx [Polkadot Docs](https://wiki.polkadot.network/docs/build-transaction-construction) @@ -1953,4 +1989,94 @@ For broadcast the sign transaction, you must reconstruct transaction include `Tx } ``` +**getParachainSignedTransaction()** + +- This fuction for : + + - Parachain - Astar(ASTR) + - Parachain Asset- Astar Asset(XC20) +- Parameters : + + - unsignedTx: unsigned hexadecimal tx [Polkadot Docs](https://wiki.polkadot.network/docs/build-transaction-construction) + - path: key path, wallet sign with that private key with a given key path (BIP32 ex) "m/44'/810'/0'/0/0"). + - fee: fee, It is fee that wallet displays on the screen. + - symbol: symbol, It is a symbol that the wallet displays on the screen. + - decimals: Parachain's decimals. + - RPCUrl: Network RPC endpoints. + - fee symbol: fee's symbol, It is a symbol that the wallet displays on the screen. + - fee decimals: fee's decimals. +- Requirements: + + - `D'CENT Bridge` version 1.5.3 or higher is required. + - D'CENT Biometric Wallet version 2.30.1 or higher is required. +- Useage: + + ```js + import { ApiPromise, HttpProvider } from '@polkadot/api' + + const httpProvider = new HttpProvider('https://evm.astar.network'); + const api = await ApiPromise({ provider: httpProvider }); + // Wait until we are ready and connected + await api.isReady; + + const blockNumber = await api.rpc.chain.getHeader(); + const blockHash = await api.rpc.chain.getBlockHash(blockNumber.number.toHex()); + // create SignerPayload + const signerPayload = api.createType('SignerPayload', { + genesisHash: api.genesisHash, + runtimeVersion: api.runtimeVersion, + version: api.extrinsicVersion, + blockHash: blockHash, + blockNumber: blockNumber.number, + era: api.createType('ExtrinsicEra', { + current: blockNumber.number, + period: 50 + }), + nonce, + address: to, + method: api.tx.balances.transfer(to, amount).method, // For tokens, method: api.tx.assets.transfer(contract, to, amount).method, + }); + + const sigHash = signerPayload.toRaw().data; + + const transactionJson = { + coinType: DcentWebConnector.coinType.PARA, + sigHash: sigHash, + path: `m/44'/810'/0'/0/0`, + decimals, // 18 + fee, + symbol: 'ASTR', + RPCUrl: 'https://evm.astar.network', + feeSymbol: 'ASTR', + feeDecimals, // 18 + }; + + var result; + try { + result = await DcentWebConnector.getParachainSignedTransaction(transactionJson); + } catch (e) { + console.log(e); + result = e; + } + ``` +- Returned response object: + + ```json + { + "header": { + "version": "1.0", + "response_from": "para", + "status": "success" + }, + "body": { + "command": "transaction", + "parameter": { + "signed_tx": "0x00263b3ed036c74d15d875c7246abe73404c82763f3300316eb782cafdf5bd93f4f47f0fe34d823f9d07f8db7b2cb81051e58a1e58993c70888916c0ef6c3c910f" + } + } + } + ``` + + Please note that for `Astar EVM` transactions, you can use the getEthereumSignedTransaction() and getTokenSignedTransaction() methods with the chain ID set to 592. + Please Refer to the `index.html` to learn more about how to use the SDK APIs. There is an Web project using our Web SDK. diff --git a/index.html b/index.html index 0e66e38..3740d2c 100644 --- a/index.html +++ b/index.html @@ -111,7 +111,12 @@
Response
- +
+ + + + +


+ +
+ +
@@ -237,6 +248,8 @@
Response
$('#get_address_polkadot').click(get_address_polkadot_clicked); $('#get_address_cosmos').click(get_address_cosmos_clicked); $('#get_address_coreum').click(get_address_coreum_clicked); + $('#get_address_parachain').click(get_address_parachain_clicked); + $('#get_address_astarevm').click(get_address_astarevm_clicked); $('#getBitcoinSignedTransaction').click(getBitcoinSignedTransaction_clicked); @@ -277,6 +290,10 @@
Response
$('#getPolkadotSignedTransaction').click(getPolkadotSignedTransaction_clicked); $('#getCosmosSignedTransaction').click(getCosmosSignedTransaction_clicked); $('#getCoreumSignedTransaction').click(getCoreumSignedTransaction_clicked); + $('#getParachainSignedTransaction').click(getParachainSignedTransaction_clicked); + $('#getParachainXc20SignedTransaction').click(getParachainXc20SignedTransaction_clicked); + $('#getEthereumSignedTransactionForAstarEVM').click(getEthereumSignedTransactionForAstarEVM_clicked); + $('#getTokenSignedTransactionForAstarEVM').click(getTokenSignedTransactionForAstarEVM_clicked); }); async function info_clicked() { @@ -482,31 +499,46 @@
Response
} async function get_address_polkadot_clicked() { - set_command_name("Processing..."); - - var result = await getAddress(dcent.coinType.POLKADOT, "m/44'/354'/0'/0/0") - - set_command_name("get_address polkadot") - resp_editor.load(result) - } - - async function get_address_cosmos_clicked() { - set_command_name("Processing..."); - - var result = await getAddress(dcent.coinType.COSMOS, "m/44'/118'/0'/0/0") - - set_command_name("get_address cosmos") - resp_editor.load(result) - } - - async function get_address_coreum_clicked() { - set_command_name("Processing..."); - var result = await getAddress(dcent.coinType.COREUM, "m/44'/990'/0'/0/0") - - set_command_name("get_address coreum") - resp_editor.load(result) - } - + set_command_name("Processing..."); + + var result = await getAddress(dcent.coinType.POLKADOT, "m/44'/354'/0'/0/0") + + set_command_name("get_address polkadot") + resp_editor.load(result) + } + + async function get_address_cosmos_clicked() { + set_command_name("Processing..."); + + var result = await getAddress(dcent.coinType.COSMOS, "m/44'/118'/0'/0/0") + + set_command_name("get_address cosmos") + resp_editor.load(result) + } + + async function get_address_coreum_clicked() { + set_command_name("Processing..."); + var result = await getAddress(dcent.coinType.COREUM, "m/44'/990'/0'/0/0") + + set_command_name("get_address coreum") + resp_editor.load(result) + } + + async function get_address_parachain_clicked() { + set_command_name("Processing..."); + var result = await getAddress(dcent.coinType.PARA, "m/44'/810'/0'/0/0", 5) + + set_command_name("get_address parachain") + resp_editor.load(result) + } + + async function get_address_astarevm_clicked() { + set_command_name("Processing..."); + var result = await getAddress(dcent.coinType.ETHEREUM, "m/44'/60'/0'/0/0") + + set_command_name("get_address for Astar EVM") + resp_editor.load(result) + } async function getBitcoinSignedTransaction_clicked() { @@ -1068,54 +1100,130 @@
Response
set_command_name("getHavahHsp20SignedTransaction_deploy") resp_editor.load(result) } + async function getPolkadotSignedTransaction_clicked() { - set_command_name("Processing..."); - var transactionJson = { - coinType: dcent.coinType.POLKADOT, - sigHash: '040000163a5ee36b1243ce5241c0a45010dd1717869e9918c040bf5d305be4a5af9e7a0b00407a10f35a003400a223000007000000e143f23803ac50e8f6f8e62695d1ce9e4e1d68aa36c1cd2cfd15340213f3423ee143f23803ac50e8f6f8e62695d1ce9e4e1d68aa36c1cd2cfd15340213f3423e', - path: `m/44'/354'/0'/0/0`, - decimals: 12, - fee: '0.00021', - symbol: 'DOT', - } - var result = await getPolkadotSignedTransaction(transactionJson); - - set_command_name("getPolkadotSignedTransaction") - resp_editor.load(result) - } - - async function getCosmosSignedTransaction_clicked() { - set_command_name("Processing..."); - var transactionJson = { - coinType: dcent.coinType.COSMOS, - sigHash: '0a94010a8f010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e64126f0a2d636f736d6f73317235763573726461377866746833686e327332367478767263726e746c646a756d74386d686c122d636f736d6f733138766864637a6a7574343467707379383034637266686e64356e713030336e7a306e663230761a0f0a057561746f6d1206313030303030120012670a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a21ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff12040a020801180a12130a0d0a057561746f6d12043530303010c09a0c1a0b636f736d6f736875622d34208f3a', - path: `m/44'/118'/0'/0/0`, - decimals: 6, - fee: '0.023', - symbol: 'ATOM', - } - var result = await getCosmosSignedTransaction(transactionJson); - - set_command_name("getCosmosSignedTransaction") - resp_editor.load(result) - } - - async function getCoreumSignedTransaction_clicked() { - set_command_name("Processing..."); - var transactionJson = { - coinType: dcent.coinType.COREUM, - sigHash: '0a90010a8b010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e64126b0a2b636f7265317432656d347a6b77346161716d7139373939656e756b66366538343577656671776e63667a78122b636f726531666c343876736e6d73647a637638357135643271347a35616a646861387975337834333537761a0f0a057561746f6d1206313030303030120012670a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a21ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff12040a020801180012130a0d0a057561746f6d12043530303010c09a0c1a0b636f736d6f736875622d342000', - path: `m/44'/990'/0'/0/0`, - decimals: 6, - fee: '0.12', - symbol: 'CORE', - } - var result = await getCosmosSignedTransaction(transactionJson); - - set_command_name("getCoreumSignedTransaction") - resp_editor.load(result) - } + set_command_name("Processing..."); + var transactionJson = { + coinType: dcent.coinType.POLKADOT, + sigHash: '040000163a5ee36b1243ce5241c0a45010dd1717869e9918c040bf5d305be4a5af9e7a0b00407a10f35a003400a223000007000000e143f23803ac50e8f6f8e62695d1ce9e4e1d68aa36c1cd2cfd15340213f3423ee143f23803ac50e8f6f8e62695d1ce9e4e1d68aa36c1cd2cfd15340213f3423e', + path: `m/44'/354'/0'/0/0`, + decimals: 12, + fee: '0.00021', + symbol: 'DOT', + } + var result = await getPolkadotSignedTransaction(transactionJson); + + set_command_name("getPolkadotSignedTransaction") + resp_editor.load(result) + } + async function getCosmosSignedTransaction_clicked() { + set_command_name("Processing..."); + var transactionJson = { + coinType: dcent.coinType.COSMOS, + sigHash: '0a94010a8f010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e64126f0a2d636f736d6f73317235763573726461377866746833686e327332367478767263726e746c646a756d74386d686c122d636f736d6f733138766864637a6a7574343467707379383034637266686e64356e713030336e7a306e663230761a0f0a057561746f6d1206313030303030120012670a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a21ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff12040a020801180a12130a0d0a057561746f6d12043530303010c09a0c1a0b636f736d6f736875622d34208f3a', + path: `m/44'/118'/0'/0/0`, + decimals: 6, + fee: '0.023', + symbol: 'ATOM', + } + var result = await getCosmosSignedTransaction(transactionJson); + + set_command_name("getCosmosSignedTransaction") + resp_editor.load(result) + } + + async function getCoreumSignedTransaction_clicked() { + set_command_name("Processing..."); + var transactionJson = { + coinType: dcent.coinType.COREUM, + sigHash: '0a90010a8b010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e64126b0a2b636f7265317432656d347a6b77346161716d7139373939656e756b66366538343577656671776e63667a78122b636f726531666c343876736e6d73647a637638357135643271347a35616a646861387975337834333537761a0f0a057561746f6d1206313030303030120012670a500a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a21ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff12040a020801180012130a0d0a057561746f6d12043530303010c09a0c1a0b636f736d6f736875622d342000', + path: `m/44'/990'/0'/0/0`, + decimals: 6, + fee: '0.12', + symbol: 'CORE', + } + var result = await getCosmosSignedTransaction(transactionJson); + + set_command_name("getCoreumSignedTransaction") + resp_editor.load(result) + } + + async function getParachainSignedTransaction_clicked() { + set_command_name("Processing...") + + var transactionJson = { + coinType: dcent.coinType.PARA, + sigHash: '0x1f03003ec746fb0d6d9d66245d6dc6c02d23b1b290821d8674865f96c03ef86d9d690d025a62020917000042000000020000009eb76c5184c4ab8679d2d5d819fdf90b9c001403e9e17da2e14b6d8aec4029c6b3436f97b6760bddf33e816da9c746b0cf17a80307f7a8485732044c8c20284d', + path: `m/44'/810'/0'/0/0`, + decimals: 18, + fee: '0.038966870338267128', + symbol: 'ASTR', + RPCUrl: 'https://astar-rpc.dwellir.com', + feeSymbol: 'ASTR', + feeDecimals: 18, + } + var result = await getParachainSignedTransaction(transactionJson) + + set_command_name("getParachainSignedTransaction") + resp_editor.load(result) + } + + async function getParachainXc20SignedTransaction_clicked() { + set_command_name("Processing...") + + var transactionJson = { + coinType: dcent.coinType.PARA_XC20, + sigHash: '0x240817030000000000000001003ec746fb0d6d9d66245d6dc6c02d23b1b290821d8674865f96c03ef86d9d690d1733c42f5578e4495b038923000048000000020000009eb76c5184c4ab8679d2d5d819fdf90b9c001403e9e17da2e14b6d8aec4029c697111d520df41d8ff1801aa6532c0c3b80ff986adf37476846b0e7e09993b7af', + path: `m/44'/810'/0'/0/0`, + decimals: 18, + fee: '0.049131930863795561', + symbol: 'GLMR', + RPCUrl: 'https://astar-rpc.dwellir.com', + feeSymbol: 'ASTR', + feeDecimals: 18, + } + var result = await getParachainSignedTransaction(transactionJson) + + set_command_name("getParachainXc20SignedTransaction") + resp_editor.load(result) + } + + async function getEthereumSignedTransactionForAstarEVM_clicked() { + set_command_name("Processing...") + + var result = await getEthereumSignedTransaction( + dcent.coinType.ETHEREUM, + '8', + '2400000000', + '210000', + '0x354609C4c9a15d4265cF6D94010568D5Cf4d0c1B', + '100000000000000000', + '0x', + "m/44'/60'/0'/0/0", + 592, + ) + + set_command_name("getEthereumSignedTransaction for Astar EVM") + resp_editor.load(result) + } + + async function getTokenSignedTransactionForAstarEVM_clicked() { + set_command_name("Processing...") + + var contract = { + name: 'Wrapped Astar', + address: '0xAeaaf0e2c81Af264101B9129C00F4440cCF0F720', + to: '0x354609C4c9a15d4265cF6D94010568D5Cf4d0c1B', + decimals: 18, + value: '100000000000000000', + symbol: 'WASTR', + } + var result = await getTokenSignedTransaction( dcent.coinType.ERC20, '21', '2400000000', '1000000', "m/44'/60'/0'/0/0", 592, contract ) + + set_command_name("getTokenSignedTransaction for Astar EVM") + resp_editor.load(result) + } /////// DCENT WEB-SDK call @@ -1199,10 +1307,10 @@
Response
return result } - async function getAddress(coinType, key) { + async function getAddress(coinType, key, optionParam) { var result try { - result = await dcent.getAddress(coinType, key) + result = await dcent.getAddress(coinType, key, optionParam) } catch (e) { result = e } @@ -1392,26 +1500,35 @@
Response
return result } - async function getPolkadotSignedTransaction(transaction) { - var result - try { - result = await dcent.getPolkadotSignedTransaction(transaction) - } catch (e) { - result = e - } - return result - } - - async function getCosmosSignedTransaction(transaction) { - var result - try { - result = await dcent.getCosmosSignedTransaction(transaction) - } catch (e) { - result = e - } - return result - } - + async function getPolkadotSignedTransaction(transaction) { + var result + try { + result = await dcent.getPolkadotSignedTransaction(transaction) + } catch (e) { + result = e + } + return result + } + + async function getCosmosSignedTransaction(transaction) { + var result + try { + result = await dcent.getCosmosSignedTransaction(transaction) + } catch (e) { + result = e + } + return result + } + + async function getParachainSignedTransaction(transaction) { + var result + try { + result = await dcent.getParachainSignedTransaction(transaction) + } catch (e) { + result = e + } + return result + } diff --git a/info/supported_union_info.json b/info/supported_union_info.json index c4bbbc7..fc2da58 100644 --- a/info/supported_union_info.json +++ b/info/supported_union_info.json @@ -86,5 +86,21 @@ { "name": "algo-app-test", "supportVersion": "2.29.1" + }, + { + "name": "para", + "supportVersion": "2.30.1" + }, + { + "name": "para-testnet", + "supportVersion": "2.30.1" + }, + { + "name": "para-xc20", + "supportVersion": "2.30.1" + }, + { + "name": "para-xc20-tesetnet", + "supportVersion": "2.30.1" } ] \ No newline at end of file diff --git a/src/index.js b/src/index.js index ecd5ae7..5283ce9 100644 --- a/src/index.js +++ b/src/index.js @@ -516,7 +516,8 @@ const _contractNotStartWith0x = (coinGroup) => { coinGroup === dcentCoinGroup.XRC20.toLowerCase() || coinGroup === dcentCoinGroup.XRC20_APOTHEM.toLowerCase() || coinGroup === dcentCoinGroup.HTS_TESTNET.toLowerCase() || coinGroup === dcentCoinGroup.HEDERA_HTS.toLowerCase() || coinGroup === dcentCoinGroup.ALGORAND_ASSET.toLowerCase() || coinGroup === dcentCoinGroup.ALGORAND_ASSET_TESTNET.toLowerCase() || - coinGroup === dcentCoinGroup.ALGORAND_APP.toLowerCase() || coinGroup === dcentCoinGroup.ALGORAND_APP_TESTNET.toLowerCase() + coinGroup === dcentCoinGroup.ALGORAND_APP.toLowerCase() || coinGroup === dcentCoinGroup.ALGORAND_APP_TESTNET.toLowerCase() || + coinGroup === dcentCoinGroup.PARA_XC20.toLowerCase() || coinGroup === dcentCoinGroup.PARA_XC20_TESTNET.toLowerCase() ) { return true } @@ -596,6 +597,10 @@ function isAvaliableCoinType (coinType) { case dcentCoinType.ALGORAND_ASSET_TESTNET.toLowerCase(): case dcentCoinType.ALGORAND_APP.toLowerCase(): case dcentCoinType.ALGORAND_APP_TESTNET.toLowerCase(): + case dcentCoinType.PARA.toLowerCase(): + case dcentCoinType.PARA_TESTNET.toLowerCase(): + case dcentCoinType.PARA_XC20.toLowerCase(): + case dcentCoinType.PARA_XC20_TESTNET.toLowerCase(): return true default: return false @@ -625,6 +630,8 @@ function isTokenType (coinGroup) { case dcentCoinType.ALGORAND_ASSET_TESTNET.toLowerCase(): case dcentCoinType.ALGORAND_APP.toLowerCase(): case dcentCoinType.ALGORAND_APP_TESTNET.toLowerCase(): + case dcentCoinGroup.PARA_XC20.toLowerCase(): + case dcentCoinGroup.PARA_XC20_TESTNET.toLowerCase(): return true default: return false @@ -642,7 +649,7 @@ function isBitcoinTxCoinType (coinType) { return false } } - + function isCzoneCoinType (coinType) { switch (coinType.toLowerCase()) { case dcentCoinType.COREUM.toLowerCase(): @@ -652,6 +659,21 @@ function isCzoneCoinType (coinType) { } } +function isParachainCoinType (coinType) { + if (!coinType) { + return false + } + switch (coinType.toLowerCase()) { + case dcentCoinType.PARA.toLowerCase(): + case dcentCoinType.PARA_TESTNET.toLowerCase(): + case dcentCoinType.PARA_XC20.toLowerCase(): + case dcentCoinType.PARA_XC20_TESTNET.toLowerCase(): + return true + default: + return false + } +} + function getCzonePrifix (coinType) { switch (coinType.toLowerCase()) { case dcentCoinType.COREUM.toLowerCase(): @@ -752,7 +774,7 @@ dcent.selectAddress = async function (addresses) { * @param {string} path string value of key path to get address * @returns {Object} address. */ -dcent.getAddress = async function (coinType, path) { +dcent.getAddress = async function (coinType, path, prefix = null) { if (!isAvaliableCoinType(coinType)) { throw dcent.dcentException('coin_type_error', 'not supported coin type') @@ -765,8 +787,15 @@ dcent.getAddress = async function (coinType, path) { if (isCzoneCoinType(coinType)) { params.optionParam = getCzonePrifix(coinType) -} - + } + + if (isParachainCoinType(coinType)) { + if (!Number(prefix)) { + throw dcent.dcentException('param_error', 'Invaild Parameter') + } + params.optionParam = Number(prefix) + } + const res = await dcent.call({ method: 'getAddress', params @@ -1425,7 +1454,7 @@ dcent.getPolkadotSignedTransaction = async function ({ params }) } - + dcent.getCosmosSignedTransaction = async function ({ coinType, sigHash, @@ -1491,6 +1520,44 @@ dcent.getAlgorandSignedTransaction = async function ({ }) } +dcent.getParachainSignedTransaction = async function ({ + coinType, + sigHash, + fee, + decimals, + nonce, + path, + symbol, + RPCUrl, + feeSymbol, + feeDecimals, + optionParam, +}) { + const params = { + coinType, + sig_hash: sigHash, + fee: UnitConverter(fee, feeDecimals).bignum.toString(16).padStart(16, '0'), + decimals, + path, + symbol, + RPCUrl, + feeSymbol, + feeDecimals, + } + if (nonce) params.nonce = nonce + if (optionParam) params.optionParam = optionParam + + const res = await dcent.call({ + method: 'getUnionSignedTransaction', + params + }) + + if (res.header.status === 'success') { + res.body.parameter.signed_tx = '0x00' + (res.body.parameter.signed_tx.startsWith('0x') ? res.body.parameter.signed_tx.substr(2) : res.body.parameter.signed_tx) + } + return res +} + dcent.state = dcentState dcent.coinType = dcentCoinType dcent.coinGroup = dcentCoinGroup diff --git a/src/native/request-method.js b/src/native/request-method.js index d902e3a..9c43288 100644 --- a/src/native/request-method.js +++ b/src/native/request-method.js @@ -28,6 +28,7 @@ module.exports = { GET_POLKADOT_SIGN_TX: 'getPolkadotSignedTransaction', GET_COSMOS_SIGN_TX: 'getCosmosSignedTransaction', GET_ALGORAND_SIGN_TX: 'getAlgorandSignedTransaction', + GET_PARA_SIGN_TX: 'getParachainSignedTransaction', } /* //////////////////////////////////////////////////////////////////////// */ diff --git a/src/type/dcent-web-type.js b/src/type/dcent-web-type.js index c5908e4..9f7aefd 100644 --- a/src/type/dcent-web-type.js +++ b/src/type/dcent-web-type.js @@ -55,6 +55,10 @@ const coinType = { ALGORAND_ASSET_TESTNET: 'algo-asset-test', ALGORAND_APP: 'algo-app', ALGORAND_APP_TESTNET: 'algo-app-test', + PARA: 'para', + PARA_TESTNET: 'para-testnet', + PARA_XC20: 'para-xc20', + PARA_XC20_TESTNET: 'para-xc20-testnet', } const coinGroup = { @@ -112,6 +116,10 @@ const coinGroup = { ALGORAND_ASSET_TESTNET: 'ALGO-ASSET-TEST', ALGORAND_APP: 'ALGO-APP', ALGORAND_APP_TESTNET: 'ALGO-APP-TEST', + PARA: 'PARA', + PARA_TESTNET: 'PARAT', + PARA_XC20: 'XC20', + PARA_XC20_TESTNET: 'XC20T', } const coinName = { @@ -169,6 +177,10 @@ const coinName = { ALGORAND_ASSET_TESTNET: 'ALGO-ASSET-TEST', ALGORAND_APP: 'ALGO-APP', ALGORAND_APP_TESTNET: 'ALGO-APP-TEST', + PARA: 'PARA', + PARA_TESTNET: 'PARAT', + PARA_XC20: 'XC20', + PARA_XC20_TESTNET: 'XC20T', } const bitcoinTxType = { diff --git a/tests/unit/1_bridge_test/20_coin.algorand.sign.spec.js b/tests/unit/1_bridge_test/20_coin.algorand.sign.spec.js index 9c2f8ae..a1f789f 100644 --- a/tests/unit/1_bridge_test/20_coin.algorand.sign.spec.js +++ b/tests/unit/1_bridge_test/20_coin.algorand.sign.spec.js @@ -71,7 +71,7 @@ describe('[dcent-web-connector] Bridge - init', () => { } var response = await page.evaluate((transactionJson) => { // eslint-disable-next-line no-undef - return getHavahSignedTransaction(transactionJson) + return getAlgoSignedTransaction(transactionJson) }, transactionJson) var responseAddress = await page.evaluate(() => { @@ -105,7 +105,7 @@ describe('[dcent-web-connector] Bridge - init', () => { } var response = await page.evaluate((transactionJson) => { // eslint-disable-next-line no-undef - return getHavahSignedTransaction(transactionJson) + return getAlgoSignedTransaction(transactionJson) }, transactionJson) var responseAddress = await page.evaluate(() => { @@ -139,7 +139,7 @@ describe('[dcent-web-connector] Bridge - init', () => { } var response = await page.evaluate((transactionJson) => { // eslint-disable-next-line no-undef - return getHavahSignedTransaction(transactionJson) + return getAlgoSignedTransaction(transactionJson) }, transactionJson) var responseAddress = await page.evaluate(() => { @@ -173,7 +173,7 @@ describe('[dcent-web-connector] Bridge - init', () => { } var response = await page.evaluate((transactionJson) => { // eslint-disable-next-line no-undef - return getHavahSignedTransaction(transactionJson) + return getAlgoSignedTransaction(transactionJson) }, transactionJson) var responseAddress = await page.evaluate(() => { @@ -207,7 +207,7 @@ describe('[dcent-web-connector] Bridge - init', () => { } var response = await page.evaluate((transactionJson) => { // eslint-disable-next-line no-undef - return getHavahSignedTransaction(transactionJson) + return getAlgoSignedTransaction(transactionJson) }, transactionJson) var responseAddress = await page.evaluate(() => { @@ -241,7 +241,7 @@ describe('[dcent-web-connector] Bridge - init', () => { } var response = await page.evaluate((transactionJson) => { // eslint-disable-next-line no-undef - return getHavahSignedTransaction(transactionJson) + return getAlgoSignedTransaction(transactionJson) }, transactionJson) var responseAddress = await page.evaluate(() => { @@ -275,7 +275,7 @@ describe('[dcent-web-connector] Bridge - init', () => { } var response = await page.evaluate((transactionJson) => { // eslint-disable-next-line no-undef - return getHavahSignedTransaction(transactionJson) + return getAlgoSignedTransaction(transactionJson) }, transactionJson) var responseAddress = await page.evaluate(() => {