Skip to content

Commit 1c8e45a

Browse files
committed
fix comments
1 parent d237a0a commit 1c8e45a

16 files changed

+668
-698
lines changed

evm-tests/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules
2+
.papi
23
.env

evm-tests/.papi/descriptors/.gitignore

Lines changed: 0 additions & 3 deletions
This file was deleted.

evm-tests/.papi/descriptors/package.json

Lines changed: 0 additions & 24 deletions
This file was deleted.
-218 KB
Binary file not shown.

evm-tests/.papi/polkadot-api.json

Lines changed: 0 additions & 11 deletions
This file was deleted.

evm-tests/README.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,38 @@ test with ts
44

55
## install papi
66

7-
npm install polkadot-api
7+
```bash
8+
yarn add polkadot-api
9+
```
810

911
## polkadot api
1012

13+
```bash
1114
npx papi add devnet -w ws://10.0.0.11:9944
15+
```
1216

1317
## get the new metadata
1418

15-
sh get-metadta.sh
19+
```bash
20+
sh get-metadata.sh
21+
```
1622

1723
## run all tests
1824

25+
```bash
1926
yarn test
27+
```
28+
29+
## To run a particular test case, you can pass an argument with the name or part of
30+
31+
the name. For example:
32+
33+
```bash
34+
yarn run test -- -g "Can set subnet parameter"
35+
```
2036

2137
## update dependence for coding
2238

23-
npm update @polkadot-api/descriptors
39+
```bash
40+
yarn upgrade @polkadot-api/descriptors
41+
```

evm-tests/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
"@polkadot/api": "15.1.1",
1313
"crypto": "^1.0.1",
1414
"dotenv": "16.4.7",
15-
"polkadot-api": "^1.9.1",
1615
"ethers": "^6.13.5",
16+
"polkadot-api": "^1.9.5",
1717
"viem": "2.23.4"
1818
},
1919
"devDependencies": {

evm-tests/src/address-utils.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,27 @@
11
import { Address } from "viem"
22
import { encodeAddress } from "@polkadot/util-crypto";
3-
import { MultiAddress } from '@polkadot-api/descriptors';
4-
import { ss58Address, KeyPair } from "@polkadot-labs/hdkd-helpers";
3+
import { ss58Address } from "@polkadot-labs/hdkd-helpers";
54
import { hexToU8a } from "@polkadot/util";
65
import { blake2AsU8a, decodeAddress } from "@polkadot/util-crypto";
76
import { Binary } from "polkadot-api";
7+
import { SS58_PREFIX } from "./config"
88

99
export function toViemAddress(address: string): Address {
1010
let addressNoPrefix = address.replace("0x", "")
1111
return `0x${addressNoPrefix}`
1212
}
1313

14-
export function convertSs58ToMultiAddress(ss58Address: string) {
15-
const address = MultiAddress.Id(ss58Address)
16-
return address
17-
}
18-
1914
export function convertH160ToSS58(ethAddress: string) {
2015
// get the public key
2116
const hash = convertH160ToPublicKey(ethAddress);
2217

2318
// Convert the hash to SS58 format
24-
const ss58Address = encodeAddress(hash, 42); // Assuming network ID 42
19+
const ss58Address = encodeAddress(hash, SS58_PREFIX);
2520
return ss58Address;
2621
}
2722

2823
export function convertPublicKeyToSs58(publickey: Uint8Array) {
29-
return ss58Address(publickey, 42);
24+
return ss58Address(publickey, SS58_PREFIX);
3025
}
3126

3227
export function convertH160ToPublicKey(ethAddress: string) {

evm-tests/src/balance-math.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import assert from "assert"
22

33
export const TAO = BigInt(1000000000) // 10^9
4-
export const ETHPerRAO = BigInt(1000000000) // 10^9
4+
export const ETH_PER_RAO = BigInt(1000000000) // 10^9
55
export const GWEI = BigInt(1000000000) // 10^9
66
export const MAX_TX_FEE = BigInt(21000000) * GWEI // 100 times EVM to EVM transfer fee
77

@@ -14,7 +14,7 @@ export function tao(value: number) {
1414
}
1515

1616
export function raoToEth(value: bigint) {
17-
return ETHPerRAO * value
17+
return ETH_PER_RAO * value
1818
}
1919

2020
export function compareEthBalanceWithTxFee(balance1: bigint, balance2: bigint) {

0 commit comments

Comments
 (0)