Skip to content
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

show the sign bug #33

Draft
wants to merge 19 commits into
base: refactor/webusb-eth
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@imkey/web3-provider",
"version": "1.1.1",
"version": "1.1.9",
"description": "A web3 provider connects to imKey",
"main": "dist/imkey-web3-provider.cjs.js",
"module": "dist/imkey-web3-provider.esm.js",
Expand Down Expand Up @@ -90,7 +90,7 @@
"tslib": "^2.3.0",
"typescript": "^4.3.5",
"utility-types": "^3.10.0",
"web3": "^1.3.6",
"web3": "^1.5.2",
"webpack": "^4.43.0",
"webpack-cli": "^3.3.11",
"webpack-dev-server": "^3.11.0"
Expand All @@ -104,11 +104,12 @@
"dependencies": {
"@types/event-emitter-es6": "^1.1.0",
"@types/sha.js": "^2.4.0",
"axios": "^0.21.4",
"bignumber.js": "^9.0.1",
"ethereumjs-util": "^5.1.1",
"ethers": "^5.1.3",
"ethers": "^5.4.6",
"event-emitter-es6": "^1.1.5",
"rlp": "^2.2.5",
"rlp": "^2.2.6",
"secp256k1": "^4.0.2",
"underscore": "^1.13.1",
"utf8": "^3.0.0",
Expand Down
2 changes: 2 additions & 0 deletions src/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,6 @@ export const constants = {
APDU_RSP_SWITCH_BL_STATUS_SUCCESS: '905A',

DEVICE_MODEL_NAME: 'imKey Pro',

TRANSACTION_TYPE_EIP1559: '0x02',
}
45 changes: 45 additions & 0 deletions src/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ export function numberToHex(value: string | number | BN) {
if (numberBN.lt(new BN(0))) {
throw new Error('number "' + result + '" is -0x.')
}
if (numberBN.isZero()) {
return '0x'
}
return '0x' + result
}

Expand Down Expand Up @@ -149,6 +152,15 @@ export function addPreZero(num: number | string): string {
export function deleteZero(str: string): string {
return str.replace(/\b(0+)/gi, '')
}

export function arrayEquals(a, b) {
return (
Array.isArray(a) &&
Array.isArray(b) &&
a.length === b.length &&
a.every((val, index) => val === b[index])
)
}
export interface JsonRpcPayload {
jsonrpc?: string
method: string
Expand All @@ -162,6 +174,24 @@ export interface JsonRpcResponse {
result?: any
error?: string
}
export interface EIP1559RLPEncodedTransaction {
raw: string
tx: {
chainId: string
nonce: string
maxPriorityFeePerGas: string
maxFeePerGas: string
gas: string
to: string
value: string
input: string
accessList: AccessListish
r: string
s: string
v: string
hash: string
}
}
export interface RLPEncodedTransaction {
raw: string
tx: {
Expand All @@ -186,6 +216,15 @@ export interface TransactionConfig {
data?: string
nonce?: number
chainId?: number
// Typed-Transaction features
type?: string | null

// EIP-2930; Type 1 & EIP-1559; Type 2
accessList?: AccessListish

// EIP-1559; Type 2
maxFeePerGas?: string
maxPriorityFeePerGas?: string
common?: Common
chain?: string
hardfork?: string
Expand Down Expand Up @@ -214,3 +253,9 @@ export interface CustomChainParams {
networkId: number
chainId: number
}
export type AccessList = Array<{ address: string; storageKeys: Array<string> }>

export type AccessListish =
| AccessList
| Array<[string, Array<string>]>
| Record<string, Array<string>>
Loading