Skip to content

Commit

Permalink
bump
Browse files Browse the repository at this point in the history
  • Loading branch information
BitHighlander committed Nov 1, 2023
1 parent 7dffe63 commit 939ffee
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 191 deletions.
2 changes: 1 addition & 1 deletion packages/keepkey-desktop/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "keepkey-desktop",
"version": "2.1.27",
"version": "2.1.28",
"author": {
"name": "KeepKey",
"email": "support@keepkey.com"
Expand Down
216 changes: 26 additions & 190 deletions packages/keepkey-sdk-server/src/controllers/ethereum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,190 +164,18 @@ export class EthereumController extends ApiController {
typedData: any
},
): Promise<types.eth.Signature> {
console.log(body)
// const account = await this.context.getAccount(body.address)
// console.log(
// 'payload: ',
// JSON.stringify({
// addressNList: account.addressNList,
// typedData: body.typedData,
// }),
// )

//signt text
let typedData:any = {
"types": {
"EIP712Domain": [
{
"name": "name",
"type": "string"
},
{
"name": "version",
"type": "string"
},
{
"name": "chainId",
"type": "uint256"
},
{
"name": "verifyingContract",
"type": "address"
}
],
"OrderComponents": [
{
"name": "offerer",
"type": "address"
},
{
"name": "zone",
"type": "address"
},
{
"name": "offer",
"type": "OfferItem[]"
},
{
"name": "consideration",
"type": "ConsiderationItem[]"
},
{
"name": "orderType",
"type": "uint8"
},
{
"name": "startTime",
"type": "uint256"
},
{
"name": "endTime",
"type": "uint256"
},
{
"name": "zoneHash",
"type": "bytes32"
},
{
"name": "salt",
"type": "uint256"
},
{
"name": "conduitKey",
"type": "bytes32"
},
{
"name": "counter",
"type": "uint256"
}
],
"OfferItem": [
{
"name": "itemType",
"type": "uint8"
},
{
"name": "token",
"type": "address"
},
{
"name": "identifierOrCriteria",
"type": "uint256"
},
{
"name": "startAmount",
"type": "uint256"
},
{
"name": "endAmount",
"type": "uint256"
}
],
"ConsiderationItem": [
{
"name": "itemType",
"type": "uint8"
},
{
"name": "token",
"type": "address"
},
{
"name": "identifierOrCriteria",
"type": "uint256"
},
{
"name": "startAmount",
"type": "uint256"
},
{
"name": "endAmount",
"type": "uint256"
},
{
"name": "recipient",
"type": "address"
}
]
},
"primaryType": "OrderComponents",
"domain": {
"name": "Seaport",
"version": "1.5",
"chainId": 137,
"verifyingContract": "0x00000000000000ADc04C56Bf30aC9d3c0aAF14dC"
},
"message": {
"offerer": "0x8c9Ed98b7C3961D22Cc871356C7b73d194608817",
"offer": [
{
"itemType": "2",
"token": "0xa9a6A3626993D487d2Dbda3173cf58cA1a9D9e9f",
"identifierOrCriteria": "64560424590441301826453812164224751707642265079650986418901366599236941237984",
"startAmount": "1",
"endAmount": "1"
}
],
"consideration": [
{
"itemType": "1",
"token": "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619",
"identifierOrCriteria": "0",
"startAmount": "194707500000000000",
"endAmount": "194707500000000000",
"recipient": "0x8c9Ed98b7C3961D22Cc871356C7b73d194608817"
},
{
"itemType": "1",
"token": "0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619",
"identifierOrCriteria": "0",
"startAmount": "4992500000000000",
"endAmount": "4992500000000000",
"recipient": "0x0000a26b00c1F0DF003000390027140000fAa719"
}
],
"startTime": "1696393777",
"endTime": "1699072168",
"orderType": 0,
"zone": "0x0000000000000000000000000000000000000000",
"zoneHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"salt": "24446860302761739304752683030156737591518664810215442929815805592127532436551",
"conduitKey": "0x0000007b02230091a7ed01230072f7006a004d60a8d4e71d599b8104250f0000",
"totalOriginalConsiderationItems": "2",
"counter": "0"
}
}
console.log("this.context.wallet: ",this.context.wallet)
const account = await this.context.getAccount(body.address)
console.log(
'payload: ',
JSON.stringify({
addressNList: account.addressNList,
typedData: body.typedData,
}),
)
return (
await this.context.wallet.ethSignTypedData({
addressNList:[
2147483692,
2147483708,
2147483648,
0,
0
],
typedData,
addressNList: account.addressNList,
typedData: body.typedData,
})
).signature
}
Expand All @@ -360,18 +188,26 @@ export class EthereumController extends ApiController {
public async sign(
@Body()
body: {
message: types.eth.HexData
message: any
address: types.eth.Address
},
): Promise<types.eth.Signature> {
const account = await this.context.getAccount(body.address)
const account = await this.context.getAccount(body.address);

// @ts-ignore
console.log("body: ",body)
console.log("account: ",account)

if (typeof body.message !== 'string' || !/^0x[0-9a-fA-F]+$/.test(body.message)) {
throw new Error('Invalid message: The message must be a hex string starting with 0x');
}

return (
await this.context.wallet.ethSignMessage({
addressNList: account.addressNList,
message: Buffer.from(body.message.replace(/^0x/, ''), 'hex').toString(),
})
).signature
await this.context.wallet.ethSignMessage({
addressNList: account.addressNList,
message: body.message,
})
).signature;
}

/**
Expand All @@ -392,7 +228,7 @@ export class EthereumController extends ApiController {
},
): Promise<boolean> {
return await this.context.wallet.ethVerifyMessage({
message: Buffer.from(body.message.replace(/^0x/, ''), 'hex'),
message: Buffer.from(body.message.replace(/^0x/, ''), 'hex').toString('hex'),
address: body.address,
signature: body.signature,
})
Expand Down

0 comments on commit 939ffee

Please sign in to comment.