Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/test headers #185

Merged
merged 3 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 39 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@
</a>
</p>

| Branch | Tests | Coverage |
|--------------|-----------------|----------------|
| Branch | Tests | Coverage |
| ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------ |
| `feature/test-chain-util` | ![Tests](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/AElfProject/aelf-web3.js/feature/badge-json/feature-test-chain-util-test-results.json) | ![Coverage](https://AElfProject.github.io/aelf-web3.js/badges.svg) |

<!-- | Statements | Branches | Functions | Lines |
| --------------------------- | ----------------------- | ------------------------- | ----------------- |
| ![Statements](https://img.shields.io/badge/statements-97.98%25-brightgreen.svg?style=flat) | ![Branches](https://img.shields.io/badge/branches-95.49%25-brightgreen.svg?style=flat) | ![Functions](https://img.shields.io/badge/functions-98.61%25-brightgreen.svg?style=flat) | ![Lines](https://img.shields.io/badge/lines-98%25-brightgreen.svg?style=flat) | -->

| ![Statements](https://img.shields.io/badge/statements-97.98%25-brightgreen.svg?style=flat) | ![Branches](https://img.shields.io/badge/branches-95.3%25-brightgreen.svg?style=flat) | ![Functions](https://img.shields.io/badge/functions-98.61%25-brightgreen.svg?style=flat) | ![Lines](https://img.shields.io/badge/lines-98%25-brightgreen.svg?style=flat) | -->

## 1. Introduction

Expand Down Expand Up @@ -80,9 +79,9 @@ module.exports = {
// ...
resolve: {
alias: {
'aelf-sdk$': 'aelf-sdk/dist/aelf.umd.js',
},
},
'aelf-sdk$': 'aelf-sdk/dist/aelf.umd.js'
}
}
};
```

Expand All @@ -95,9 +94,9 @@ rollup({
// ...
plugins: [
alias({
'aelf-sdk': require.resolve('aelf-sdk/dist/aelf.umd.js'),
}),
],
'aelf-sdk': require.resolve('aelf-sdk/dist/aelf.umd.js')
})
]
});
```

Expand All @@ -110,9 +109,9 @@ module.exports = {
// ...
resolve: {
alias: {
'aelf-sdk$': 'aelf-sdk/dist/aelf.cjs.js',
},
},
'aelf-sdk$': 'aelf-sdk/dist/aelf.cjs.js'
}
}
};
```

Expand All @@ -125,9 +124,9 @@ rollup({
// ...
plugins: [
alias({
'aelf-sdk': require.resolve('aelf-sdk/dist/aelf.cjs.js'),
}),
],
'aelf-sdk': require.resolve('aelf-sdk/dist/aelf.cjs.js')
})
]
});
```

Expand All @@ -143,9 +142,7 @@ You can also see full examples in [./examples](./examples);
import AElf from 'aelf-sdk';

// create a new instance of AElf
const aelf = new AElf(
new AElf.providers.HttpProvider('http://127.0.0.1:1235')
);
const aelf = new AElf(new AElf.providers.HttpProvider('http://127.0.0.1:1235'));
```

2. Create or load a wallet with `AElf.wallet`
Expand All @@ -170,14 +167,9 @@ You can also see full examples in [./examples](./examples);
// get genesis contract address
const GenesisContractAddress = chainStatus.GenesisContractAddress;
// get genesis contract instance
const zeroContract = await aelf.chain.contractAt(
GenesisContractAddress,
newWallet
);
const zeroContract = await aelf.chain.contractAt(GenesisContractAddress, newWallet);
// Get contract address by the read only method `GetContractAddressByName` of genesis contract
tokenContractAddress = await zeroContract.GetContractAddressByName.call(
AElf.utils.sha256(tokenContractName)
);
tokenContractAddress = await zeroContract.GetContractAddressByName.call(AElf.utils.sha256(tokenContractName));
})();
```

Expand All @@ -193,7 +185,7 @@ You can also see full examples in [./examples](./examples);
})();

// promise way
aelf.chain.contractAt(tokenContractAddress, wallet).then((result) => {
aelf.chain.contractAt(tokenContractAddress, wallet).then(result => {
tokenContract = result;
});

Expand All @@ -215,7 +207,7 @@ You can also see full examples in [./examples](./examples);
// with `.call` method, `aelf-sdk` will only call read-only method
const result = await tokenContract.GetBalance.call({
symbol: 'ELF',
owner: '7s4XoUHfPuqoZAwnTV7pHWZAaivMiL8aZrDSnY9brE1woa8vz',
owner: '7s4XoUHfPuqoZAwnTV7pHWZAaivMiL8aZrDSnY9brE1woa8vz'
});
console.log(result);
/**
Expand All @@ -230,7 +222,7 @@ You can also see full examples in [./examples](./examples);
symbol: 'ELF',
to: '7s4XoUHfPuqoZAwnTV7pHWZAaivMiL8aZrDSnY9brE1woa8vz',
amount: '1000000000',
memo: 'transfer in demo',
memo: 'transfer in demo'
});
console.log(transactionId);
/**
Expand All @@ -246,9 +238,7 @@ You can also see full examples in [./examples](./examples);
```javascript
import AElf from 'aelf-sdk';

const aelf = new AElf(
new AElf.providers.HttpProvider('http://127.0.0.1:1235')
);
const aelf = new AElf(new AElf.providers.HttpProvider('http://127.0.0.1:1235'));
aelf.setProvider(new AElf.providers.HttpProvider('http://127.0.0.1:8000'));
```

Expand Down Expand Up @@ -299,7 +289,7 @@ _Returns_
_Example_

```javascript
aelf.chain.getChainStatus().then((res) => {
aelf.chain.getChainStatus().then(res => {
console.log(res);
});
```
Expand All @@ -323,7 +313,7 @@ _Returns_
_Example_

```javascript
aelf.chain.getContractFileDescriptorSet(contractAddress).then((res) => {
aelf.chain.getContractFileDescriptorSet(contractAddress).then(res => {
console.log(res);
});
```
Expand All @@ -347,7 +337,7 @@ _Returns_
_Example_

```javascript
aelf.chain.getBlockHeight().then((res) => {
aelf.chain.getBlockHeight().then(res => {
console.log(res);
});
```
Expand Down Expand Up @@ -391,7 +381,7 @@ _Returns_
_Example_

```javascript
aelf.chain.getBlock(blockHash, false).then((res) => {
aelf.chain.getBlock(blockHash, false).then(res => {
console.log(res);
});
```
Expand Down Expand Up @@ -435,7 +425,7 @@ _Returns_
_Example_

```javascript
aelf.chain.getBlockByHeight(12, false).then((res) => {
aelf.chain.getBlockByHeight(12, false).then(res => {
console.log(res);
});
```
Expand Down Expand Up @@ -479,7 +469,7 @@ _Returns_
_Example_

```javascript
aelf.chain.getTxResult(transactionId).then((res) => {
aelf.chain.getTxResult(transactionId).then(res => {
console.log(res);
});
```
Expand All @@ -506,7 +496,7 @@ _Returns_
_Example_

```javascript
aelf.chain.getTxResults(blockHash, 0, 2).then((res) => {
aelf.chain.getTxResults(blockHash, 0, 2).then(res => {
console.log(res);
});
```
Expand Down Expand Up @@ -594,7 +584,7 @@ you need to create a aelf authorization instance and set a provider
```javascript
const aelf = new AElf(
new AElf.providers.HttpProvider('http://127.0.0.1:8000', 8000, {
Authorization: AElf.utils.getAuthorization('UseName', 'Password'),
Authorization: AElf.utils.getAuthorization('UseName', 'Password')
})
);
```
Expand All @@ -604,11 +594,11 @@ _Example_
```javascript
const aelf = new AElf(
new AElf.providers.HttpProvider('http://127.0.0.1:8000', 8000, {
Authorization: AElf.utils.getAuthorization('aelf', '12345678'),
Authorization: AElf.utils.getAuthorization('aelf', '12345678')
})
);

aelf.chain.addPeer('192.168.11.140:6801').then((res) => {
aelf.chain.addPeer('192.168.11.140:6801').then(res => {
console.log(res);
});
```
Expand All @@ -622,7 +612,7 @@ you need to create a aelf authorization instance and set a provider
```javascript
const aelf = new AElf(
new AElf.providers.HttpProvider('http://127.0.0.1:8000', 8000, {
Authorization: AElf.utils.getAuthorization('UseName', 'Password'),
Authorization: AElf.utils.getAuthorization('UseName', 'Password')
})
);
```
Expand All @@ -632,11 +622,11 @@ _Example_
```javascript
const aelf = new AElf(
new AElf.providers.HttpProvider('http://127.0.0.1:8000', 8000, {
Authorization: AElf.utils.getAuthorization('aelf', '12345678'),
Authorization: AElf.utils.getAuthorization('aelf', '12345678')
})
);

aelf.chain.removePeer('192.168.11.140:6801').then((res) => {
aelf.chain.removePeer('192.168.11.140:6801').then(res => {
console.log(res);
});
```
Expand Down Expand Up @@ -792,8 +782,9 @@ AElf.version; // eg. 3.2.23
![node](https://img.shields.io/badge/node->=10-green.svg)

## 4. Building
- [Node.js](https://nodejs.org)
- [npm](https://www.npmjs.com/)

- [Node.js](https://nodejs.org)
- [npm](https://www.npmjs.com/)

```bash
sudo apt-get update
Expand All @@ -816,6 +807,7 @@ yarn run test
```

Commit code will run test and lint automatically, and show the test result in readme.md, please make sure all test cases passed.

### 4.3 About contributing

Read out [contributing guide](./.github/CONTRIBUTING.md)
Expand Down
Loading
Loading