Skip to content

Commit

Permalink
Add support for CIP42 and EIP1559 (#10483)
Browse files Browse the repository at this point in the history
* remove deprecated functions / params for gasPrice / fee currency in kit

* improve types / format txs

* signing tests, add viem to compare with in tests.

* fix type issue, and split the first 12 (not the last 3)

* parallelize async calls.


* do not extract signer from cip42 txns

this doesnt seem to be a very important feature so punting on it to get CK released


* update test

* revert removal of signer recovery

* feedback from sep

* add back signer test for faster deving

* it works. gandolf rides over the crest as the sun rises blinding the enemy

* show error if the rpc caller  does not attach

* fix binding

* lint fix, and remove the call to set FeeMarket (i dont think its actually need as this will happen in tx params normalizer)

* cheat and pay with CELO to avoid the ganache issue where when paying in fee token querying for gasPrice give and error due to price lookup having an arg and ganache expecting 0 args

* it was never supposed to be like this

* why is it gasCurrency here?

* add some logging for that bug debug -- dont judge me!

* fix but where  transfer was not adhering to the gasFeeCurrency flag

* fix #10025 js numbers cause impresission

* hex must be even

* cleanup extra logs / commented out code.

* add warning for gatewayfee

* add more logging to try to debug test failure

* fix test description typos

* Dont use custom signing code in protocol test

* remove underscore dep



* protocol now depends on local wallet


* revert back logging to how it was,
add back ensure 0x to data if it exists
throw an error (like web3 does) if storage key is bad
remove temp file for changes (now in PR description)

* use named types for address and hex values,
mark gateway fee as deprecated
fix versioning

* publish sdk 5 and pnp-common 3.0.1



* add back dev suffix

* use node 18 in container
  • Loading branch information
aaronmgdr authored Sep 12, 2023
1 parent 2cc7296 commit 07400b0
Show file tree
Hide file tree
Showing 61 changed files with 2,663 additions and 705 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cron-npm-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
name: ${{ matrix.package }} NPM package install
runs-on: ubuntu-latest
container:
image: node:14-bullseye
image: node:18-bullseye
strategy:
fail-fast: false
matrix:
Expand Down
3 changes: 2 additions & 1 deletion dependency-graph.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@
"@celo/cryptographic-utils",
"@celo/phone-utils",
"@celo/typescript",
"@celo/utils"
"@celo/utils",
"@celo/wallet-local"
]
},
"@celo/typescript": {
Expand Down
18 changes: 9 additions & 9 deletions packages/celotool/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
"author": "Celo",
"license": "Apache-2.0",
"dependencies": {
"@celo/base": "4.1.2-dev",
"@celo/connect": "4.1.2-dev",
"@celo/cryptographic-utils": "4.1.2-dev",
"@celo/contractkit": "4.1.2-dev",
"@celo/base": "5.0.3-dev",
"@celo/connect": "5.0.3-dev",
"@celo/cryptographic-utils": "5.0.3-dev",
"@celo/contractkit": "5.0.3-dev",
"@celo/env-tests": "1.0.0",
"@celo/explorer": "4.1.2-dev",
"@celo/governance": "4.1.2-dev",
"@celo/identity": "4.1.2-dev",
"@celo/network-utils": "4.1.2-dev",
"@celo/utils": "4.1.2-dev",
"@celo/explorer": "5.0.3-dev",
"@celo/governance": "5.0.3-dev",
"@celo/identity": "5.0.3-dev",
"@celo/network-utils": "5.0.3-dev",
"@celo/utils": "5.0.3-dev",
"@ethereumjs/util": "8.0.5",
"@ethereumjs/rlp": "4.0.1",
"@google-cloud/monitoring": "0.7.1",
Expand Down
20 changes: 10 additions & 10 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@
},
"dependencies": {
"@celo/bls12377js": "0.1.1",
"@celo/contractkit": "^4.1.2-dev",
"@celo/explorer": "^4.1.2-dev",
"@celo/governance": "^4.1.2-dev",
"@celo/identity": "^4.1.2-dev",
"@celo/phone-utils": "^4.1.2-dev",
"@celo/utils": "^4.1.2-dev",
"@celo/cryptographic-utils": "^4.1.2-dev",
"@celo/wallet-hsm-azure": "^4.1.2-dev",
"@celo/wallet-ledger": "^4.1.2-dev",
"@celo/wallet-local": "^4.1.2-dev",
"@celo/contractkit": "^5.0.3-dev",
"@celo/explorer": "^5.0.3-dev",
"@celo/governance": "^5.0.3-dev",
"@celo/identity": "^5.0.3-dev",
"@celo/phone-utils": "^5.0.3-dev",
"@celo/utils": "^5.0.3-dev",
"@celo/cryptographic-utils": "^5.0.3-dev",
"@celo/wallet-hsm-azure": "^5.0.3-dev",
"@celo/wallet-ledger": "^5.0.3-dev",
"@celo/wallet-local": "^5.0.3-dev",
"@ledgerhq/hw-transport-node-hid": "^6.27.4",
"@oclif/command": "^1.6.0",
"@oclif/config": "^1.6.0",
Expand Down
3 changes: 0 additions & 3 deletions packages/cli/src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,6 @@ export abstract class BaseCommand extends Command {

const setStableTokenGas = async (stable: StableToken) => {
await this.kit.setFeeCurrency(stableTokenInfos[stable].contract)
await this.kit.updateGasPriceInConnectionLayer(
await this.kit.registry.addressFor(stableTokenInfos[stable].contract)
)
}
if (Object.keys(StableToken).includes(gasCurrencyConfig)) {
await setStableTokenGas(StableToken[gasCurrencyConfig as keyof typeof StableToken])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ testWithGanache('releasegold:transfer-dollars cmd', (web3: Web3) => {
contractAddress,
'--value',
cUSDToTransfer,
'--gasCurrency',
'CELO',
])
// RG cUSD balance should match the amount sent
const contractBalance = await kit.getTotalBalance(contractAddress)
Expand All @@ -52,6 +54,8 @@ testWithGanache('releasegold:transfer-dollars cmd', (web3: Web3) => {
accounts[0],
'--value',
cUSDToTransfer,
'--gasCurrency',
'CELO',
])
const balanceAfter = await kit.getTotalBalance(accounts[0])
expect(balanceBefore.cUSD).toEqual(balanceAfter.cUSD)
Expand Down
1 change: 0 additions & 1 deletion packages/cli/src/commands/releasegold/transfer-dollars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export default class TransferDollars extends ReleaseGoldBaseCommand {
this.kit.defaultAccount = isRevoked
? await this.releaseGoldWrapper.getReleaseOwner()
: await this.releaseGoldWrapper.getBeneficiary()

await displaySendTx('transfer', this.releaseGoldWrapper.transfer(flags.to, flags.value))
}
}
18 changes: 10 additions & 8 deletions packages/cli/src/transfer-stable-base.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { StableToken } from '@celo/contractkit'
import { StableTokenWrapper } from '@celo/contractkit/lib/wrappers/StableTokenWrapper'
import { stableTokenInfos } from '@celo/contractkit/src/celo-tokens'
import { flags } from '@oclif/command'
import { ParserOutput } from '@oclif/parser/lib/parse'
import BigNumber from 'bignumber.js'
Expand Down Expand Up @@ -35,7 +36,10 @@ export abstract class TransferStableBase extends BaseCommand {
} catch {
failWith(`The ${this._stableCurrency} token was not deployed yet`)
}
await this.kit.updateGasPriceInConnectionLayer(stableToken.address)
// If gasCurrency is not set, use the transferring token
if (!res.flags.gasCurrency) {
await this.kit.setFeeCurrency(stableTokenInfos[this._stableCurrency].contract)
}

const tx = res.flags.comment
? stableToken.transferWithComment(to, value.toFixed(), res.flags.comment)
Expand All @@ -47,14 +51,12 @@ export abstract class TransferStableBase extends BaseCommand {
`Account can afford transfer and gas paid in ${this._stableCurrency}`,
this.kit.connection.defaultFeeCurrency === stableToken.address,
async () => {
const gas = await tx.txo.estimateGas({ feeCurrency: stableToken.address })
// TODO: replace with gasPrice rpc once supported by min client version
const { gasPrice } = await this.kit.connection.fillGasPrice({
gasPrice: '0',
feeCurrency: stableToken.address,
})
const [gas, gasPrice, balance] = await Promise.all([
tx.txo.estimateGas({ feeCurrency: stableToken.address }),
this.kit.connection.gasPrice(stableToken.address),
stableToken.balanceOf(from),
])
const gasValue = new BigNumber(gas).times(gasPrice as string)
const balance = await stableToken.balanceOf(from)
return balance.gte(value.plus(gasValue))
},
`Cannot afford transfer with ${this._stableCurrency} gasCurrency; try reducing value slightly or using gasCurrency=CELO`
Expand Down
14 changes: 7 additions & 7 deletions packages/env-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
"main": "index.js",
"license": "MIT",
"dependencies": {
"@celo/contractkit": "4.1.2-dev",
"@celo/utils": "4.1.2-dev",
"@celo/base": "4.1.2-dev",
"@celo/connect": "4.1.2-dev",
"@celo/identity": "4.1.2-dev",
"@celo/phone-utils": "4.1.2-dev",
"@celo/cryptographic-utils": "4.1.2-dev",
"@celo/contractkit": "5.0.3-dev",
"@celo/utils": "5.0.3-dev",
"@celo/base": "5.0.3-dev",
"@celo/connect": "5.0.3-dev",
"@celo/identity": "5.0.3-dev",
"@celo/phone-utils": "5.0.3-dev",
"@celo/cryptographic-utils": "5.0.3-dev",
"bunyan": "1.8.12",
"bunyan-gke-stackdriver": "0.1.2",
"bunyan-debug-stream": "2.0.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/metadata-crawler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
"homepage": "https://github.com/celo-org/celo-monorepo/tree/master/packages/metadata-crawler",
"repository": "https://github.com/celo-org/celo-monorepo/tree/master/packages/metadata-crawler",
"dependencies": {
"@celo/connect": "4.1.2-dev",
"@celo/contractkit": "4.1.2-dev",
"@celo/utils": "4.1.2-dev",
"@celo/connect": "5.0.3-dev",
"@celo/contractkit": "5.0.3-dev",
"@celo/utils": "5.0.3-dev",
"@types/pg": "^7.14.3",
"bunyan": "1.8.12",
"bunyan-gke-stackdriver": "0.1.2",
Expand Down
14 changes: 7 additions & 7 deletions packages/phone-number-privacy/combiner/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@celo/phone-number-privacy-combiner",
"version": "3.0.1-dev",
"version": "3.0.3",
"description": "Orchestrates and combines threshold signatures for use in ODIS",
"author": "Celo",
"license": "Apache-2.0",
Expand Down Expand Up @@ -29,10 +29,10 @@
"test:e2e:mainnet": "CONTEXT_NAME=mainnet yarn test:e2e"
},
"dependencies": {
"@celo/contractkit": "^4.1.2-dev",
"@celo/phone-number-privacy-common": "^3.0.1-dev",
"@celo/identity": "^4.1.2-dev",
"@celo/encrypted-backup": "^4.1.2-dev",
"@celo/contractkit": "^5.0.3-dev",
"@celo/phone-number-privacy-common": "^3.0.3",
"@celo/identity": "^5.0.3-dev",
"@celo/encrypted-backup": "^5.0.3-dev",
"@celo/poprf": "^0.1.9",
"@types/bunyan": "^1.8.8",
"@opentelemetry/api": "^1.4.1",
Expand All @@ -55,8 +55,8 @@
},
"devDependencies": {
"@types/node": "18.15.13",
"@celo/utils": "^4.1.2-dev",
"@celo/phone-utils": "^4.1.2-dev",
"@celo/utils": "^5.0.3-dev",
"@celo/phone-utils": "^5.0.3-dev",
"@types/express": "^4.17.6",
"@types/supertest": "^2.0.12",
"@types/uuid": "^7.0.3",
Expand Down
14 changes: 7 additions & 7 deletions packages/phone-number-privacy/common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@celo/phone-number-privacy-common",
"version": "3.0.1-dev",
"version": "3.0.3",
"description": "Common library for the combiner and signer libraries",
"author": "Celo",
"license": "Apache-2.0",
Expand All @@ -18,10 +18,10 @@
"lib/**/*"
],
"dependencies": {
"@celo/base": "^4.1.2-dev",
"@celo/contractkit": "^4.1.2-dev",
"@celo/utils": "^4.1.2-dev",
"@celo/phone-utils": "^4.1.2-dev",
"@celo/base": "^5.0.3-dev",
"@celo/contractkit": "^5.0.3-dev",
"@celo/utils": "^5.0.3-dev",
"@celo/phone-utils": "^5.0.3-dev",
"@types/bunyan": "1.8.8",
"bignumber.js": "^9.0.0",
"bunyan": "1.8.12",
Expand All @@ -41,13 +41,13 @@
},
"devDependencies": {
"@celo/poprf": "^0.1.9",
"@celo/wallet-local": "^4.1.2-dev",
"@celo/wallet-local": "^5.0.3-dev",
"@types/elliptic": "^6.4.12",
"@types/express": "^4.17.6",
"@types/is-base64": "^1.1.0",
"@types/node-fetch": "^2.5.7"
},
"engines": {
"node": ">=10"
"node": ">=12"
}
}
16 changes: 8 additions & 8 deletions packages/phone-number-privacy/monitor/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@celo/phone-number-privacy-monitor",
"version": "3.0.0-beta.2-dev",
"version": "3.0.3",
"description": "Regularly queries ODIS to ensure the system is functioning properly",
"author": "Celo",
"license": "Apache-2.0",
Expand All @@ -22,13 +22,13 @@
"loadTest": "ts-node src/scripts/run-load-test.ts run"
},
"dependencies": {
"@celo/contractkit": "^4.1.2-dev",
"@celo/cryptographic-utils": "^4.1.2-dev",
"@celo/encrypted-backup": "^4.1.2-dev",
"@celo/identity": "^4.1.2-dev",
"@celo/wallet-local": "^4.1.2-dev",
"@celo/phone-number-privacy-common": "^3.0.1-dev",
"@celo/utils": "^4.1.2-dev",
"@celo/contractkit": "^5.0.3-dev",
"@celo/cryptographic-utils": "^5.0.3-dev",
"@celo/encrypted-backup": "^5.0.3-dev",
"@celo/identity": "^5.0.3-dev",
"@celo/wallet-local": "^5.0.3-dev",
"@celo/phone-number-privacy-common": "^3.0.2",
"@celo/utils": "^5.0.3-dev",
"firebase-admin": "^9.12.0",
"firebase-functions": "^3.15.7"
},
Expand Down
14 changes: 7 additions & 7 deletions packages/phone-number-privacy/signer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@celo/phone-number-privacy-signer",
"version": "3.0.2-dev",
"version": "3.0.3",
"description": "Signing participator of ODIS",
"author": "Celo",
"license": "Apache-2.0",
Expand Down Expand Up @@ -37,12 +37,12 @@
"ssl:keygen": "./scripts/create-ssl-cert.sh"
},
"dependencies": {
"@celo/base": "^4.1.2-dev",
"@celo/contractkit": "^4.1.2-dev",
"@celo/phone-number-privacy-common": "^3.0.1-dev",
"@celo/base": "^5.0.3-dev",
"@celo/contractkit": "^5.0.3-dev",
"@celo/phone-number-privacy-common": "^3.0.3",
"@celo/poprf": "^0.1.9",
"@celo/utils": "^4.1.2-dev",
"@celo/wallet-hsm-azure": "^4.1.2-dev",
"@celo/utils": "^5.0.3-dev",
"@celo/wallet-hsm-azure": "^5.0.3-dev",
"@google-cloud/secret-manager": "3.0.0",
"@opentelemetry/api": "^1.4.1",
"@opentelemetry/auto-instrumentations-node": "^0.38.0",
Expand Down Expand Up @@ -78,4 +78,4 @@
"engines": {
"node": ">=10"
}
}
}
Loading

0 comments on commit 07400b0

Please sign in to comment.