Compare commits

...
6 Commits
Author SHA1 Message Date
Github Actions a3f5c65b5d [CI Skip] release/stable 6.4.2
skip-checks: true
2021-10-18 16:53:12 +00:00
JacoandAlexander Popiak 7f94137b2d Ensure SignerPayload correctly serializes Option with None (#4079)
* Ensure `SignerPayload` correctly serializes `Option` with `None`

* patch

* Update CHANGELOG.md

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>
2021-10-18 19:35:56 +03:00
Github Actions d65587f58d [CI Skip] release/beta 6.4.2-1
skip-checks: true
2021-10-18 14:24:15 +00:00
Jaco 8959455401 Add Eth Block{0, 1, 2} and TransactionV{0, 1, 2} (#4078)
* Add Eth Block{0, 1, 2} and TransactionV{0, 1, 2}

* CHANGELOG
2021-10-18 17:06:53 +03:00
Github Actions 8e40e38bd6 [CI Skip] release/beta 6.4.2-0
skip-checks: true
2021-10-18 11:49:20 +00:00
Jaco c646717576 Explicit tests for metadata re-serialization (#4077)
* Explicit tests for metadata re-serialization

* Skip re-serialized

* Add asCallsOnly tests
2021-10-18 14:25:45 +03:00
30 changed files with 349 additions and 130 deletions
+2
View File
@@ -39,3 +39,5 @@
6.0.4
6.0.5
6.1.2
6.4.2
+11
View File
@@ -1,5 +1,16 @@
# CHANGELOG
## 6.4.2 Oct 18, 2021
Upgrade priority: Low. Recommended for Westmint runtime 500+
Changes:
- Ensure `SignerPayload` correctly serializes `Option` with `None`
- Add Ethereum `BlockV{0, 1, 2}` types, aligning with latest Frontier
- Additional tests for metadata serialization/de-serialization
## 6.4.1 Oct 17, 2021
Upgrade priority: Low. Recommended for Kusama & Polkadot runtime 9110+
+1 -1
View File
@@ -35,6 +35,6 @@
"@types/jest": "^27.0.2",
"copyfiles": "^2.4.1"
},
"version": "6.4.1",
"version": "6.4.2",
"packageManager": "yarn@3.0.1"
}
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api-contract",
"version": "6.4.1",
"version": "6.4.2",
"type": "module",
"description": "Interfaces for interacting with contracts and contract ABIs",
"main": "index.js",
@@ -20,8 +20,8 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-contract#readme",
"dependencies": {
"@babel/runtime": "^7.15.4",
"@polkadot/api": "6.4.1",
"@polkadot/types": "6.4.1",
"@polkadot/api": "6.4.2",
"@polkadot/types": "6.4.2",
"@polkadot/util": "^7.5.1",
"rxjs": "^7.4.0"
}
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/api-contract', version: '6.4.1' };
export const packageInfo = { name: '@polkadot/api-contract', version: '6.4.2' };
+5 -5
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api-derive",
"version": "6.4.1",
"version": "6.4.2",
"type": "module",
"description": "Common functions used across Polkadot, derived from RPC calls and storage queries.",
"main": "index.js",
@@ -20,15 +20,15 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-derive#readme",
"dependencies": {
"@babel/runtime": "^7.15.4",
"@polkadot/api": "6.4.1",
"@polkadot/rpc-core": "6.4.1",
"@polkadot/types": "6.4.1",
"@polkadot/api": "6.4.2",
"@polkadot/rpc-core": "6.4.2",
"@polkadot/types": "6.4.2",
"@polkadot/util": "^7.5.1",
"@polkadot/util-crypto": "^7.5.1",
"rxjs": "^7.4.0"
},
"devDependencies": {
"@polkadot/keyring": "^7.5.1",
"@polkadot/rpc-provider": "6.4.1"
"@polkadot/rpc-provider": "6.4.2"
}
}
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/api-derive', version: '6.4.1' };
export const packageInfo = { name: '@polkadot/api-derive', version: '6.4.2' };
+6 -6
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api",
"version": "6.4.1",
"version": "6.4.2",
"type": "module",
"description": "Promise and RxJS wrappers around the Polkadot JS RPC",
"main": "index.js",
@@ -20,12 +20,12 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api#readme",
"dependencies": {
"@babel/runtime": "^7.15.4",
"@polkadot/api-derive": "6.4.1",
"@polkadot/api-derive": "6.4.2",
"@polkadot/keyring": "^7.5.1",
"@polkadot/rpc-core": "6.4.1",
"@polkadot/rpc-provider": "6.4.1",
"@polkadot/types": "6.4.1",
"@polkadot/types-known": "6.4.1",
"@polkadot/rpc-core": "6.4.2",
"@polkadot/rpc-provider": "6.4.2",
"@polkadot/types": "6.4.2",
"@polkadot/types-known": "6.4.2",
"@polkadot/util": "^7.5.1",
"@polkadot/util-crypto": "^7.5.1",
"eventemitter3": "^4.0.7",
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/api', version: '6.4.1' };
export const packageInfo = { name: '@polkadot/api', version: '6.4.2' };
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/rpc-core",
"version": "6.4.1",
"version": "6.4.2",
"type": "module",
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
"main": "index.js",
@@ -20,8 +20,8 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-core#readme",
"dependencies": {
"@babel/runtime": "^7.15.4",
"@polkadot/rpc-provider": "6.4.1",
"@polkadot/types": "6.4.1",
"@polkadot/rpc-provider": "6.4.2",
"@polkadot/types": "6.4.2",
"@polkadot/util": "^7.5.1",
"rxjs": "^7.4.0"
},
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/rpc-core', version: '6.4.1' };
export const packageInfo = { name: '@polkadot/rpc-core', version: '6.4.2' };
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/rpc-provider",
"version": "6.4.1",
"version": "6.4.2",
"type": "module",
"description": "Transport providers for the API",
"main": "index.js",
@@ -20,7 +20,7 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-provider#readme",
"dependencies": {
"@babel/runtime": "^7.15.4",
"@polkadot/types": "6.4.1",
"@polkadot/types": "6.4.2",
"@polkadot/util": "^7.5.1",
"@polkadot/util-crypto": "^7.5.1",
"@polkadot/x-fetch": "^7.5.1",
@@ -30,7 +30,7 @@
},
"devDependencies": {
"@polkadot/keyring": "^7.5.1",
"@polkadot/types": "6.4.1",
"@polkadot/types": "6.4.2",
"mock-socket": "^9.0.5",
"nock": "^13.1.3"
}
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/rpc-provider', version: '6.4.1' };
export const packageInfo = { name: '@polkadot/rpc-provider', version: '6.4.2' };
+5 -5
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/typegen",
"version": "6.4.1",
"version": "6.4.2",
"type": "module",
"description": "Type generation scripts",
"main": "index.js",
@@ -29,10 +29,10 @@
"@babel/core": "^7.15.8",
"@babel/register": "^7.15.3",
"@babel/runtime": "^7.15.4",
"@polkadot/api": "6.4.1",
"@polkadot/rpc-provider": "6.4.1",
"@polkadot/types": "6.4.1",
"@polkadot/types-support": "6.4.1",
"@polkadot/api": "6.4.2",
"@polkadot/rpc-provider": "6.4.2",
"@polkadot/types": "6.4.2",
"@polkadot/types-support": "6.4.2",
"@polkadot/util": "^7.5.1",
"handlebars": "^4.7.7",
"websocket": "^1.0.34",
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/typegen', version: '6.4.1' };
export const packageInfo = { name: '@polkadot/typegen', version: '6.4.2' };
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/types-known",
"version": "6.4.1",
"version": "6.4.2",
"type": "module",
"description": "Known type definitions",
"main": "index.js",
@@ -21,7 +21,7 @@
"dependencies": {
"@babel/runtime": "^7.15.4",
"@polkadot/networks": "^7.5.1",
"@polkadot/types": "6.4.1",
"@polkadot/types": "6.4.2",
"@polkadot/util": "^7.5.1"
}
}
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/types-known', version: '6.4.1' };
export const packageInfo = { name: '@polkadot/types-known', version: '6.4.2' };
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/types-support",
"version": "6.4.1",
"version": "6.4.2",
"type": "module",
"description": "Supporting files for types, mostly for testing",
"main": "index.js",
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/types-support', version: '6.4.1' };
export const packageInfo = { name: '@polkadot/types-support', version: '6.4.2' };
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/types",
"version": "6.4.1",
"version": "6.4.2",
"type": "module",
"description": "Implementation of the Parity codec",
"main": "index.js",
@@ -26,7 +26,7 @@
},
"devDependencies": {
"@polkadot/keyring": "^7.5.1",
"@polkadot/types-support": "6.4.1",
"@polkadot/types-support": "6.4.2",
"@types/bn.js": "^4.11.6",
"bn.js": "^4.12.0"
}
+13 -1
View File
@@ -23,7 +23,7 @@ import type { ConfigData, MessageId, OverweightIndex, PageCounter, PageIndexData
import type { AccountVote, AccountVoteSplit, AccountVoteStandard, Conviction, Delegations, PreimageStatus, PreimageStatusAvailable, PriorLock, PropIndex, Proposal, ProxyState, ReferendumIndex, ReferendumInfo, ReferendumInfoFinished, ReferendumInfoTo239, ReferendumStatus, Tally, Voting, VotingDelegating, VotingDirect, VotingDirectVote } from '@polkadot/types/interfaces/democracy';
import type { ApprovalFlag, DefunctVoter, Renouncing, SetIndex, Vote, VoteIndex, VoteThreshold, VoterInfo } from '@polkadot/types/interfaces/elections';
import type { CreatedBlock, ImportedAux } from '@polkadot/types/interfaces/engine';
import type { EthAccount, EthBlock, EthBloom, EthCallRequest, EthFilter, EthFilterAddress, EthFilterChanges, EthFilterTopic, EthFilterTopicEntry, EthFilterTopicInner, EthHeader, EthLog, EthReceipt, EthRichBlock, EthRichHeader, EthStorageProof, EthSubKind, EthSubParams, EthSubResult, EthSyncInfo, EthSyncStatus, EthTransaction, EthTransactionAction, EthTransactionCondition, EthTransactionRequest, EthTransactionSignature, EthTransactionStatus, EthWork, EthereumAccountId, EthereumLookupSource, EthereumSignature } from '@polkadot/types/interfaces/eth';
import type { BlockV0, BlockV1, BlockV2, EIP1559Transaction, EIP2930Transaction, EthAccessList, EthAccessListItem, EthAccount, EthAddress, EthBlock, EthBloom, EthCallRequest, EthFilter, EthFilterAddress, EthFilterChanges, EthFilterTopic, EthFilterTopicEntry, EthFilterTopicInner, EthHeader, EthLog, EthReceipt, EthRichBlock, EthRichHeader, EthStorageProof, EthSubKind, EthSubParams, EthSubResult, EthSyncInfo, EthSyncStatus, EthTransaction, EthTransactionAction, EthTransactionCondition, EthTransactionRequest, EthTransactionSignature, EthTransactionStatus, EthWork, EthereumAccountId, EthereumLookupSource, EthereumSignature, LegacyTransaction, TransactionV0, TransactionV1, TransactionV2 } from '@polkadot/types/interfaces/eth';
import type { EvmAccount, EvmLog, EvmVicinity, ExitError, ExitFatal, ExitReason, ExitRevert, ExitSucceed } from '@polkadot/types/interfaces/evm';
import type { AnySignature, EcdsaSignature, Ed25519Signature, Era, Extrinsic, ExtrinsicEra, ExtrinsicPayload, ExtrinsicPayloadUnknown, ExtrinsicPayloadV4, ExtrinsicSignature, ExtrinsicSignatureV4, ExtrinsicUnknown, ExtrinsicV4, ImmortalEra, MortalEra, MultiSignature, Signature, SignerPayload, Sr25519Signature } from '@polkadot/types/interfaces/extrinsics';
import type { AssetOptions, Owner, PermissionLatest, PermissionVersions, PermissionsV1 } from '@polkadot/types/interfaces/genericAsset';
@@ -155,6 +155,9 @@ declare module '@polkadot/types/types/registry' {
BlockTraceEvent: BlockTraceEvent;
BlockTraceEventData: BlockTraceEventData;
BlockTraceSpan: BlockTraceSpan;
BlockV0: BlockV0;
BlockV1: BlockV1;
BlockV2: BlockV2;
BlockWeights: BlockWeights;
BodyId: BodyId;
BodyPart: BodyPart;
@@ -293,6 +296,8 @@ declare module '@polkadot/types/types/registry' {
DownwardMessage: DownwardMessage;
EcdsaSignature: EcdsaSignature;
Ed25519Signature: Ed25519Signature;
EIP1559Transaction: EIP1559Transaction;
EIP2930Transaction: EIP2930Transaction;
ElectionCompute: ElectionCompute;
ElectionPhase: ElectionPhase;
ElectionResult: ElectionResult;
@@ -314,7 +319,10 @@ declare module '@polkadot/types/types/registry' {
ErrorMetadataV13: ErrorMetadataV13;
ErrorMetadataV14: ErrorMetadataV14;
ErrorMetadataV9: ErrorMetadataV9;
EthAccessList: EthAccessList;
EthAccessListItem: EthAccessListItem;
EthAccount: EthAccount;
EthAddress: EthAddress;
EthBlock: EthBlock;
EthBloom: EthBloom;
EthCallRequest: EthCallRequest;
@@ -522,6 +530,7 @@ declare module '@polkadot/types/types/registry' {
LastRuntimeUpgradeInfo: LastRuntimeUpgradeInfo;
LeasePeriod: LeasePeriod;
LeasePeriodOf: LeasePeriodOf;
LegacyTransaction: LegacyTransaction;
Limits: Limits;
LimitsTo264: LimitsTo264;
LocalValidationData: LocalValidationData;
@@ -951,6 +960,9 @@ declare module '@polkadot/types/types/registry' {
TransactionInfo: TransactionInfo;
TransactionPriority: TransactionPriority;
TransactionStorageProof: TransactionStorageProof;
TransactionV0: TransactionV0;
TransactionV1: TransactionV1;
TransactionV2: TransactionV2;
TransactionValidityError: TransactionValidityError;
TransientValidationData: TransientValidationData;
TreasuryProposal: TreasuryProposal;
+1
View File
@@ -27,6 +27,7 @@ describe('Option', (): void => {
expect(new Option(registry, Text, undefined).isNone).toBe(true);
expect(new Option(registry, Text, null).isNone).toBe(true);
expect(new Option(registry, Text, 'test').isNone).toBe(false);
expect(new Option(registry, Text, '0x').isNone).toBe(true);
});
it('converts an option to an option', (): void => {
+1 -1
View File
@@ -18,7 +18,7 @@ function decodeOptionU8a (registry: Registry, Type: Constructor, value: Uint8Arr
/** @internal */
function decodeOption (registry: Registry, typeName: Constructor | string, value?: unknown): Codec {
if (isNull(value) || isUndefined(value) || value instanceof Null) {
if (isNull(value) || isUndefined(value) || value instanceof Null || value === '0x') {
return new Null(registry);
}
+2 -2
View File
@@ -459,9 +459,9 @@ export class TypeRegistry implements Registry {
// setup the available extensions
this.setSignedExtensions(
signedExtensions || (
metadata.asLatest.extrinsic.version.gt(BN_ZERO)
this.#metadata.extrinsic.version.gt(BN_ZERO)
// FIXME Use the extension and their injected types
? metadata.asLatest.extrinsic.signedExtensions.map(({ identifier }) => identifier.toString())
? this.#metadata.extrinsic.signedExtensions.map(({ identifier }) => identifier.toString())
: fallbackExtensions
),
userExtensions
@@ -7,6 +7,7 @@ import type { Codec, ISignerPayload, Registry, SignerPayloadJSON, SignerPayloadR
import { u8aToHex } from '@polkadot/util';
import { Compact } from '../codec/Compact';
import { Option } from '../codec/Option';
import { Struct } from '../codec/Struct';
import { Vec } from '../codec/Vec';
import { Text } from '../primitive/Text';
@@ -120,7 +121,13 @@ export class GenericSignerPayload extends Struct implements ISignerPayload, Sign
return {
// add any explicit overrides we may have
...(Object.keys(this._extraTypes).reduce<Record<string, string>>((map, key) => {
map[key] = (this.get(key) as Codec).toHex();
const value = this.get(key) as Codec;
const isOption = value instanceof Option;
// Don't include Option.isNone
if (!isOption || value.isSome) {
map[key] = value.toHex();
}
return map;
}, {})),
+103 -28
View File
@@ -10,12 +10,94 @@ import type { DefinitionsTypes } from '../../types';
import { rpc } from './rpc';
const V0: DefinitionsTypes = {
BlockV0: {
header: 'EthHeader',
transactions: 'Vec<TransactionV0>',
ommers: 'Vec<EthHeader>'
},
LegacyTransaction: {
nonce: 'U256',
gasPrice: 'U256',
gasLimit: 'U256',
action: 'EthTransactionAction',
value: 'U256',
input: 'Bytes',
signature: 'EthTransactionSignature'
},
TransactionV0: 'LegacyTransaction'
};
const V1: DefinitionsTypes = {
BlockV1: {
header: 'EthHeader',
transactions: 'Vec<TransactionV1>',
ommers: 'Vec<EthHeader>'
},
EIP2930Transaction: {
chainId: 'u64',
nonce: 'U256',
gasPrice: 'U256',
gasLimit: 'U256',
action: 'EthTransactionAction',
value: 'U256',
input: 'Bytes',
accessList: 'EthAccessList',
oddYParity: 'bool',
r: 'H256',
s: 'H256'
},
TransactionV1: {
_enum: {
Legacy: 'LegacyTransaction',
EIP2930: 'EIP2930Transaction'
}
}
};
const V2: DefinitionsTypes = {
BlockV2: {
header: 'EthHeader',
transactions: 'Vec<TransactionV2>',
ommers: 'Vec<EthHeader>'
},
EIP1559Transaction: {
chainId: 'u64',
nonce: 'U256',
maxPriorityFeePerGas: 'U256',
maxFeePerGas: 'U256',
gasLimit: 'U256',
action: 'EthTransactionAction',
value: 'U256',
input: 'Bytes',
accessList: 'EthAccessList',
oddYParity: 'bool',
r: 'H256',
s: 'H256'
},
TransactionV2: {
_enum: {
Legacy: 'LegacyTransaction',
EIP2930: 'EIP2930Transaction',
EIP1559: 'EIP1559Transaction'
}
}
};
const types: DefinitionsTypes = {
...V0,
...V1,
...V2,
EthereumAccountId: 'GenericEthereumAccountId',
EthereumLookupSource: 'GenericEthereumLookupSource',
EthereumSignature: '[u8; 65]',
EthAccessListItem: {
address: 'EthAddress',
slots: 'Vec<H256>'
},
EthAccessList: 'Vec<EthAccessListItem>',
EthAccount: {
address: 'H160',
address: 'EthAddress',
balance: 'U256',
nonce: 'U256',
codeHash: 'H256',
@@ -23,6 +105,7 @@ const types: DefinitionsTypes = {
accountProof: 'Vec<Bytes>',
storageProof: 'Vec<EthStorageProof>'
},
EthAddress: 'H160',
EthBlock: {
header: 'EthHeader',
transactions: 'Vec<EthTransaction>',
@@ -31,7 +114,7 @@ const types: DefinitionsTypes = {
EthHeader: {
parentHash: 'H256',
ommersHash: 'H256',
beneficiary: 'H160',
beneficiary: 'EthAddress',
stateRoot: 'H256',
transactionsRoot: 'H256',
receiptsRoot: 'H256',
@@ -53,8 +136,8 @@ const types: DefinitionsTypes = {
blockHash: 'Option<H256>',
parentHash: 'H256',
sha3Uncles: 'H256',
author: 'H160',
miner: 'H160',
author: 'EthAddress',
miner: 'EthAddress',
stateRoot: 'H256',
transactionsRoot: 'H256',
receiptsRoot: 'H256',
@@ -73,8 +156,8 @@ const types: DefinitionsTypes = {
},
EthBloom: 'H2048',
EthCallRequest: {
from: 'Option<H160>',
to: 'Option<H160>',
from: 'Option<EthAddress>',
to: 'Option<EthAddress>',
gasPrice: 'Option<U256>',
gas: 'Option<U256>',
value: 'Option<U256>',
@@ -90,8 +173,8 @@ const types: DefinitionsTypes = {
},
EthFilterAddress: {
_enum: {
Single: 'H160',
Multiple: 'Vec<H160>',
Single: 'EthAddress',
Multiple: 'Vec<EthAddress>',
Null: 'Null'
}
},
@@ -125,8 +208,8 @@ const types: DefinitionsTypes = {
blockHash: 'Option<H256>',
parentHash: 'H256',
sha3Uncles: 'H256',
author: 'H160',
miner: 'H160',
author: 'EthAddress',
miner: 'EthAddress',
stateRoot: 'H256',
transactionsRoot: 'H256',
receiptsRoot: 'H256',
@@ -141,7 +224,7 @@ const types: DefinitionsTypes = {
blockSize: 'Option<U256>'
},
EthLog: {
address: 'H160',
address: 'EthAddress',
topics: 'Vec<H256>',
data: 'Bytes',
blockHash: 'Option<H256>',
@@ -156,12 +239,12 @@ const types: DefinitionsTypes = {
transactionHash: 'Option<H256>',
transactionIndex: 'Option<U256>',
blockHash: 'Option<H256>',
from: 'Option<H160>',
to: 'Option<H160>',
from: 'Option<EthAddress>',
to: 'Option<EthAddress>',
blockNumber: 'Option<U256>',
cumulativeGasUsed: 'U256',
gasUsed: 'Option<U256>',
contractAddress: 'Option<H160>',
contractAddress: 'Option<EthAddress>',
logs: 'Vec<EthLog>',
root: 'Option<H256>',
logsBloom: 'EthBloom',
@@ -202,15 +285,7 @@ const types: DefinitionsTypes = {
None: 'Null'
}
},
EthTransaction: {
nonce: 'U256',
gasPrice: 'U256',
gasLimit: 'U256',
action: 'EthTransactionAction',
value: 'U256',
input: 'Bytes',
signature: 'EthTransactionSignature'
},
EthTransaction: 'LegacyTransaction',
EthTransactionSignature: {
v: 'u64',
r: 'H256',
@@ -229,8 +304,8 @@ const types: DefinitionsTypes = {
}
},
EthTransactionRequest: {
from: 'Option<H160>',
to: 'Option<H160>',
from: 'Option<EthAddress>',
to: 'Option<EthAddress>',
gasPrice: 'Option<U256>',
gas: 'Option<U256>',
value: 'Option<U256>',
@@ -240,9 +315,9 @@ const types: DefinitionsTypes = {
EthTransactionStatus: {
transactionHash: 'H256',
transactionIndex: 'u32',
from: 'H160',
to: 'Option<H160>',
contractAddress: 'Option<H160>',
from: 'EthAddress',
to: 'Option<EthAddress>',
contractAddress: 'Option<EthAddress>',
logs: 'Vec<EthLog>',
logsBloom: 'EthBloom'
},
+116 -28
View File
@@ -4,9 +4,70 @@
import type { Bytes, Enum, GenericEthereumAccountId, GenericEthereumLookupSource, Option, Struct, U256, U64, U8aFixed, Vec, bool, u32, u64 } from '@polkadot/types';
import type { BlockNumber, H160, H2048, H256, H64 } from '@polkadot/types/interfaces/runtime';
/** @name BlockV0 */
export interface BlockV0 extends Struct {
readonly header: EthHeader;
readonly transactions: Vec<TransactionV0>;
readonly ommers: Vec<EthHeader>;
}
/** @name BlockV1 */
export interface BlockV1 extends Struct {
readonly header: EthHeader;
readonly transactions: Vec<TransactionV1>;
readonly ommers: Vec<EthHeader>;
}
/** @name BlockV2 */
export interface BlockV2 extends Struct {
readonly header: EthHeader;
readonly transactions: Vec<TransactionV2>;
readonly ommers: Vec<EthHeader>;
}
/** @name EIP1559Transaction */
export interface EIP1559Transaction extends Struct {
readonly chainId: u64;
readonly nonce: U256;
readonly maxPriorityFeePerGas: U256;
readonly maxFeePerGas: U256;
readonly gasLimit: U256;
readonly action: EthTransactionAction;
readonly value: U256;
readonly input: Bytes;
readonly accessList: EthAccessList;
readonly oddYParity: bool;
readonly r: H256;
readonly s: H256;
}
/** @name EIP2930Transaction */
export interface EIP2930Transaction extends Struct {
readonly chainId: u64;
readonly nonce: U256;
readonly gasPrice: U256;
readonly gasLimit: U256;
readonly action: EthTransactionAction;
readonly value: U256;
readonly input: Bytes;
readonly accessList: EthAccessList;
readonly oddYParity: bool;
readonly r: H256;
readonly s: H256;
}
/** @name EthAccessList */
export interface EthAccessList extends Vec<EthAccessListItem> {}
/** @name EthAccessListItem */
export interface EthAccessListItem extends Struct {
readonly address: EthAddress;
readonly slots: Vec<H256>;
}
/** @name EthAccount */
export interface EthAccount extends Struct {
readonly address: H160;
readonly address: EthAddress;
readonly balance: U256;
readonly nonce: U256;
readonly codeHash: H256;
@@ -15,6 +76,9 @@ export interface EthAccount extends Struct {
readonly storageProof: Vec<EthStorageProof>;
}
/** @name EthAddress */
export interface EthAddress extends H160 {}
/** @name EthBlock */
export interface EthBlock extends Struct {
readonly header: EthHeader;
@@ -27,8 +91,8 @@ export interface EthBloom extends H2048 {}
/** @name EthCallRequest */
export interface EthCallRequest extends Struct {
readonly from: Option<H160>;
readonly to: Option<H160>;
readonly from: Option<EthAddress>;
readonly to: Option<EthAddress>;
readonly gasPrice: Option<U256>;
readonly gas: Option<U256>;
readonly value: Option<U256>;
@@ -57,9 +121,9 @@ export interface EthFilter extends Struct {
/** @name EthFilterAddress */
export interface EthFilterAddress extends Enum {
readonly isSingle: boolean;
readonly asSingle: H160;
readonly asSingle: EthAddress;
readonly isMultiple: boolean;
readonly asMultiple: Vec<H160>;
readonly asMultiple: Vec<EthAddress>;
readonly isNull: boolean;
}
@@ -97,7 +161,7 @@ export interface EthFilterTopicInner extends Enum {
export interface EthHeader extends Struct {
readonly parentHash: H256;
readonly ommersHash: H256;
readonly beneficiary: H160;
readonly beneficiary: EthAddress;
readonly stateRoot: H256;
readonly transactionsRoot: H256;
readonly receiptsRoot: H256;
@@ -114,7 +178,7 @@ export interface EthHeader extends Struct {
/** @name EthLog */
export interface EthLog extends Struct {
readonly address: H160;
readonly address: EthAddress;
readonly topics: Vec<H256>;
readonly data: Bytes;
readonly blockHash: Option<H256>;
@@ -131,12 +195,12 @@ export interface EthReceipt extends Struct {
readonly transactionHash: Option<H256>;
readonly transactionIndex: Option<U256>;
readonly blockHash: Option<H256>;
readonly from: Option<H160>;
readonly to: Option<H160>;
readonly from: Option<EthAddress>;
readonly to: Option<EthAddress>;
readonly blockNumber: Option<U256>;
readonly cumulativeGasUsed: U256;
readonly gasUsed: Option<U256>;
readonly contractAddress: Option<H160>;
readonly contractAddress: Option<EthAddress>;
readonly logs: Vec<EthLog>;
readonly root: Option<H256>;
readonly logsBloom: EthBloom;
@@ -148,8 +212,8 @@ export interface EthRichBlock extends Struct {
readonly blockHash: Option<H256>;
readonly parentHash: H256;
readonly sha3Uncles: H256;
readonly author: H160;
readonly miner: H160;
readonly author: EthAddress;
readonly miner: EthAddress;
readonly stateRoot: H256;
readonly transactionsRoot: H256;
readonly receiptsRoot: H256;
@@ -172,8 +236,8 @@ export interface EthRichHeader extends Struct {
readonly blockHash: Option<H256>;
readonly parentHash: H256;
readonly sha3Uncles: H256;
readonly author: H160;
readonly miner: H160;
readonly author: EthAddress;
readonly miner: EthAddress;
readonly stateRoot: H256;
readonly transactionsRoot: H256;
readonly receiptsRoot: H256;
@@ -239,15 +303,7 @@ export interface EthSyncStatus extends Enum {
}
/** @name EthTransaction */
export interface EthTransaction extends Struct {
readonly nonce: U256;
readonly gasPrice: U256;
readonly gasLimit: U256;
readonly action: EthTransactionAction;
readonly value: U256;
readonly input: Bytes;
readonly signature: EthTransactionSignature;
}
export interface EthTransaction extends LegacyTransaction {}
/** @name EthTransactionAction */
export interface EthTransactionAction extends Enum {
@@ -266,8 +322,8 @@ export interface EthTransactionCondition extends Enum {
/** @name EthTransactionRequest */
export interface EthTransactionRequest extends Struct {
readonly from: Option<H160>;
readonly to: Option<H160>;
readonly from: Option<EthAddress>;
readonly to: Option<EthAddress>;
readonly gasPrice: Option<U256>;
readonly gas: Option<U256>;
readonly value: Option<U256>;
@@ -286,9 +342,9 @@ export interface EthTransactionSignature extends Struct {
export interface EthTransactionStatus extends Struct {
readonly transactionHash: H256;
readonly transactionIndex: u32;
readonly from: H160;
readonly to: Option<H160>;
readonly contractAddress: Option<H160>;
readonly from: EthAddress;
readonly to: Option<EthAddress>;
readonly contractAddress: Option<EthAddress>;
readonly logs: Vec<EthLog>;
readonly logsBloom: EthBloom;
}
@@ -301,4 +357,36 @@ export interface EthWork extends Struct {
readonly number: Option<u64>;
}
/** @name LegacyTransaction */
export interface LegacyTransaction extends Struct {
readonly nonce: U256;
readonly gasPrice: U256;
readonly gasLimit: U256;
readonly action: EthTransactionAction;
readonly value: U256;
readonly input: Bytes;
readonly signature: EthTransactionSignature;
}
/** @name TransactionV0 */
export interface TransactionV0 extends LegacyTransaction {}
/** @name TransactionV1 */
export interface TransactionV1 extends Enum {
readonly isLegacy: boolean;
readonly asLegacy: LegacyTransaction;
readonly isEip2930: boolean;
readonly asEip2930: EIP2930Transaction;
}
/** @name TransactionV2 */
export interface TransactionV2 extends Enum {
readonly isLegacy: boolean;
readonly asLegacy: LegacyTransaction;
readonly isEip2930: boolean;
readonly asEip2930: EIP2930Transaction;
readonly isEip1559: boolean;
readonly asEip1559: EIP1559Transaction;
}
export type PHANTOM_ETH = 'eth';
+25 -2
View File
@@ -125,16 +125,39 @@ export function defaultValues (registry: Registry, { data, fails = [] }: Check,
});
}
function serialize (registry: Registry, { data }: Check): void {
const metadata = new Metadata(registry, data);
it('serializes to hex in the same form as retrieved', (): void => {
expect(metadata.toHex()).toEqual(data);
});
// NOTE Assuming the first passes this is actually something that doesn't test
// anything new. If the first line in this function passed and the above values
// are equivalent, this would be as well.
it.skip('can construct from a re-serialized form', (): void => {
expect(
() => new Metadata(registry, metadata.toHex())
).not.toThrow();
});
// as used in the extension
it('can construct from asCallsOnly.toHex()', (): void => {
expect(
() => new Metadata(registry, metadata.asCallsOnly.toHex())
).not.toThrow();
});
}
export function testMeta (version: number, matchers: Record<string, Check>, withFallback = true): void {
describe(`MetadataV${version}`, (): void => {
describe.each(Object.keys(matchers))('%s', (type): void => {
const matcher = matchers[type];
const registry = new TypeRegistry();
serialize(registry, matcher);
decodeLatestMeta(registry, type, version, matcher);
toLatest(registry, version, matcher);
defaultValues(registry, matcher, true, withFallback);
});
});
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/types', version: '6.4.1' };
export const packageInfo = { name: '@polkadot/types', version: '6.4.2' };
+27 -27
View File
@@ -1833,40 +1833,40 @@ __metadata:
resolution: "@polkadot/api-contract@workspace:packages/api-contract"
dependencies:
"@babel/runtime": ^7.15.4
"@polkadot/api": 6.4.1
"@polkadot/types": 6.4.1
"@polkadot/api": 6.4.2
"@polkadot/types": 6.4.2
"@polkadot/util": ^7.5.1
rxjs: ^7.4.0
languageName: unknown
linkType: soft
"@polkadot/api-derive@6.4.1, @polkadot/api-derive@workspace:packages/api-derive":
"@polkadot/api-derive@6.4.2, @polkadot/api-derive@workspace:packages/api-derive":
version: 0.0.0-use.local
resolution: "@polkadot/api-derive@workspace:packages/api-derive"
dependencies:
"@babel/runtime": ^7.15.4
"@polkadot/api": 6.4.1
"@polkadot/api": 6.4.2
"@polkadot/keyring": ^7.5.1
"@polkadot/rpc-core": 6.4.1
"@polkadot/rpc-provider": 6.4.1
"@polkadot/types": 6.4.1
"@polkadot/rpc-core": 6.4.2
"@polkadot/rpc-provider": 6.4.2
"@polkadot/types": 6.4.2
"@polkadot/util": ^7.5.1
"@polkadot/util-crypto": ^7.5.1
rxjs: ^7.4.0
languageName: unknown
linkType: soft
"@polkadot/api@6.4.1, @polkadot/api@workspace:packages/api":
"@polkadot/api@6.4.2, @polkadot/api@workspace:packages/api":
version: 0.0.0-use.local
resolution: "@polkadot/api@workspace:packages/api"
dependencies:
"@babel/runtime": ^7.15.4
"@polkadot/api-derive": 6.4.1
"@polkadot/api-derive": 6.4.2
"@polkadot/keyring": ^7.5.1
"@polkadot/rpc-core": 6.4.1
"@polkadot/rpc-provider": 6.4.1
"@polkadot/types": 6.4.1
"@polkadot/types-known": 6.4.1
"@polkadot/rpc-core": 6.4.2
"@polkadot/rpc-provider": 6.4.2
"@polkadot/types": 6.4.2
"@polkadot/types-known": 6.4.2
"@polkadot/util": ^7.5.1
"@polkadot/util-crypto": ^7.5.1
eventemitter3: ^4.0.7
@@ -1991,26 +1991,26 @@ __metadata:
languageName: node
linkType: hard
"@polkadot/rpc-core@6.4.1, @polkadot/rpc-core@workspace:packages/rpc-core":
"@polkadot/rpc-core@6.4.2, @polkadot/rpc-core@workspace:packages/rpc-core":
version: 0.0.0-use.local
resolution: "@polkadot/rpc-core@workspace:packages/rpc-core"
dependencies:
"@babel/runtime": ^7.15.4
"@polkadot/keyring": ^7.5.1
"@polkadot/rpc-provider": 6.4.1
"@polkadot/types": 6.4.1
"@polkadot/rpc-provider": 6.4.2
"@polkadot/types": 6.4.2
"@polkadot/util": ^7.5.1
rxjs: ^7.4.0
languageName: unknown
linkType: soft
"@polkadot/rpc-provider@6.4.1, @polkadot/rpc-provider@workspace:packages/rpc-provider":
"@polkadot/rpc-provider@6.4.2, @polkadot/rpc-provider@workspace:packages/rpc-provider":
version: 0.0.0-use.local
resolution: "@polkadot/rpc-provider@workspace:packages/rpc-provider"
dependencies:
"@babel/runtime": ^7.15.4
"@polkadot/keyring": ^7.5.1
"@polkadot/types": 6.4.1
"@polkadot/types": 6.4.2
"@polkadot/util": ^7.5.1
"@polkadot/util-crypto": ^7.5.1
"@polkadot/x-fetch": ^7.5.1
@@ -2038,10 +2038,10 @@ __metadata:
"@babel/core": ^7.15.8
"@babel/register": ^7.15.3
"@babel/runtime": ^7.15.4
"@polkadot/api": 6.4.1
"@polkadot/rpc-provider": 6.4.1
"@polkadot/types": 6.4.1
"@polkadot/types-support": 6.4.1
"@polkadot/api": 6.4.2
"@polkadot/rpc-provider": 6.4.2
"@polkadot/types": 6.4.2
"@polkadot/types-support": 6.4.2
"@polkadot/util": ^7.5.1
"@types/websocket": ^1.0.4
"@types/yargs": ^17.0.4
@@ -2057,18 +2057,18 @@ __metadata:
languageName: unknown
linkType: soft
"@polkadot/types-known@6.4.1, @polkadot/types-known@workspace:packages/types-known":
"@polkadot/types-known@6.4.2, @polkadot/types-known@workspace:packages/types-known":
version: 0.0.0-use.local
resolution: "@polkadot/types-known@workspace:packages/types-known"
dependencies:
"@babel/runtime": ^7.15.4
"@polkadot/networks": ^7.5.1
"@polkadot/types": 6.4.1
"@polkadot/types": 6.4.2
"@polkadot/util": ^7.5.1
languageName: unknown
linkType: soft
"@polkadot/types-support@6.4.1, @polkadot/types-support@workspace:packages/types-support":
"@polkadot/types-support@6.4.2, @polkadot/types-support@workspace:packages/types-support":
version: 0.0.0-use.local
resolution: "@polkadot/types-support@workspace:packages/types-support"
dependencies:
@@ -2077,13 +2077,13 @@ __metadata:
languageName: unknown
linkType: soft
"@polkadot/types@6.4.1, @polkadot/types@workspace:packages/types":
"@polkadot/types@6.4.2, @polkadot/types@workspace:packages/types":
version: 0.0.0-use.local
resolution: "@polkadot/types@workspace:packages/types"
dependencies:
"@babel/runtime": ^7.15.4
"@polkadot/keyring": ^7.5.1
"@polkadot/types-support": 6.4.1
"@polkadot/types-support": 6.4.2
"@polkadot/util": ^7.5.1
"@polkadot/util-crypto": ^7.5.1
"@types/bn.js": ^4.11.6