-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Move to types bundle #4011
Merged
Merged
Move to types bundle #4011
Changes from 35 commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
f915972
support ethereum addresses
joelamouche df6c191
corrections
joelamouche 46057dd
add standalone url and ethereum identicons
joelamouche fcefb90
add moonbeam config
joelamouche e5d9908
added changes from the old pr
joelamouche 9707a48
add new config
joelamouche 1725bff
added dummy rpc method declarations for eth methods
joelamouche 3821ee0
wip fix address add modal
joelamouche 173525d
support ethereum addresses
joelamouche d959ad0
corrections
joelamouche 4d3863e
add standalone url and ethereum identicons
joelamouche 94dafe6
add moonbeam config
joelamouche 5bda4df
added changes from the old pr
joelamouche 379923a
add new config
joelamouche ab9a0e1
added dummy rpc method declarations for eth methods
joelamouche 05f0b5a
wip fix address add modal
joelamouche 8f3ce13
ok
joelamouche c60a567
wip repair app with new keyring
joelamouche 66f695f
use isDevelopement false for ethereum
joelamouche 267dac3
lint
joelamouche 4eaf8e7
more formatng
joelamouche b41a9c8
eth addresses by default for account creation
joelamouche 6ac97a6
sync with parity master
joelamouche 31a3875
Merge branch 'master' into node-moonbeam-integration-2
joelamouche ee630e6
added many more types to support moonbeam
joelamouche 61552bf
added color
joelamouche 6fc041a
add h160 to types and components
joelamouche e618105
add rpc methods to app-config
joelamouche cdea06d
sync with master #Merge branch 'master' into node-moonbeam-integration-2
joelamouche da71df3
lint
joelamouche 16e94a8
polish
joelamouche 7e2a535
Update packages/react-params/src/initValue.ts
joelamouche 706f031
Apply suggestions from code review
joelamouche 58ca9c8
mobe to typesBundle
joelamouche 4251a94
sync with master
joelamouche 712af03
added right type for types declaration
joelamouche 8d56f39
lint
joelamouche 5dc0ff5
sync with master
joelamouche 5de8089
corrected type and removed moobeam specs
joelamouche File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// Copyright 2017-2020 @polkadot/apps-config authors & contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import { OverrideBundleDefinition } from '@polkadot/types/types'; | ||
|
||
// structs need to be in order | ||
/* eslint-disable sort-keys */ | ||
|
||
export default { | ||
AccountId: 'EthereumAccountId', | ||
Address: 'AccountId', | ||
Balance: 'u128', | ||
RefCount: 'u8', | ||
LookupSource: 'AccountId', | ||
Account: { | ||
nonce: 'U256', | ||
balance: 'u128' | ||
}, | ||
TransactionCondition: { | ||
_enum: { | ||
block: 'u64', | ||
time: 'u64' | ||
} | ||
}, | ||
Transaction: { | ||
action: 'String', | ||
block_hash: 'Option<H256>', | ||
block_number: 'Option<U256>', | ||
chain_id: 'Option<u64>', | ||
condition: 'Option<TransactionCondition>', | ||
creates: 'Option<H160>', | ||
from: 'H160', | ||
gas: 'U256', | ||
gas_price: 'U256', | ||
gas_limit: 'u64', | ||
hash: 'H256', | ||
input: 'Bytes', | ||
nonce: 'U256', | ||
public_key: 'Option<H512>', | ||
r: 'U256', | ||
raw: 'Bytes', | ||
s: 'U256', | ||
signature: 'Signature', | ||
standard_v: 'U256', | ||
to: 'Option<H160>', | ||
transaction_index: 'Option<U256>', | ||
v: 'U256', | ||
value: 'U256' | ||
}, | ||
Signature: { | ||
v: 'u64', | ||
r: 'H256', | ||
s: 'H256' | ||
}, | ||
TransactionStatus: { | ||
transaction_hash: 'H256', | ||
transaction_index: 'u32', | ||
from: 'H160', | ||
to: 'Option<H160>', | ||
contract_address: 'Option<H160>', | ||
logs: 'Vec<Log>', | ||
logs_bloom: 'Bloom' | ||
}, | ||
Receipt: { | ||
transaction_hash: 'Option<H256>', | ||
transaction_index: 'Option<U256>', | ||
block_hash: 'Option<H256>', | ||
from: 'Option<H160>', | ||
to: 'Option<H160>', | ||
block_number: 'Option<U256>', | ||
cumulative_gas_used: 'U256', | ||
gas_used: 'Option<U256>', | ||
contract_address: 'Option<H160>', | ||
logs: 'Vec<Log>', | ||
state_root: 'Option<H256>', | ||
logs_bloom: 'H2048', | ||
status_code: 'Option<U64>' | ||
} | ||
} as OverrideBundleDefinition; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,149 @@ | ||
// Copyright 2017-2020 @polkadot/apps-config authors & contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import { DefinitionRpc, DefinitionRpcParam } from '@polkadot/types/types'; | ||
import { DefinitionRpc, DefinitionRpcParam } from "@polkadot/types/types"; | ||
|
||
export default function (): Record<string, Record<string, DefinitionRpc>> { | ||
function generateDescription (description:string, returnType:string, params:DefinitionRpcParam[] = []):DefinitionRpc { | ||
export default function(): Record<string, Record<string, DefinitionRpc>> { | ||
function generateDescription( | ||
description: string, | ||
returnType: string, | ||
params: DefinitionRpcParam[] = [] | ||
): DefinitionRpc { | ||
return { | ||
description, | ||
params, | ||
type: returnType | ||
}; | ||
} | ||
|
||
const numberParam: DefinitionRpcParam = { isOptional: true, name: 'number', type: 'BlockNumber' }; | ||
const hashParam: DefinitionRpcParam = { name: 'hash', type: 'H256' }; | ||
const reqParam: DefinitionRpcParam = { name: 'request', type: 'CallRequest' }; | ||
const blockParam: DefinitionRpcParam = { name: 'block', type: 'BlockNumber' }; | ||
const addressParam: DefinitionRpcParam = { name: 'address', type: 'H160' }; | ||
const indexParam: DefinitionRpcParam = { name: 'index', type: 'U256' }; | ||
const numberParam: DefinitionRpcParam = { isOptional: true, name: "number", type: "BlockNumber" }; | ||
const hashParam: DefinitionRpcParam = { name: "hash", type: "H256" }; | ||
const reqParam: DefinitionRpcParam = { name: "request", type: "CallRequest" }; | ||
const blockParam: DefinitionRpcParam = { name: "block", type: "BlockNumber" }; | ||
const addressParam: DefinitionRpcParam = { name: "address", type: "H160" }; | ||
const indexParam: DefinitionRpcParam = { name: "index", type: "U256" }; | ||
|
||
return { | ||
eth: { | ||
accounts: generateDescription('Returns accounts list.', 'Vec<H160>'), | ||
blockNumber: generateDescription('Returns balance of the given account.', 'U256'), | ||
call: generateDescription('Call contract, returning the output data.', 'Bytes', [reqParam, numberParam]), | ||
chainId: generateDescription('Returns the chain ID used for transaction signing at the current best block. None is returned if not available.', 'U64'), | ||
coinbase: generateDescription('Returns block author.', 'H160'), | ||
estimateGas: generateDescription('Estimate gas needed for execution of given contract.', 'U256', [reqParam, numberParam]), | ||
gasPrice: generateDescription('Returns current gas_price.', 'U256'), | ||
getBalance: generateDescription('Returns balance of the given account.', 'U256', [addressParam, numberParam]), | ||
getBlockByHash: generateDescription('Returns block with given hash.', 'RichBlock', [hashParam, { isOptional: true, name: 'full', type: 'bool' }]), | ||
getBlockByNumber: generateDescription('Returns block with given number.', 'RichBlock', [blockParam, { isOptional: true, name: 'full', type: 'bool' }]), | ||
getBlockTransactionCountByHash: generateDescription('Returns the number of transactions in a block with given hash.', 'U256', [hashParam]), | ||
getBlockTransactionCountByNumber: generateDescription('Returns the number of transactions in a block with given block number.', 'U256', [blockParam]), | ||
getCode: generateDescription('Returns the code at given address at given time (block number).', 'Bytes', [addressParam, numberParam]), | ||
getLogs: generateDescription('Returns logs matching given filter object.', 'Vec<Log>', [{ name: 'filter', type: 'Filter' }]), | ||
getStorageAt: generateDescription('Returns content of the storage at given address.', 'H256', [addressParam, indexParam, numberParam]), | ||
getTransactionByBlockHashAndIndex: generateDescription('Returns transaction at given block hash and index.', 'Transaction', [hashParam, indexParam]), | ||
getTransactionByBlockNumberAndIndex: generateDescription('Returns transaction by given block number and index.', 'Transaction', [numberParam, indexParam]), | ||
getTransactionByHash: generateDescription('Get transaction by its hash.', 'Transaction', [hashParam]), | ||
getTransactionCount: generateDescription('Returns the number of transactions sent from given address at given time (block number).', 'U256', [hashParam, numberParam]), | ||
getTransactionReceipt: generateDescription('Returns transaction receipt by transaction hash.', 'Receipt', [hashParam]), | ||
getUncleByBlockHashAndIndex: generateDescription('Returns an uncles at given block and index.', 'RichBlock', [hashParam, indexParam]), | ||
getUncleByBlockNumberAndIndex: generateDescription('Returns an uncles at given block and index.', 'RichBlock', [numberParam, indexParam]), | ||
getUncleCountByBlockHash: generateDescription('Returns the number of uncles in a block with given hash.', 'U256', [hashParam]), | ||
getUncleCountByBlockNumber: generateDescription('Returns the number of uncles in a block with given block number.', 'U256', [numberParam]), | ||
getWork: generateDescription('Returns the hash of the current block, the seedHash, and the boundary condition to be met.', 'Work'), | ||
hashrate: generateDescription('Returns the number of hashes per second that the node is mining with.', 'U256'), | ||
mining: generateDescription('Returns true if client is actively mining new blocks.', 'bool'), | ||
protocolVersion: generateDescription('Returns protocol version encoded as a string (quotes are necessary).', 'u64'), | ||
sendRawTransaction: generateDescription('Sends signed transaction, returning its hash.', 'BoxFuture<H256>', [{ name: 'bytes', type: 'Bytes' }]), | ||
submitHashrate: generateDescription('Used for submitting mining hashrate.', 'bool', [indexParam, hashParam]), | ||
submitWork: generateDescription('Used for submitting a proof-of-work solution.', 'bool', [{ name: '_', type: 'H64' }, { name: '_', type: 'H256' }, { name: '_', type: 'H256' }]), | ||
subscribe: generateDescription('Subscribe to Eth subscription.', '', [{ name: '_metadata', type: 'Self::Metadata' }, { name: 'subscriber', type: 'Subscriber<PubSubResult>' }, { name: 'kind', type: 'Kind' }, { isOptional: true, name: 'params', type: 'Params' }]), | ||
syncing: generateDescription('Returns an object with data about the sync status or false. (wtf?)', 'SyncStatus'), | ||
unsubscribe: generateDescription('nsubscribe from existing Eth subscription.', '', [{ name: '_metadata', type: 'Self::Metadata' }, { name: 'subscription_id', type: 'Self::SubscriptionId' }]) | ||
accounts: generateDescription("Returns accounts list.", "Vec<H160>"), | ||
blockNumber: generateDescription("Returns balance of the given account.", "U256"), | ||
call: generateDescription("Call contract, returning the output data.", "Bytes", [reqParam, numberParam]), | ||
chainId: generateDescription( | ||
"Returns the chain ID used for transaction signing at the current best block. None is returned if not available.", | ||
"U64" | ||
), | ||
coinbase: generateDescription("Returns block author.", "H160"), | ||
estimateGas: generateDescription("Estimate gas needed for execution of given contract.", "U256", [ | ||
reqParam, | ||
numberParam | ||
]), | ||
gasPrice: generateDescription("Returns current gas_price.", "U256"), | ||
getBalance: generateDescription("Returns balance of the given account.", "U256", [addressParam, numberParam]), | ||
getBlockByHash: generateDescription("Returns block with given hash.", "RichBlock", [ | ||
hashParam, | ||
{ isOptional: true, name: "full", type: "bool" } | ||
]), | ||
getBlockByNumber: generateDescription("Returns block with given number.", "RichBlock", [ | ||
blockParam, | ||
{ isOptional: true, name: "full", type: "bool" } | ||
]), | ||
getBlockTransactionCountByHash: generateDescription( | ||
"Returns the number of transactions in a block with given hash.", | ||
"U256", | ||
[hashParam] | ||
), | ||
getBlockTransactionCountByNumber: generateDescription( | ||
"Returns the number of transactions in a block with given block number.", | ||
"U256", | ||
[blockParam] | ||
), | ||
getCode: generateDescription("Returns the code at given address at given time (block number).", "Bytes", [ | ||
addressParam, | ||
numberParam | ||
]), | ||
getLogs: generateDescription("Returns logs matching given filter object.", "Vec<Log>", [ | ||
{ name: "filter", type: "Filter" } | ||
]), | ||
getStorageAt: generateDescription("Returns content of the storage at given address.", "H256", [ | ||
addressParam, | ||
indexParam, | ||
numberParam | ||
]), | ||
getTransactionByBlockHashAndIndex: generateDescription( | ||
"Returns transaction at given block hash and index.", | ||
"Transaction", | ||
[hashParam, indexParam] | ||
), | ||
getTransactionByBlockNumberAndIndex: generateDescription( | ||
"Returns transaction by given block number and index.", | ||
"Transaction", | ||
[numberParam, indexParam] | ||
), | ||
getTransactionByHash: generateDescription("Get transaction by its hash.", "Transaction", [hashParam]), | ||
getTransactionCount: generateDescription( | ||
"Returns the number of transactions sent from given address at given time (block number).", | ||
"U256", | ||
[hashParam, numberParam] | ||
), | ||
getTransactionReceipt: generateDescription("Returns transaction receipt by transaction hash.", "Receipt", [ | ||
hashParam | ||
]), | ||
getUncleByBlockHashAndIndex: generateDescription("Returns an uncles at given block and index.", "RichBlock", [ | ||
hashParam, | ||
indexParam | ||
]), | ||
getUncleByBlockNumberAndIndex: generateDescription("Returns an uncles at given block and index.", "RichBlock", [ | ||
numberParam, | ||
indexParam | ||
]), | ||
getUncleCountByBlockHash: generateDescription( | ||
"Returns the number of uncles in a block with given hash.", | ||
"U256", | ||
[hashParam] | ||
), | ||
getUncleCountByBlockNumber: generateDescription( | ||
"Returns the number of uncles in a block with given block number.", | ||
"U256", | ||
[numberParam] | ||
), | ||
getWork: generateDescription( | ||
"Returns the hash of the current block, the seedHash, and the boundary condition to be met.", | ||
"Work" | ||
), | ||
hashrate: generateDescription("Returns the number of hashes per second that the node is mining with.", "U256"), | ||
mining: generateDescription("Returns true if client is actively mining new blocks.", "bool"), | ||
protocolVersion: generateDescription( | ||
"Returns protocol version encoded as a string (quotes are necessary).", | ||
"u64" | ||
), | ||
sendRawTransaction: generateDescription("Sends signed transaction, returning its hash.", "BoxFuture<H256>", [ | ||
{ name: "bytes", type: "Bytes" } | ||
]), | ||
submitHashrate: generateDescription("Used for submitting mining hashrate.", "bool", [indexParam, hashParam]), | ||
submitWork: generateDescription("Used for submitting a proof-of-work solution.", "bool", [ | ||
{ name: "_", type: "H64" }, | ||
{ name: "_", type: "H256" }, | ||
{ name: "_", type: "H256" } | ||
]), | ||
subscribe: generateDescription("Subscribe to Eth subscription.", "", [ | ||
{ name: "_metadata", type: "Self::Metadata" }, | ||
{ name: "subscriber", type: "Subscriber<PubSubResult>" }, | ||
{ name: "kind", type: "Kind" }, | ||
{ isOptional: true, name: "params", type: "Params" } | ||
]), | ||
syncing: generateDescription("Returns an object with data about the sync status or false. (wtf?)", "SyncStatus"), | ||
unsubscribe: generateDescription("nsubscribe from existing Eth subscription.", "", [ | ||
{ name: "_metadata", type: "Self::Metadata" }, | ||
{ name: "subscription_id", type: "Self::SubscriptionId" } | ||
]) | ||
}, | ||
net: { | ||
listening: generateDescription('Returns true if client is actively listening for network connections. Otherwise false.', 'bool'), | ||
peerCount: generateDescription('Returns number of peers connected to node.', 'String'), | ||
version: generateDescription('Returns protocol version.', 'String') | ||
listening: generateDescription( | ||
"Returns true if client is actively listening for network connections. Otherwise false.", | ||
"bool" | ||
), | ||
peerCount: generateDescription("Returns number of peers connected to node.", "String"), | ||
version: generateDescription("Returns protocol version.", "String") | ||
} | ||
}; | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The format is slightly different here, and probably the issue.
Here is an example,
This allos you to manage multiples, see eg. https://github.com/polkadot-js/api/blob/master/packages/types-known/src/spec/kusama.ts where it is done for Kusama
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks :)
However, doesn't that mean that the laminar and acala files use the wrong type (OverrideBundleDefinition)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it looks like using OverrideVersionedType[] like in the example you provided doesn't conform to the type for Api.create of react-api
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may be slightly different, honestly would need to look at what it does under the hood. Too many type options.
(I have been meaning to move all types across for all chains, Acala added the required support into the UI specifically since they had upgrades lines up)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jacogr have you had the occasion to look? Should I try again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should just work as defined here.
You do
OverrideVersionedType[]
which aligns with types-known, as first used.When passed to the API, it expects
typesBundle: OverrideBundleType
which is of this form -The api-react should take the stuff defined and just put it in that format.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, so what you should export is -
aka a
OverrideBundleDefinition
which looks like -TL;DR Seems like you are just missing the top-level
types:
key containing the array.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Like I said once the types is in, we can attempt to move the RPCs as well - not 100% sure the API uses it atm, the intent is there - if it doesn't can fix)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the help. Should be ready now!
Not too hot on adding features that aren't needed explicitly but I can add that as well if you feel this is important
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I'm sure that stuff is going to break and it is more for my benefit ... so I'll ply with that and see what breaks horribly. However, will get you to review once ready. (Not promising in the next couple of days, but having seen that again makes me want to get it going)