diff --git a/.changeset/quick-tips-happen.md b/.changeset/quick-tips-happen.md new file mode 100644 index 000000000..ba80c94b7 --- /dev/null +++ b/.changeset/quick-tips-happen.md @@ -0,0 +1,6 @@ +--- +"@celo/connect": minor +"@celo/wallet-base": minor +--- + +Add support Type 0 Ethereum-compatible legacy TXs diff --git a/packages/docs/sdk/docs/connect/interfaces/types.EncodedTransaction.md b/packages/docs/sdk/docs/connect/interfaces/types.EncodedTransaction.md index 6a937aded..65ff818a9 100644 --- a/packages/docs/sdk/docs/connect/interfaces/types.EncodedTransaction.md +++ b/packages/docs/sdk/docs/connect/interfaces/types.EncodedTransaction.md @@ -19,14 +19,14 @@ #### Defined in -[packages/sdk/connect/src/types.ts:118](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/connect/src/types.ts#L118) +[packages/sdk/connect/src/types.ts:123](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/connect/src/types.ts#L123) ___ ### tx -• **tx**: [`EIP1559TXProperties`](types.EIP1559TXProperties.md) \| [`CIP64TXProperties`](types.CIP64TXProperties.md) \| [`CIP42TXProperties`](types.CIP42TXProperties.md) \| [`LegacyTXProperties`](types.LegacyTXProperties.md) +• **tx**: [`EIP1559TXProperties`](types.EIP1559TXProperties.md) \| [`CIP64TXProperties`](types.CIP64TXProperties.md) \| [`CIP42TXProperties`](types.CIP42TXProperties.md) \| [`LegacyTXProperties`](types.LegacyTXProperties.md) \| [`EthereumLegacyTXProperties`](types.EthereumLegacyTXProperties.md) #### Defined in -[packages/sdk/connect/src/types.ts:119](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/connect/src/types.ts#L119) +[packages/sdk/connect/src/types.ts:124](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/connect/src/types.ts#L124) diff --git a/packages/docs/sdk/docs/connect/interfaces/types.Error.md b/packages/docs/sdk/docs/connect/interfaces/types.Error.md index 8261af374..f102652fe 100644 --- a/packages/docs/sdk/docs/connect/interfaces/types.Error.md +++ b/packages/docs/sdk/docs/connect/interfaces/types.Error.md @@ -20,7 +20,7 @@ #### Defined in -[packages/sdk/connect/src/types.ts:153](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/connect/src/types.ts#L153) +[packages/sdk/connect/src/types.ts:163](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/connect/src/types.ts#L163) ___ @@ -30,7 +30,7 @@ ___ #### Defined in -[packages/sdk/connect/src/types.ts:154](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/connect/src/types.ts#L154) +[packages/sdk/connect/src/types.ts:164](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/connect/src/types.ts#L164) ___ @@ -40,4 +40,4 @@ ___ #### Defined in -[packages/sdk/connect/src/types.ts:155](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/connect/src/types.ts#L155) +[packages/sdk/connect/src/types.ts:165](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/connect/src/types.ts#L165) diff --git a/packages/docs/sdk/docs/connect/interfaces/types.EthereumLegacyTXProperties.md b/packages/docs/sdk/docs/connect/interfaces/types.EthereumLegacyTXProperties.md new file mode 100644 index 000000000..59888e8e6 --- /dev/null +++ b/packages/docs/sdk/docs/connect/interfaces/types.EthereumLegacyTXProperties.md @@ -0,0 +1,177 @@ +[@celo/connect](../README.md) / [Exports](../modules.md) / [types](../modules/types.md) / EthereumLegacyTXProperties + +# Interface: EthereumLegacyTXProperties + +[types](../modules/types.md).EthereumLegacyTXProperties + +## Hierarchy + +- `CommonTXProperties` + + ↳ **`EthereumLegacyTXProperties`** + +## Table of contents + +### Properties + +- [gas](types.EthereumLegacyTXProperties.md#gas) +- [gasPrice](types.EthereumLegacyTXProperties.md#gasprice) +- [hash](types.EthereumLegacyTXProperties.md#hash) +- [input](types.EthereumLegacyTXProperties.md#input) +- [nonce](types.EthereumLegacyTXProperties.md#nonce) +- [r](types.EthereumLegacyTXProperties.md#r) +- [s](types.EthereumLegacyTXProperties.md#s) +- [to](types.EthereumLegacyTXProperties.md#to) +- [type](types.EthereumLegacyTXProperties.md#type) +- [v](types.EthereumLegacyTXProperties.md#v) +- [value](types.EthereumLegacyTXProperties.md#value) + +## Properties + +### gas + +• **gas**: `string` + +#### Inherited from + +CommonTXProperties.gas + +#### Defined in + +[packages/sdk/connect/src/types.ts:73](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/connect/src/types.ts#L73) + +___ + +### gasPrice + +• **gasPrice**: `string` + +#### Defined in + +[packages/sdk/connect/src/types.ts:118](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/connect/src/types.ts#L118) + +___ + +### hash + +• **hash**: `string` + +#### Inherited from + +CommonTXProperties.hash + +#### Defined in + +[packages/sdk/connect/src/types.ts:80](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/connect/src/types.ts#L80) + +___ + +### input + +• **input**: `string` + +#### Inherited from + +CommonTXProperties.input + +#### Defined in + +[packages/sdk/connect/src/types.ts:76](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/connect/src/types.ts#L76) + +___ + +### nonce + +• **nonce**: `string` + +#### Inherited from + +CommonTXProperties.nonce + +#### Defined in + +[packages/sdk/connect/src/types.ts:72](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/connect/src/types.ts#L72) + +___ + +### r + +• **r**: `string` + +#### Inherited from + +CommonTXProperties.r + +#### Defined in + +[packages/sdk/connect/src/types.ts:77](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/connect/src/types.ts#L77) + +___ + +### s + +• **s**: `string` + +#### Inherited from + +CommonTXProperties.s + +#### Defined in + +[packages/sdk/connect/src/types.ts:78](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/connect/src/types.ts#L78) + +___ + +### to + +• **to**: `string` + +#### Inherited from + +CommonTXProperties.to + +#### Defined in + +[packages/sdk/connect/src/types.ts:74](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/connect/src/types.ts#L74) + +___ + +### type + +• **type**: ``"ethereum-legacy"`` + +#### Overrides + +CommonTXProperties.type + +#### Defined in + +[packages/sdk/connect/src/types.ts:119](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/connect/src/types.ts#L119) + +___ + +### v + +• **v**: `string` + +#### Inherited from + +CommonTXProperties.v + +#### Defined in + +[packages/sdk/connect/src/types.ts:79](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/connect/src/types.ts#L79) + +___ + +### value + +• **value**: `string` + +#### Inherited from + +CommonTXProperties.value + +#### Defined in + +[packages/sdk/connect/src/types.ts:75](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/connect/src/types.ts#L75) diff --git a/packages/docs/sdk/docs/connect/interfaces/types.HttpProvider.md b/packages/docs/sdk/docs/connect/interfaces/types.HttpProvider.md index 02e6089c3..f86143f67 100644 --- a/packages/docs/sdk/docs/connect/interfaces/types.HttpProvider.md +++ b/packages/docs/sdk/docs/connect/interfaces/types.HttpProvider.md @@ -29,4 +29,4 @@ #### Defined in -[packages/sdk/connect/src/types.ts:159](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/connect/src/types.ts#L159) +[packages/sdk/connect/src/types.ts:169](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/connect/src/types.ts#L169) diff --git a/packages/docs/sdk/docs/connect/interfaces/types.JsonRpcPayload.md b/packages/docs/sdk/docs/connect/interfaces/types.JsonRpcPayload.md index 1300c1607..9a24e5599 100644 --- a/packages/docs/sdk/docs/connect/interfaces/types.JsonRpcPayload.md +++ b/packages/docs/sdk/docs/connect/interfaces/types.JsonRpcPayload.md @@ -21,7 +21,7 @@ #### Defined in -[packages/sdk/connect/src/types.ts:142](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/connect/src/types.ts#L142) +[packages/sdk/connect/src/types.ts:152](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/connect/src/types.ts#L152) ___ @@ -31,7 +31,7 @@ ___ #### Defined in -[packages/sdk/connect/src/types.ts:139](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/connect/src/types.ts#L139) +[packages/sdk/connect/src/types.ts:149](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/connect/src/types.ts#L149) ___ @@ -41,7 +41,7 @@ ___ #### Defined in -[packages/sdk/connect/src/types.ts:140](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/connect/src/types.ts#L140) +[packages/sdk/connect/src/types.ts:150](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/connect/src/types.ts#L150) ___ @@ -51,4 +51,4 @@ ___ #### Defined in -[packages/sdk/connect/src/types.ts:141](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/connect/src/types.ts#L141) +[packages/sdk/connect/src/types.ts:151](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/connect/src/types.ts#L151) diff --git a/packages/docs/sdk/docs/connect/interfaces/types.JsonRpcResponse.md b/packages/docs/sdk/docs/connect/interfaces/types.JsonRpcResponse.md index c9239e0f2..652c409f9 100644 --- a/packages/docs/sdk/docs/connect/interfaces/types.JsonRpcResponse.md +++ b/packages/docs/sdk/docs/connect/interfaces/types.JsonRpcResponse.md @@ -29,7 +29,7 @@ #### Defined in -[packages/sdk/connect/src/types.ts:131](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/connect/src/types.ts#L131) +[packages/sdk/connect/src/types.ts:141](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/connect/src/types.ts#L141) ___ @@ -39,7 +39,7 @@ ___ #### Defined in -[packages/sdk/connect/src/types.ts:129](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/connect/src/types.ts#L129) +[packages/sdk/connect/src/types.ts:139](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/connect/src/types.ts#L139) ___ @@ -49,7 +49,7 @@ ___ #### Defined in -[packages/sdk/connect/src/types.ts:128](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/connect/src/types.ts#L128) +[packages/sdk/connect/src/types.ts:138](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/connect/src/types.ts#L138) ___ @@ -59,4 +59,4 @@ ___ #### Defined in -[packages/sdk/connect/src/types.ts:130](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/connect/src/types.ts#L130) +[packages/sdk/connect/src/types.ts:140](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/connect/src/types.ts#L140) diff --git a/packages/docs/sdk/docs/connect/interfaces/types.Provider.md b/packages/docs/sdk/docs/connect/interfaces/types.Provider.md index d6c741b42..3180d38c8 100644 --- a/packages/docs/sdk/docs/connect/interfaces/types.Provider.md +++ b/packages/docs/sdk/docs/connect/interfaces/types.Provider.md @@ -33,4 +33,4 @@ #### Defined in -[packages/sdk/connect/src/types.ts:146](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/connect/src/types.ts#L146) +[packages/sdk/connect/src/types.ts:156](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/connect/src/types.ts#L156) diff --git a/packages/docs/sdk/docs/connect/interfaces/types.RLPEncodedTx.md b/packages/docs/sdk/docs/connect/interfaces/types.RLPEncodedTx.md index 2ca2d140e..cff733224 100644 --- a/packages/docs/sdk/docs/connect/interfaces/types.RLPEncodedTx.md +++ b/packages/docs/sdk/docs/connect/interfaces/types.RLPEncodedTx.md @@ -20,7 +20,7 @@ #### Defined in -[packages/sdk/connect/src/types.ts:167](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/connect/src/types.ts#L167) +[packages/sdk/connect/src/types.ts:177](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/connect/src/types.ts#L177) ___ @@ -30,7 +30,7 @@ ___ #### Defined in -[packages/sdk/connect/src/types.ts:166](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/connect/src/types.ts#L166) +[packages/sdk/connect/src/types.ts:176](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/connect/src/types.ts#L176) ___ @@ -40,4 +40,4 @@ ___ #### Defined in -[packages/sdk/connect/src/types.ts:168](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/connect/src/types.ts#L168) +[packages/sdk/connect/src/types.ts:178](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/connect/src/types.ts#L178) diff --git a/packages/docs/sdk/docs/connect/modules/index.md b/packages/docs/sdk/docs/connect/modules/index.md index 2929d52d4..2fd441869 100644 --- a/packages/docs/sdk/docs/connect/modules/index.md +++ b/packages/docs/sdk/docs/connect/modules/index.md @@ -32,6 +32,7 @@ - [EIP1559TXProperties](index.md#eip1559txproperties) - [EncodedTransaction](index.md#encodedtransaction) - [Error](index.md#error) +- [EthereumLegacyTXProperties](index.md#ethereumlegacytxproperties) - [FormattedCeloTx](index.md#formattedcelotx) - [Hex](index.md#hex) - [HexOrMissing](index.md#hexormissing) @@ -235,6 +236,12 @@ Re-exports [Error](../interfaces/types.Error.md) ___ +### EthereumLegacyTXProperties + +Re-exports [EthereumLegacyTXProperties](../interfaces/types.EthereumLegacyTXProperties.md) + +___ + ### FormattedCeloTx Re-exports [FormattedCeloTx](../interfaces/types.FormattedCeloTx.md) diff --git a/packages/docs/sdk/docs/connect/modules/types.md b/packages/docs/sdk/docs/connect/modules/types.md index db0109746..6341015d1 100644 --- a/packages/docs/sdk/docs/connect/modules/types.md +++ b/packages/docs/sdk/docs/connect/modules/types.md @@ -27,6 +27,7 @@ - [EIP1559TXProperties](../interfaces/types.EIP1559TXProperties.md) - [EncodedTransaction](../interfaces/types.EncodedTransaction.md) - [Error](../interfaces/types.Error.md) +- [EthereumLegacyTXProperties](../interfaces/types.EthereumLegacyTXProperties.md) - [FormattedCeloTx](../interfaces/types.FormattedCeloTx.md) - [HttpProvider](../interfaces/types.HttpProvider.md) - [JsonRpcPayload](../interfaces/types.JsonRpcPayload.md) @@ -163,7 +164,7 @@ ___ #### Defined in -[packages/sdk/connect/src/types.ts:125](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/connect/src/types.ts#L125) +[packages/sdk/connect/src/types.ts:135](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/connect/src/types.ts#L135) ___ @@ -183,7 +184,7 @@ ___ #### Defined in -[packages/sdk/connect/src/types.ts:122](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/connect/src/types.ts#L122) +[packages/sdk/connect/src/types.ts:132](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/connect/src/types.ts#L132) ___ @@ -193,7 +194,7 @@ ___ #### Defined in -[packages/sdk/connect/src/types.ts:123](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/connect/src/types.ts#L123) +[packages/sdk/connect/src/types.ts:133](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/connect/src/types.ts#L133) ___ @@ -229,7 +230,7 @@ ___ ### TransactionTypes -Ƭ **TransactionTypes**: ``"eip1559"`` \| ``"celo-legacy"`` \| ``"cip42"`` \| ``"cip64"`` +Ƭ **TransactionTypes**: ``"ethereum-legacy"`` \| ``"eip1559"`` \| ``"celo-legacy"`` \| ``"cip42"`` \| ``"cip64"`` #### Defined in diff --git a/packages/docs/sdk/docs/wallet-base/classes/wallet_base.WalletBase.md b/packages/docs/sdk/docs/wallet-base/classes/wallet_base.WalletBase.md index 2088fb3b9..ad304a930 100644 --- a/packages/docs/sdk/docs/wallet-base/classes/wallet_base.WalletBase.md +++ b/packages/docs/sdk/docs/wallet-base/classes/wallet_base.WalletBase.md @@ -72,7 +72,7 @@ ReadOnlyWallet.computeSharedSecret #### Defined in -[wallets/wallet-base/src/wallet-base.ts:141](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/wallets/wallet-base/src/wallet-base.ts#L141) +[wallets/wallet-base/src/wallet-base.ts:143](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/wallets/wallet-base/src/wallet-base.ts#L143) ___ @@ -97,7 +97,7 @@ ReadOnlyWallet.decrypt #### Defined in -[wallets/wallet-base/src/wallet-base.ts:133](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/wallets/wallet-base/src/wallet-base.ts#L133) +[wallets/wallet-base/src/wallet-base.ts:135](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/wallets/wallet-base/src/wallet-base.ts#L135) ___ @@ -198,7 +198,7 @@ ReadOnlyWallet.signPersonalMessage #### Defined in -[wallets/wallet-base/src/wallet-base.ts:97](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/wallets/wallet-base/src/wallet-base.ts#L97) +[wallets/wallet-base/src/wallet-base.ts:99](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/wallets/wallet-base/src/wallet-base.ts#L99) ___ @@ -253,4 +253,4 @@ ReadOnlyWallet.signTypedData #### Defined in -[wallets/wallet-base/src/wallet-base.ts:114](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/wallets/wallet-base/src/wallet-base.ts#L114) +[wallets/wallet-base/src/wallet-base.ts:116](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/wallets/wallet-base/src/wallet-base.ts#L116) diff --git a/packages/docs/sdk/docs/wallet-base/modules/signing_utils.md b/packages/docs/sdk/docs/wallet-base/modules/signing_utils.md index 79e6817ab..d1d08af50 100644 --- a/packages/docs/sdk/docs/wallet-base/modules/signing_utils.md +++ b/packages/docs/sdk/docs/wallet-base/modules/signing_utils.md @@ -100,7 +100,7 @@ ___ #### Defined in -[wallets/wallet-base/src/signing-utils.ts:697](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/wallets/wallet-base/src/signing-utils.ts#L697) +[wallets/wallet-base/src/signing-utils.ts:774](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/wallets/wallet-base/src/signing-utils.ts#L774) ___ @@ -124,7 +124,7 @@ ___ #### Defined in -[wallets/wallet-base/src/signing-utils.ts:322](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/wallets/wallet-base/src/signing-utils.ts#L322) +[wallets/wallet-base/src/signing-utils.ts:348](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/wallets/wallet-base/src/signing-utils.ts#L348) ___ @@ -150,7 +150,7 @@ ___ #### Defined in -[wallets/wallet-base/src/signing-utils.ts:405](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/wallets/wallet-base/src/signing-utils.ts#L405) +[wallets/wallet-base/src/signing-utils.ts:445](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/wallets/wallet-base/src/signing-utils.ts#L445) ___ @@ -190,7 +190,7 @@ ___ #### Defined in -[wallets/wallet-base/src/signing-utils.ts:500](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/wallets/wallet-base/src/signing-utils.ts#L500) +[wallets/wallet-base/src/signing-utils.ts:518](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/wallets/wallet-base/src/signing-utils.ts#L518) ___ @@ -210,7 +210,7 @@ ___ #### Defined in -[wallets/wallet-base/src/signing-utils.ts:271](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/wallets/wallet-base/src/signing-utils.ts#L271) +[wallets/wallet-base/src/signing-utils.ts:290](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/wallets/wallet-base/src/signing-utils.ts#L290) ___ @@ -231,7 +231,7 @@ ___ #### Defined in -[wallets/wallet-base/src/signing-utils.ts:665](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/wallets/wallet-base/src/signing-utils.ts#L665) +[wallets/wallet-base/src/signing-utils.ts:742](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/wallets/wallet-base/src/signing-utils.ts#L742) ___ @@ -251,7 +251,7 @@ ___ #### Defined in -[wallets/wallet-base/src/signing-utils.ts:439](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/wallets/wallet-base/src/signing-utils.ts#L439) +[wallets/wallet-base/src/signing-utils.ts:479](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/wallets/wallet-base/src/signing-utils.ts#L479) ___ @@ -313,7 +313,7 @@ ___ #### Defined in -[wallets/wallet-base/src/signing-utils.ts:675](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/wallets/wallet-base/src/signing-utils.ts#L675) +[wallets/wallet-base/src/signing-utils.ts:752](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/wallets/wallet-base/src/signing-utils.ts#L752) ___ @@ -335,4 +335,4 @@ ___ #### Defined in -[wallets/wallet-base/src/signing-utils.ts:684](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/wallets/wallet-base/src/signing-utils.ts#L684) +[wallets/wallet-base/src/signing-utils.ts:761](https://github.com/celo-org/developer-tooling/blob/master/packages/sdk/wallets/wallet-base/src/signing-utils.ts#L761) diff --git a/packages/sdk/connect/src/types.ts b/packages/sdk/connect/src/types.ts index 5594c3a86..34bbdc098 100644 --- a/packages/sdk/connect/src/types.ts +++ b/packages/sdk/connect/src/types.ts @@ -66,7 +66,7 @@ export { BlockNumber, EventLog, Log, PromiEvent, Sign } from 'web3-core' export { Block, BlockHeader, Syncing } from 'web3-eth' export { Contract, ContractSendMethod, PastEventOptions } from 'web3-eth-contract' -export type TransactionTypes = 'eip1559' | 'celo-legacy' | 'cip42' | 'cip64' +export type TransactionTypes = 'ethereum-legacy' | 'eip1559' | 'celo-legacy' | 'cip42' | 'cip64' interface CommonTXProperties { nonce: string @@ -114,9 +114,19 @@ export interface LegacyTXProperties extends CommonTXProperties { type: 'celo-legacy' } +export interface EthereumLegacyTXProperties extends CommonTXProperties { + gasPrice: string + type: 'ethereum-legacy' +} + export interface EncodedTransaction { raw: Hex - tx: LegacyTXProperties | CIP42TXProperties | EIP1559TXProperties | CIP64TXProperties + tx: + | EthereumLegacyTXProperties + | LegacyTXProperties + | CIP42TXProperties + | EIP1559TXProperties + | CIP64TXProperties } export type CeloTxPending = Transaction & Partial diff --git a/packages/sdk/wallets/wallet-base/src/signing-utils.test.ts b/packages/sdk/wallets/wallet-base/src/signing-utils.test.ts index 2c2a22d76..998c99c0a 100644 --- a/packages/sdk/wallets/wallet-base/src/signing-utils.test.ts +++ b/packages/sdk/wallets/wallet-base/src/signing-utils.test.ts @@ -16,7 +16,7 @@ const PRIVATE_KEY1 = '0x1234567890abcdef1234567890abcdef1234567890abcdef12345678 const ACCOUNT_ADDRESS1 = normalizeAddressWith0x(privateKeyToAddress(PRIVATE_KEY1)) as `0x${string}` describe('rlpEncodedTx', () => { - describe('legacy', () => { + describe('Celo legacy', () => { const legacyTransaction = { feeCurrency: '0x5409ED021D9299bf6814279A6A1411A7e866A631', from: ACCOUNT_ADDRESS1, @@ -102,6 +102,43 @@ describe('rlpEncodedTx', () => { }) }) + describe('Ethereum legacy', () => { + const legacyTransaction = { + from: '0x1daf825EB5C0D9d9FeC33C444e413452A08e04A6', + to: '0x43d72ff17701b2da814620735c39c620ce0ea4a1', + chainId: 42220, + value: Web3.utils.toWei('0', 'ether'), + nonce: 619, + gas: '504830', + gasPrice: '5000000000', + data: '0x4e71d92d', + } + it('convert CeloTx into RLP', () => { + const transaction = { + ...legacyTransaction, + } + const result = rlpEncodedTx(transaction) + expect(result).toMatchInlineSnapshot(` + { + "rlpEncode": "0xed82026b85012a05f2008307b3fe9443d72ff17701b2da814620735c39c620ce0ea4a180844e71d92d82a4ec8080", + "transaction": { + "chainId": 42220, + "data": "0x4e71d92d", + "from": "0x1daf825eb5c0d9d9fec33c444e413452a08e04a6", + "gas": "0x07b3fe", + "gasPrice": "0x012a05f200", + "maxFeePerGas": "0x", + "maxPriorityFeePerGas": "0x", + "nonce": 619, + "to": "0x43d72ff17701b2da814620735c39c620ce0ea4a1", + "value": "0x", + }, + "type": "ethereum-legacy", + } + `) + }) + }) + describe('EIP1559 / CIP42', () => { const eip1559Transaction: CeloTx = { from: ACCOUNT_ADDRESS1, @@ -369,6 +406,25 @@ describe('recoverTransaction', () => { ] `) }) + it('handles ethereum-legacy transactions', () => { + const ethereumLegacyTx = + '0xf86e82026b85012a05f2008307b3fe9443d72ff17701b2da814620735c39c620ce0ea4a180844e71d92d830149fba0f616cf0a105a0b117b178f6aaa5dc79b9b2aa3898811f99a8f48fb70cece8a33a032a158ab09e32747044e62bd3facd9abd746df23df306dbc31305668da2c7937' + expect(recoverTransaction(ethereumLegacyTx)).toMatchInlineSnapshot(` + [ + { + "chainId": "0xa4ec", + "data": "0x4e71d92d", + "gas": 504830, + "gasPrice": 5000000000, + "nonce": 619, + "to": "0x43d72ff17701b2da814620735c39c620ce0ea4a1", + "type": "ethereum-legacy", + "value": "0x", + }, + "0x1daf825EB5C0D9d9FeC33C444e413452A08e04A6", + ] + `) + }) it('handles cip64 transactions', () => { const cip64TX = '0x7bf88282ad5a8063630a94588e4b68193001e4d10928660ab4165b813717c0880de0b6b3a764000083abcdefc094cd2a3d9f938e13cd947ec05abc7fe734df8dd82680a091b5504a59e529e7efa42dbb97fbc3311a91d035c873a94ab0789441fc989f84a02e8254d6b3101b63417e5d496833bc84f4832d4a8bf8a2b83e291d8f38c0f62d' @@ -567,7 +623,7 @@ describe('extractSignature', () => { }) it('fails when length is wrong', () => { expect(() => extractSignature('0x')).toThrowErrorMatchingInlineSnapshot( - `"@extractSignature: provided transaction has 0 elements but celo-legacy txs with a signature have 12 []"` + `"@extractSignature: provided transaction has 0 elements but ethereum-legacy txs with a signature have 9 []"` ) }) }) diff --git a/packages/sdk/wallets/wallet-base/src/signing-utils.ts b/packages/sdk/wallets/wallet-base/src/signing-utils.ts index 1bd8eaa90..705a37d5d 100644 --- a/packages/sdk/wallets/wallet-base/src/signing-utils.ts +++ b/packages/sdk/wallets/wallet-base/src/signing-utils.ts @@ -84,7 +84,7 @@ function signatureFormatter( s: string } { let v = signature.v - if (type !== 'celo-legacy') { + if (type !== 'celo-legacy' && type !== 'ethereum-legacy') { v = signature.v === Y_PARITY_EIP_2098 ? 0 : 1 } return { @@ -193,7 +193,7 @@ export function rlpEncodedTx(tx: CeloTx): RLPEncodedTx { rlpEncode: concatHex([TxTypeToPrefix.eip1559, rlpEncode]), type: 'eip1559', } - } else { + } else if (isCeloLegacy(tx)) { // This order should match the order in Geth. // https://github.com/celo-org/celo-blockchain/blob/027dba2e4584936cc5a8e8993e4e27d28d5247b8/core/types/transaction.go#L65 rlpEncode = RLP.encode([ @@ -211,10 +211,29 @@ export function rlpEncodedTx(tx: CeloTx): RLPEncodedTx { '0x', ]) return { transaction, rlpEncode, type: 'celo-legacy' } + } else { + // https://github.com/celo-org/celo-proposals/blob/master/CIPs/cip-0035.md + // rlp([nonce, gasprice, gaslimit, recipient, amount, data, v, r, s]) + rlpEncode = RLP.encode([ + stringNumberToHex(transaction.nonce), + transaction.gasPrice, + transaction.gas, + transaction.to, + transaction.value, + transaction.data, + stringNumberToHex(transaction.chainId), + '0x', + '0x', + ]) + delete transaction.feeCurrency + delete transaction.gatewayFee + delete transaction.gatewayFeeRecipient + return { transaction, rlpEncode, type: 'ethereum-legacy' } } } enum TxTypeToPrefix { + 'ethereum-legacy' = '', 'celo-legacy' = '', cip42 = '0x7c', cip64 = '0x7b', @@ -290,7 +309,7 @@ function isCIP64(tx: CeloTx) { return ( isEIP1559(tx) && isPresent(tx.feeCurrency) && - !isPresent(tx.gatewayFeeRecipient) && + !isPresent(tx.gatewayFee) && !isPresent(tx.gatewayFeeRecipient) ) } @@ -302,6 +321,13 @@ function isCIP42(tx: CeloTx): boolean { ) } +function isCeloLegacy(tx: CeloTx): boolean { + return ( + !isEIP1559(tx) && + (isPresent(tx.feeCurrency) || isPresent(tx.gatewayFeeRecipient) || isPresent(tx.gatewayFee)) + ) +} + function concatHex(values: string[]): Hex { return `0x${values.reduce((acc, x) => acc + x.replace('0x', ''), '')}` } @@ -328,12 +354,19 @@ export async function encodeTransaction( const r = sanitizedSignature.r const s = sanitizedSignature.s const decodedTX = prefixAwareRLPDecode(rlpEncoded.rlpEncode, rlpEncoded.type) + + let decodedFields: string[] + // for legacy tx we need to slice but for new ones we do not want to do that - const rawTx = (rlpEncoded.type === 'celo-legacy' ? decodedTX.slice(0, 9) : decodedTX).concat([ - v, - r, - s, - ]) + if (rlpEncoded.type == 'celo-legacy') { + decodedFields = decodedTX.slice(0, 9) + } else if (rlpEncoded.type == 'ethereum-legacy') { + decodedFields = decodedTX.slice(0, 6) + } else { + decodedFields = decodedTX + } + + const rawTx = decodedFields.concat([v, r, s]) // After signing, the transaction is encoded again and type prefix added const rawTransaction = concatTypePrefixHex(RLP.encode(rawTx), rlpEncoded.type) @@ -369,7 +402,7 @@ export async function encodeTransaction( gatewayFee: rlpEncoded.transaction.gatewayFee!.toString(), } } - if (rlpEncoded.type === 'celo-legacy') { + if (rlpEncoded.type === 'celo-legacy' || rlpEncoded.type === 'ethereum-legacy') { tx = { ...tx, // @ts-expect-error -- just a matter of how this tx is built @@ -386,7 +419,11 @@ export async function encodeTransaction( } // new types have prefix but legacy does not function prefixAwareRLPDecode(rlpEncode: string, type: TransactionTypes): string[] { - return type === 'celo-legacy' ? RLP.decode(rlpEncode) : RLP.decode(`0x${rlpEncode.slice(4)}`) + if (type === 'celo-legacy' || type === 'ethereum-legacy') { + return RLP.decode(rlpEncode) + } + + return RLP.decode(`0x${rlpEncode.slice(4)}`) } function correctLengthOf(type: TransactionTypes, includeSig: boolean = true) { @@ -396,11 +433,14 @@ function correctLengthOf(type: TransactionTypes, includeSig: boolean = true) { } case 'cip42': return includeSig ? 15 : 12 + case 'ethereum-legacy': + return 9 case 'celo-legacy': case 'eip1559': return 12 } } + // Based on the return type of ensureLeading0x this was not a Buffer export function extractSignature(rawTx: string) { const type = determineTXType(rawTx) @@ -448,32 +488,10 @@ export function recoverTransaction(rawTx: string): [CeloTx, string] { return recoverTransactionCIP42(rawTx as Hex) case 'eip1559': return recoverTransactionEIP1559(rawTx as Hex) + case 'celo-legacy': + return recoverCeloLegacy(rawTx as Hex) default: - const rawValues = RLP.decode(rawTx) - debug('signing-utils@recoverTransaction: values are %s', rawValues) - const recovery = Bytes.toNumber(rawValues[9]) - // eslint-disable-next-line no-bitwise - const chainId = Bytes.fromNumber((recovery - 35) >> 1) - const celoTx: CeloTx = { - type: 'celo-legacy', - nonce: rawValues[0].toLowerCase() === '0x' ? 0 : parseInt(rawValues[0], 16), - gasPrice: rawValues[1].toLowerCase() === '0x' ? 0 : parseInt(rawValues[1], 16), - gas: rawValues[2].toLowerCase() === '0x' ? 0 : parseInt(rawValues[2], 16), - feeCurrency: rawValues[3], - gatewayFeeRecipient: rawValues[4], - gatewayFee: rawValues[5], - to: rawValues[6], - value: rawValues[7], - data: rawValues[8], - chainId, - } - const { r, v, s } = extractSignatureFromDecoded(rawValues) - const signature = Account.encodeSignature([v, r, s]) - const extraData = recovery < 35 ? [] : [chainId, '0x', '0x'] - const signingData = rawValues.slice(0, 9).concat(extraData) - const signingDataHex = RLP.encode(signingData) - const signer = Account.recover(getHashFromEncoded(signingDataHex), signature) - return [celoTx, signer] + return recoverEthereumLegacy(rawTx as Hex) } } @@ -516,7 +534,13 @@ function determineTXType(serializedTransaction: string): TransactionTypes { } else if (prefix === TxTypeToPrefix.cip64) { return 'cip64' } - return 'celo-legacy' + + // it is one of the legacy types (Celo or Ethereum), to differentiate between + // legacy tx types we have to check the numberof fields + const rawValues = RLP.decode(serializedTransaction) + const length = rawValues.length + + return correctLengthOf('celo-legacy') === length ? 'celo-legacy' : 'ethereum-legacy' } function vrsForRecovery(vRaw: string, r: string, s: string) { @@ -662,6 +686,59 @@ function recoverTransactionEIP1559(serializedTransaction: Hex): [CeloTxWithSig, return [celoTx, signer] } +function recoverCeloLegacy(serializedTransaction: Hex): [CeloTx, string] { + const rawValues = RLP.decode(serializedTransaction) + debug('signing-utils@recoverTransaction: values are %s', rawValues) + const recovery = Bytes.toNumber(rawValues[9]) + // eslint-disable-next-line no-bitwise + const chainId = Bytes.fromNumber((recovery - 35) >> 1) + const celoTx: CeloTx = { + type: 'celo-legacy', + nonce: rawValues[0].toLowerCase() === '0x' ? 0 : parseInt(rawValues[0], 16), + gasPrice: rawValues[1].toLowerCase() === '0x' ? 0 : parseInt(rawValues[1], 16), + gas: rawValues[2].toLowerCase() === '0x' ? 0 : parseInt(rawValues[2], 16), + feeCurrency: rawValues[3], + gatewayFeeRecipient: rawValues[4], + gatewayFee: rawValues[5], + to: rawValues[6], + value: rawValues[7], + data: rawValues[8], + chainId, + } + const { r, v, s } = extractSignatureFromDecoded(rawValues) + const signature = Account.encodeSignature([v, r, s]) + const extraData = recovery < 35 ? [] : [chainId, '0x', '0x'] + const signingData = rawValues.slice(0, 9).concat(extraData) + const signingDataHex = RLP.encode(signingData) + const signer = Account.recover(getHashFromEncoded(signingDataHex), signature) + return [celoTx, signer] +} + +function recoverEthereumLegacy(serializedTransaction: Hex): [CeloTx, string] { + const rawValues = RLP.decode(serializedTransaction) + debug('signing-utils@recoverTransaction: values are %s', rawValues) + const recovery = Bytes.toNumber(rawValues[6]) + // eslint-disable-next-line no-bitwise + const chainId = Bytes.fromNumber((recovery - 35) >> 1) + const celoTx: CeloTx = { + type: 'ethereum-legacy', + nonce: rawValues[0].toLowerCase() === '0x' ? 0 : parseInt(rawValues[0], 16), + gasPrice: rawValues[1].toLowerCase() === '0x' ? 0 : parseInt(rawValues[1], 16), + gas: rawValues[2].toLowerCase() === '0x' ? 0 : parseInt(rawValues[2], 16), + to: rawValues[3], + value: rawValues[4], + data: rawValues[5], + chainId, + } + const { r, v, s } = extractSignatureFromDecoded(rawValues) + const signature = Account.encodeSignature([v, r, s]) + const extraData = recovery < 35 ? [] : [chainId, '0x', '0x'] + const signingData = rawValues.slice(0, 6).concat(extraData) + const signingDataHex = RLP.encode(signingData) + const signer = Account.recover(getHashFromEncoded(signingDataHex), signature) + return [celoTx, signer] +} + export function recoverMessageSigner(signingDataHex: string, signedData: string): string { const dataBuff = toBuffer(signingDataHex) const msgHashBuff = hashPersonalMessage(dataBuff) diff --git a/packages/sdk/wallets/wallet-base/src/wallet-base.ts b/packages/sdk/wallets/wallet-base/src/wallet-base.ts index acab8d7fa..c86bd23a0 100644 --- a/packages/sdk/wallets/wallet-base/src/wallet-base.ts +++ b/packages/sdk/wallets/wallet-base/src/wallet-base.ts @@ -78,7 +78,9 @@ export abstract class WalletBase implements ReadOnlyWall } const rlpEncoded = rlpEncodedTx(txParams) const addToV = - rlpEncoded.type === 'celo-legacy' ? chainIdTransformationForSigning(txParams.chainId!) : 27 + rlpEncoded.type === 'celo-legacy' || rlpEncoded.type === 'ethereum-legacy' + ? chainIdTransformationForSigning(txParams.chainId!) + : 27 // Get the signer from the 'from' field const fromAddress = txParams.from!.toString()