Skip to content

Commit

Permalink
Merge pull request #34 from kaiachain/feat/update-rpc-docs-21-8-24
Browse files Browse the repository at this point in the history
feat: update api changes
  • Loading branch information
Sotatek-TanHoang authored Aug 22, 2024
2 parents f2dd3ec + 61c12f4 commit 478c681
Show file tree
Hide file tree
Showing 27 changed files with 686 additions and 103 deletions.
13 changes: 9 additions & 4 deletions documentation/index.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ paths:
$ref: ../web3rpc/rpc-specs/paths/kaia/configuration/protocolVersion.yaml#/paths/~1kaia~1configuration~1protocolVersion
/kaia/configuration/rewardbase:
$ref: ../web3rpc/rpc-specs/paths/kaia/configuration/rewardBase.yaml#/paths/~1kaia~1configuration~1rewardbase
/kaia/configuration/getParams:
$ref: ../web3rpc/rpc-specs/paths/kaia/configuration/getParams.yaml#/paths/~1kaia~1configuration~1getParams

# kaia/filter
/kaia/filter/getFilterChanges:
Expand Down Expand Up @@ -196,6 +198,8 @@ paths:
$ref: ../web3rpc/rpc-specs/paths/kaia/miscellaneous/sha3.yaml#/paths/~1kaia~1miscellaneous~1sha3
/kaia/miscellaneous/getProof:
$ref: ../web3rpc/rpc-specs/paths/kaia/miscellaneous/getProof.yaml#/paths/~1kaia~1miscellaneous~1getProof
/kaia/miscellaneous/getTotalSupply:
$ref: ../web3rpc/rpc-specs/paths/kaia/miscellaneous/getTotalSupply.yaml#/paths/~1kaia~1miscellaneous~1getTotalSupply

# klay/account
/klay/account/accountCreated:
Expand Down Expand Up @@ -318,6 +322,8 @@ paths:
$ref: ../web3rpc/rpc-specs/paths/klay/configuration/protocolVersion.yaml#/paths/~1klay~1configuration~1protocolVersion
/klay/configuration/rewardbase:
$ref: ../web3rpc/rpc-specs/paths/klay/configuration/rewardBase.yaml#/paths/~1klay~1configuration~1rewardbase
/klay/configuration/getParams:
$ref: ../web3rpc/rpc-specs/paths/klay/configuration/getParams.yaml#/paths/~1klay~1configuration~1getParams

# klay/filter
/klay/filter/getFilterChanges:
Expand Down Expand Up @@ -418,7 +424,6 @@ paths:
/eth/block/getBlockReceipt:
$ref: ../web3rpc/rpc-specs/paths/eth/block/getBlockReceipts.yaml#/paths/~1eth~1block~1getBlockReceipts


# eth/transaction
/eth/transaction/call:
$ref: ../web3rpc/rpc-specs/paths/eth/transaction/call.yaml#/paths/~1eth~1transaction~1call
Expand Down Expand Up @@ -460,7 +465,7 @@ paths:
$ref: ../web3rpc/rpc-specs/paths/eth/config/coinbase.yaml#/paths/~1eth~1config~1coinbase
/eth/config/etherbase:
$ref: ../web3rpc/rpc-specs/paths/eth/config/etherbase.yaml#/paths/~1eth~1config~1etherbase

/eth/protocolVersion:
$ref: ../web3rpc/rpc-specs/paths/eth/config/protocolVersion.yaml#/paths/~1eth~1config~1protocolVersion

Expand Down Expand Up @@ -820,12 +825,12 @@ paths:
/subbridge/deregisterToken:
$ref: ../web3rpc/rpc-specs/paths/subbridge/deregisterToken.yaml#/paths/~1subbridge~1deregisterToken
/subbridge/convertRequestTxHashToHandleTxHash:
$ref: ../web3rpc/rpc-specs/paths/subbridge/convertRequestTxHashToHandleTxHash.yaml#/paths/~1subbridge~1convertRequestTxHashToHandleTxHash
$ref: ../web3rpc/rpc-specs/paths/subbridge/convertRequestTxHashToHandleTxHash.yaml#/paths/~1subbridge~1convertRequestTxHashToHandleTxHash
/subbridge/listBridge:
$ref: ../web3rpc/rpc-specs/paths/subbridge/listBridge.yaml#/paths/~1subbridge~1listBridge
/subbridge/getBridgeInFormation:
$ref: ../web3rpc/rpc-specs/paths/subbridge/getBridgeInformation.yaml#/paths/~1subbridge~1getBridgeInformation
/subbridge/txPendingCount:
$ref: ../web3rpc/rpc-specs/paths/subbridge/txPendingCount.yaml#/paths/~1subbridge~1txPendingCount
/subbridge/txPending:
$ref: ../web3rpc/rpc-specs/paths/subbridge/txPending.yaml#/paths/~1subbridge~1txPending
$ref: ../web3rpc/rpc-specs/paths/subbridge/txPending.yaml#/paths/~1subbridge~1txPending
9 changes: 6 additions & 3 deletions documentation/namespaces/kaia.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ servers:
- url: https://public-en-cypress.klaytn.net
- url: http://localhost:8551
paths:

# kaia/account
/kaia/account/accountCreated:
$ref: ../../web3rpc/rpc-specs/paths/kaia/account/accountCreated.yaml#/paths/~1kaia~1account~1accountCreated
Expand Down Expand Up @@ -123,7 +122,7 @@ paths:
$ref: ../../web3rpc/rpc-specs/paths/kaia/transaction/resend.yaml#/paths/~1kaia~1transaction~1resend
/kaia/getRawTransactionByBlockNumberAndIndex:
$ref: ../../web3rpc/rpc-specs/paths/kaia/transaction/getRawTransactionByBlockNumberAndIndex.yaml#/paths/~1kaia~1transaction~1getRawTransactionByBlockNumberAndIndex

# kaia/configuration
/kaia/configuration/chainID:
$ref: ../../web3rpc/rpc-specs/paths/kaia/configuration/chainID.yaml#/paths/~1kaia~1configuration~1chainID
Expand All @@ -143,6 +142,8 @@ paths:
$ref: ../../web3rpc/rpc-specs/paths/kaia/configuration/getChainConfig.yaml#/paths/~1kaia~1configuration~1getChainConfig
/kaia/configuration/forkStatus:
$ref: ../../web3rpc/rpc-specs/paths/kaia/configuration/forkStatus.yaml#/paths/~1kaia~1configuration~1forkStatus
/kaia/configuration/getParams:
$ref: ../../web3rpc/rpc-specs/paths/kaia/configuration/getParams.yaml#/paths/~1kaia~1configuration~1getParams

# kaia/filter
/kaia/filter/getFilterChanges:
Expand Down Expand Up @@ -186,4 +187,6 @@ paths:
/kaia/miscellaneous/getProof:
$ref: ../../web3rpc/rpc-specs/paths/kaia/miscellaneous/getProof.yaml#/paths/~1kaia~1miscellaneous~1getProof
/kaia/miscellaneous/nodeAddress:
$ref: ../../web3rpc/rpc-specs/paths/kaia/miscellaneous/nodeAddress.yaml#/paths/~1kaia~1miscellaneous~1nodeAddress
$ref: ../../web3rpc/rpc-specs/paths/kaia/miscellaneous/nodeAddress.yaml#/paths/~1kaia~1miscellaneous~1nodeAddress
/kaia/miscellaneous/getTotalSupply:
$ref: ../../web3rpc/rpc-specs/paths/kaia/miscellaneous/getTotalSupply.yaml#/paths/~1kaia~1miscellaneous~1getTotalSupply
9 changes: 5 additions & 4 deletions documentation/namespaces/klay.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ servers:
- url: https://public-en-cypress.klaytn.net
- url: http://localhost:8551
paths:

# klay/account
/klay/account/accountCreated:
$ref: ../../web3rpc/rpc-specs/paths/klay/account/accountCreated.yaml#/paths/~1klay~1account~1accountCreated
Expand Down Expand Up @@ -123,7 +122,7 @@ paths:
$ref: ../../web3rpc/rpc-specs/paths/klay/transaction/resend.yaml#/paths/~1klay~1transaction~1resend
/klay/getRawTransactionByBlockNumberAndIndex:
$ref: ../../web3rpc/rpc-specs/paths/klay/transaction/getRawTransactionByBlockNumberAndIndex.yaml#/paths/~1klay~1transaction~1getRawTransactionByBlockNumberAndIndex

# klay/configuration
/klay/configuration/chainID:
$ref: ../../web3rpc/rpc-specs/paths/klay/configuration/chainID.yaml#/paths/~1klay~1configuration~1chainID
Expand All @@ -141,6 +140,8 @@ paths:
$ref: ../../web3rpc/rpc-specs/paths/klay/configuration/getChainConfig.yaml#/paths/~1klay~1configuration~1getChainConfig
/klay/configuration/forkStatus:
$ref: ../../web3rpc/rpc-specs/paths/klay/configuration/forkStatus.yaml#/paths/~1klay~1configuration~1forkStatus
/klay/configuration/getParams:
$ref: ../../web3rpc/rpc-specs/paths/klay/configuration/getParams.yaml#/paths/~1klay~1configuration~1getParams

# klay/filter
/klay/filter/getFilterChanges:
Expand Down Expand Up @@ -186,12 +187,12 @@ paths:
$ref: ../../web3rpc/rpc-specs/paths/klay/miscellaneous/getProof.yaml#/paths/~1klay~1miscellaneous~1getProof
/klay/miscellaneous/nodeAddress:
$ref: ../../web3rpc/rpc-specs/paths/klay/miscellaneous/nodeAddress.yaml#/paths/~1klay~1miscellaneous~1nodeAddress

/klay/miscellaneous/getBlsInfos:
$ref: ../../web3rpc/rpc-specs/paths/klay/miscellaneous/getBlsInfos.yaml#/paths/~1klay~1miscellaneous~1getBlsInfos
/klay/miscellaneous/getActiveAddressFromRegistry:
$ref: ../../web3rpc/rpc-specs/paths/klay/miscellaneous/getActiveAddressFromRegistry.yaml#/paths/~1klay~1miscellaneous~1getActiveAddressFromRegistry
/klay/miscellaneous/getAllRecordsFromRegistry:
$ref: ../../web3rpc/rpc-specs/paths/klay/miscellaneous/getAllRecordsFromRegistry.yaml#/paths/~1klay~1miscellaneous~1getAllRecordsFromRegistry
/klay/miscellaneous/getTotalSupply:
$ref: ../../web3rpc/rpc-specs/paths/klay/miscellaneous/getTotalSupply.yaml#/paths/~1klay~1miscellaneous~1getTotalSupply
$ref: ../../web3rpc/rpc-specs/paths/klay/miscellaneous/getTotalSupply.yaml#/paths/~1klay~1miscellaneous~1getTotalSupply
64 changes: 32 additions & 32 deletions web3py-ext/web3py_ext/web3rpc/klay_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,6 @@ class KlayApi(Module):
namespace = "klay"


__get_chain_config: Method[Callable[..., Any]] = Method(
namespace + "_getChainConfig", mungers=[default_root_munger]
)

def _get_chain_config(self, *args) -> Any:
return self.__get_chain_config(*args)


_account_created: Method[Callable[..., Any]] = Method(
namespace + "_accountCreated", mungers=[default_root_munger]
)
Expand Down Expand Up @@ -137,14 +129,6 @@ def gas_price(self, *args) -> Any:
return self._gas_price(*args)


_gas_price_at: Method[Callable[..., Any]] = Method(
namespace + "_gasPriceAt", mungers=[default_root_munger]
)

def gas_price_at(self, *args) -> Any:
return self._gas_price_at(*args)


_get_account: Method[Callable[..., Any]] = Method(
namespace + "_getAccount", mungers=[default_root_munger]
)
Expand Down Expand Up @@ -257,6 +241,14 @@ def get_bls_infos(self, *args) -> Any:
return self._get_bls_infos(*args)


_get_chain_config: Method[Callable[..., Any]] = Method(
namespace + "_getChainConfig", mungers=[default_root_munger]
)

def get_chain_config(self, *args) -> Any:
return self._get_chain_config(*args)


_get_code: Method[Callable[..., Any]] = Method(
namespace + "_getCode", mungers=[default_root_munger]
)
Expand Down Expand Up @@ -345,6 +337,14 @@ def get_logs(self, *args) -> Any:
return self._get_logs(*args)


_get_params: Method[Callable[..., Any]] = Method(
namespace + "_getParams", mungers=[default_root_munger]
)

def get_params(self, *args) -> Any:
return self._get_params(*args)


_get_proof: Method[Callable[..., Any]] = Method(
namespace + "_getProof", mungers=[default_root_munger]
)
Expand Down Expand Up @@ -686,14 +686,6 @@ class AsyncKlayApi(Module):
namespace = "klay"


__get_chain_config: Method[Callable[..., Awaitable[Any]]] = Method(
namespace + "_getChainConfig", mungers=[default_root_munger]
)

async def _get_chain_config(self, *args) -> Any:
return await self.__get_chain_config(*args)


_account_created: Method[Callable[..., Awaitable[Any]]] = Method(
namespace + "_accountCreated", mungers=[default_root_munger]
)
Expand Down Expand Up @@ -806,14 +798,6 @@ async def gas_price(self, *args) -> Any:
return await self._gas_price(*args)


_gas_price_at: Method[Callable[..., Awaitable[Any]]] = Method(
namespace + "_gasPriceAt", mungers=[default_root_munger]
)

async def gas_price_at(self, *args) -> Any:
return await self._gas_price_at(*args)


_get_account: Method[Callable[..., Awaitable[Any]]] = Method(
namespace + "_getAccount", mungers=[default_root_munger]
)
Expand Down Expand Up @@ -926,6 +910,14 @@ async def get_bls_infos(self, *args) -> Any:
return await self._get_bls_infos(*args)


_get_chain_config: Method[Callable[..., Awaitable[Any]]] = Method(
namespace + "_getChainConfig", mungers=[default_root_munger]
)

async def get_chain_config(self, *args) -> Any:
return await self._get_chain_config(*args)


_get_code: Method[Callable[..., Awaitable[Any]]] = Method(
namespace + "_getCode", mungers=[default_root_munger]
)
Expand Down Expand Up @@ -1014,6 +1006,14 @@ async def get_logs(self, *args) -> Any:
return await self._get_logs(*args)


_get_params: Method[Callable[..., Awaitable[Any]]] = Method(
namespace + "_getParams", mungers=[default_root_munger]
)

async def get_params(self, *args) -> Any:
return await self._get_params(*args)


_get_proof: Method[Callable[..., Awaitable[Any]]] = Method(
namespace + "_getProof", mungers=[default_root_munger]
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
curl -X 'POST' \
'https://api.baobab.klaytn.net:8651' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"method": "kaia_getParams",
"id": 1,
"jsonrpc": "2.0",
"params": [89]
}'
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
curl -X POST \
-H "Content-Type: application/json" \
--data '{
"jsonrpc": "2.0",
"method": "kaia_getTotalSupply",
"params": ["latest"],
"id": 1
}' \
https://api.baobab.klaytn.net:8651
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
curl -X 'POST' \
'https://api.baobab.klaytn.net:8651' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"method": "klay_getParams",
"id": 1,
"jsonrpc": "2.0",
"params": [89]
}'
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import org.web3j.protocol.http.HttpService;
import org.web3j.protocol.kaia.Web3j;
import org.web3j.protocol.kaia.core.method.response.KaiaGetParamsResponse;

import java.io.IOException;

public class KaiaGetParamsExample {
private Web3j w3 = Web3j.build(new HttpService("https://public-en-baobab.klaytn.net"));
void kaiaGetParamsExample() throws IOException {
int blockTag = 0;
KaiaGetParamsResponse response = w3.kaiaGetParams(blockTag).send();
response.getResult();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import org.web3j.protocol.http.HttpService;
import org.web3j.protocol.kaia.Web3j;
import org.web3j.protocol.kaia.core.method.response.KaiaGetTotalSupplyResponse;

import java.io.IOException;

public class KaiaGetTotalSupplyExample {
private Web3j w3 = Web3j.build(new HttpService("https://public-en-baobab.klaytn.net"));

void KaiaGetTotalSupply() throws IOException {
String blockNumber = "latest";
KaiaGetTotalSupplyResponse response = w3.kaiaGetTotalSupply(blockNumber).send();
response.getResult();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import org.web3j.protocol.http.HttpService;
import org.web3j.protocol.kaia.Web3j;
import org.web3j.protocol.kaia.core.method.response.KlayGetParamsResponse;

import java.io.IOException;

public class KlayGetParamsExample {
private Web3j w3 = Web3j.build(new HttpService("https://public-en-baobab.klaytn.net"));
void klayGetParamsExample() throws IOException {
int blockTag = 0;
KlayGetParamsResponse response = w3.klayGetParams(blockTag).send();
response.getResult();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const { JsonRpcProvider } = require("@kaiachain/ethers-ext");
(() => {
const provider = new JsonRpcProvider("https://public-en-baobab.klaytn.net");
const blockNumber = 89;

provider.kaia
.getParams(blockNumber, {}, (err, data, response) => {})
.then((data) => {
console.log(data);
});
})();
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const { JsonRpcProvider } = require("@kaiachain/ethers-ext");
(() => {
const provider = new JsonRpcProvider("https://public-en-baobab.klaytn.net");
const blockNumber = "latest";

provider.kaia
.getTotalSupply(blockNumber, {}, (err, data, response) => {})
.then((data) => {
console.log(data);
});
})();
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const { JsonRpcProvider } = require("@kaiachain/ethers-ext");
(() => {
const provider = new JsonRpcProvider("https://public-en-baobab.klaytn.net");
const blockNumber = 89;

provider.klay
.getParams(blockNumber, {}, (err, data, response) => {})
.then((data) => {
console.log(data);
});
})();
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from web3 import Web3
from web3py_ext import extend

host = "https://api.baobab.klaytn.net:8651"

blockNumber = 89

w3 = Web3(Web3.HTTPProvider(host))
kaia_response = w3.kaia.get_params(blockNumber)

print(kaia_response)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from web3 import Web3
from web3py_ext import extend

host = "https://api.baobab.klaytn.net:8651"

blockNumber = 'latest'

w3 = Web3(Web3.HTTPProvider(host))
kaia_response = w3.kaia.get_total_supply(blockNumber)

print(kaia_response)
Loading

0 comments on commit 478c681

Please sign in to comment.