Skip to content

Commit

Permalink
Astar EVM getAddress 및 getSignedTransaction 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
AnHyoChul committed Dec 13, 2023
1 parent 0d8c308 commit 5dee02f
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 16 deletions.
12 changes: 8 additions & 4 deletions doc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -520,6 +521,8 @@ try{
}
```

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
Expand Down Expand Up @@ -831,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 :
Expand Down Expand Up @@ -2006,7 +2008,7 @@ For broadcast the sign transaction, you must reconstruct transaction include `Tx
- Requirements:
- `D'CENT Bridge` version 1.5.3 or higher is required.
- D'CENT Biometric Wallet version 2.30.0 or higher is required.
- D'CENT Biometric Wallet version 2.30.1 or higher is required.
- Useage:

```js
Expand Down Expand Up @@ -2075,4 +2077,6 @@ For broadcast the sign transaction, you must reconstruct transaction include `Tx
}
```
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.
68 changes: 61 additions & 7 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,12 @@ <h5 class="card-title">Response</h5>
<button id="getPolkadotSignedTransaction" type="button" class="btn btn-primary">getPolkadotSignedTransaction</button>
<button id="getCosmosSignedTransaction" type="button" class="btn btn-primary">getCosmosSignedTransaction</button>
<button id="getCoreumSignedTransaction" type="button" class="btn btn-primary">getCosmosSignedTransaction - for coreum</button>
<br />

<button id="getParachainSignedTransaction" type="button" class="btn btn-primary">getParachainSignedTransaction - for Astar</button>
<button id="getParachainXc20SignedTransaction" type="button" class="btn btn-primary">getParachainXc20SignedTransaction - for Astar</button>

<button id="getEthereumSignedTransactionForAstarEVM" type="button" class="btn btn-primary">getEthereumSignedTransaction - for Astar EVM</button>
<button id="getTokenSignedTransactionForAstarEVM" type="button" class="btn btn-primary">getTokenSignedTransaction - for Astar EVM</button>
<br /><br />

<button id="get_address_bitcoin" type="button" class="btn btn-primary">Get Bitcoin
Expand Down Expand Up @@ -173,6 +176,9 @@ <h5 class="card-title">Response</h5>
<button id="get_address_parachain" type="button" class="btn btn-primary">Get Parachain(Astar) Mainnet
Address("m/44'/810'/0'/0/0")</button>
<br />
<button id="get_address_astarevm" type="button" class="btn btn-primary">Get Astar EVM Mainnet
Address("m/44'/60'/0'/0/0")</button>
<br />

</div>
</div>
Expand Down Expand Up @@ -243,6 +249,7 @@ <h5 class="card-title">Response</h5>
$('#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);

Expand Down Expand Up @@ -285,6 +292,8 @@ <h5 class="card-title">Response</h5>
$('#getCoreumSignedTransaction').click(getCoreumSignedTransaction_clicked);
$('#getParachainSignedTransaction').click(getParachainSignedTransaction_clicked);
$('#getParachainXc20SignedTransaction').click(getParachainXc20SignedTransaction_clicked);
$('#getEthereumSignedTransactionForAstarEVM').click(getEthereumSignedTransactionForAstarEVM_clicked);
$('#getTokenSignedTransactionForAstarEVM').click(getTokenSignedTransactionForAstarEVM_clicked);
});

async function info_clicked() {
Expand Down Expand Up @@ -523,6 +532,13 @@ <h5 class="card-title">Response</h5>
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() {
Expand Down Expand Up @@ -1134,7 +1150,8 @@ <h5 class="card-title">Response</h5>
}

async function getParachainSignedTransaction_clicked() {
set_command_name("Processing...");
set_command_name("Processing...")

var transactionJson = {
coinType: dcent.coinType.PARA,
sigHash: '0x1f03003ec746fb0d6d9d66245d6dc6c02d23b1b290821d8674865f96c03ef86d9d690d025a62020917000042000000020000009eb76c5184c4ab8679d2d5d819fdf90b9c001403e9e17da2e14b6d8aec4029c6b3436f97b6760bddf33e816da9c746b0cf17a80307f7a8485732044c8c20284d',
Expand All @@ -1146,14 +1163,15 @@ <h5 class="card-title">Response</h5>
feeSymbol: 'ASTR',
feeDecimals: 18,
}
var result = await getParachainSignedTransaction(transactionJson);
var result = await getParachainSignedTransaction(transactionJson)

set_command_name("getParachainSignedTransaction")
resp_editor.load(result)
}

async function getParachainXc20SignedTransaction_clicked() {
set_command_name("Processing...");
set_command_name("Processing...")

var transactionJson = {
coinType: dcent.coinType.PARA_XC20,
sigHash: '0x240817030000000000000001003ec746fb0d6d9d66245d6dc6c02d23b1b290821d8674865f96c03ef86d9d690d1733c42f5578e4495b038923000048000000020000009eb76c5184c4ab8679d2d5d819fdf90b9c001403e9e17da2e14b6d8aec4029c697111d520df41d8ff1801aa6532c0c3b80ff986adf37476846b0e7e09993b7af',
Expand All @@ -1165,12 +1183,48 @@ <h5 class="card-title">Response</h5>
feeSymbol: 'ASTR',
feeDecimals: 18,
}
var result = await getParachainSignedTransaction(transactionJson);
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

async function info() {
Expand Down
8 changes: 4 additions & 4 deletions info/supported_union_info.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,18 @@
},
{
"name": "para",
"supportVersion": "2.30.0"
"supportVersion": "2.30.1"
},
{
"name": "para-testnet",
"supportVersion": "2.30.0"
"supportVersion": "2.30.1"
},
{
"name": "para-xc20",
"supportVersion": "2.30.0"
"supportVersion": "2.30.1"
},
{
"name": "para-xc20-tesetnet",
"supportVersion": "2.30.0"
"supportVersion": "2.30.1"
}
]
4 changes: 3 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1552,7 +1552,9 @@ dcent.getParachainSignedTransaction = async function ({
params
})

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)
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
}

Expand Down

0 comments on commit 5dee02f

Please sign in to comment.