Skip to content

Commit

Permalink
Feat/sol sign offchain message (#280)
Browse files Browse the repository at this point in the history
* feat: add solSignOffchainMessage

* chore: release version 2.2.7-alpha.1
  • Loading branch information
ByteZhang1024 authored Jan 6, 2025
1 parent 7c2931c commit fd45c5d
Show file tree
Hide file tree
Showing 36 changed files with 234 additions and 163 deletions.
8 changes: 4 additions & 4 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onekeyfe/cross-inpage-provider-core",
"version": "2.2.7-alpha.0",
"version": "2.2.7-alpha.1",
"keywords": [
"cross-inpage-provider"
],
Expand Down Expand Up @@ -29,9 +29,9 @@
"build-version-info": "node ./scripts/buildVersionInfo.js"
},
"dependencies": {
"@onekeyfe/cross-inpage-provider-errors": "2.2.7-alpha.0",
"@onekeyfe/cross-inpage-provider-events": "2.2.7-alpha.0",
"@onekeyfe/cross-inpage-provider-types": "2.2.7-alpha.0",
"@onekeyfe/cross-inpage-provider-errors": "2.2.7-alpha.1",
"@onekeyfe/cross-inpage-provider-events": "2.2.7-alpha.1",
"@onekeyfe/cross-inpage-provider-types": "2.2.7-alpha.1",
"events": "^3.3.0",
"lodash-es": "^4.17.21",
"ms": "^2.1.3"
Expand Down
6 changes: 3 additions & 3 deletions packages/desktop/desktop-bridge-injected/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onekeyfe/desktop-bridge-injected",
"version": "2.2.7-alpha.0",
"version": "2.2.7-alpha.1",
"keywords": [
"cross-inpage-provider"
],
Expand Down Expand Up @@ -34,7 +34,7 @@
"electron": "^17.2.0"
},
"dependencies": {
"@onekeyfe/cross-inpage-provider-core": "2.2.7-alpha.0",
"@onekeyfe/cross-inpage-provider-types": "2.2.7-alpha.0"
"@onekeyfe/cross-inpage-provider-core": "2.2.7-alpha.1",
"@onekeyfe/cross-inpage-provider-types": "2.2.7-alpha.1"
}
}
8 changes: 4 additions & 4 deletions packages/e2e/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@onekeyfe/e2e",
"version": "2.2.7-alpha.0",
"version": "2.2.7-alpha.1",
"keywords": [
"cross-inpage-provider"
],
Expand Down Expand Up @@ -31,9 +31,9 @@
"test:ui": "yarn env && npx playwright test --ui "
},
"dependencies": {
"@onekeyfe/cross-inpage-provider-injected": "2.2.7-alpha.0",
"@onekeyfe/cross-inpage-provider-types": "2.2.7-alpha.0",
"@onekeyfe/inpage-providers-hub": "2.2.7-alpha.0",
"@onekeyfe/cross-inpage-provider-injected": "2.2.7-alpha.1",
"@onekeyfe/cross-inpage-provider-types": "2.2.7-alpha.1",
"@onekeyfe/inpage-providers-hub": "2.2.7-alpha.1",
"lodash-es": "^4.17.21"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/empty/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onekeyfe/cross-inpage-provider-empty",
"version": "2.2.7-alpha.0",
"version": "2.2.7-alpha.1",
"keywords": [
"cross-inpage-provider"
],
Expand Down
2 changes: 1 addition & 1 deletion packages/errors/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onekeyfe/cross-inpage-provider-errors",
"version": "2.2.7-alpha.0",
"version": "2.2.7-alpha.1",
"keywords": [
"cross-inpage-provider"
],
Expand Down
2 changes: 1 addition & 1 deletion packages/events/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onekeyfe/cross-inpage-provider-events",
"version": "2.2.7-alpha.0",
"version": "2.2.7-alpha.1",
"keywords": [
"cross-inpage-provider"
],
Expand Down
40 changes: 39 additions & 1 deletion packages/example/components/chains/solana/example.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import params from './params';
import { createTransferTransaction, createVersionedTransaction, createTokenTransferTransaction } from './builder';
import nacl from 'tweetnacl';
import { toast } from '../../ui/use-toast';
import { OffchainMessage } from '../solanaStandard/OffchainMessage';

const NETWORK = clusterApiUrl('mainnet-beta');

Expand Down Expand Up @@ -177,6 +178,43 @@ export default function Example() {
publicKeyObj.toBytes(),
);

return Promise.resolve(isValidSignature.toString());
}}
/>
<ApiPayload
title="solSignOffchainMessage"
description="签名消息(OneKey 私有方法)"
presupposeParams={params.signMessage}
onExecute={async (request: string) => {
return await provider?.solSignOffchainMessage(Buffer.from(request, 'utf8'));
}}
onValidate={(request: string, result: string) => {
// const message = bs58.decode(request).toString();
const {
signature,
publicKey,
}: {
signature: any;
publicKey: string;
} = JSON.parse(result);

let signatureObj;
if(Array.isArray(signature)) {
signatureObj = new Uint8Array(signature)
} else {
signatureObj = new Uint8Array(signature.data)
}
const publicKeyObj = new PublicKey(publicKey);

const offchainMessage = new OffchainMessage({
message: Buffer.from(request, 'utf8'),
});
const isValidSignature = nacl.sign.detached.verify(
offchainMessage.serialize(),
signatureObj,
publicKeyObj.toBytes(),
);

return Promise.resolve(isValidSignature.toString());
}}
/>
Expand Down Expand Up @@ -337,7 +375,7 @@ export default function Example() {
amount: number;
decimals: number;
} = JSON.parse(request);

const recentBlockhash = (await connection.getLatestBlockhash()).blockhash;
const transaction = await createTokenTransferTransaction(
connection,
Expand Down
7 changes: 7 additions & 0 deletions packages/example/components/chains/solana/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ export interface IProviderApi {
signature: Uint8Array;
publicKey: PublicKey;
}>;
solSignOffchainMessage(
data: Uint8Array,
version?: number,
): Promise<{
signature: Uint8Array;
publicKey: PublicKey;
}>;
signAndSendTransaction(transafe: Transaction): Promise<{
signature: Uint8Array;
}>;
Expand Down
24 changes: 12 additions & 12 deletions packages/example/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onekeyfe/cross-inpage-provider-example",
"version": "2.2.7-alpha.0",
"version": "2.2.7-alpha.1",
"private": true,
"scripts": {
"postinstall": "patch-package",
Expand Down Expand Up @@ -28,17 +28,17 @@
"@metamask/onboarding": "^1.0.1",
"@mizuwallet-sdk/core": "^1.4.0",
"@mysten/dapp-kit": "0.13.2",
"@onekeyfe/cross-inpage-provider-core": "2.2.7-alpha.0",
"@onekeyfe/cross-inpage-provider-types": "2.2.7-alpha.0",
"@onekeyfe/onekey-aptos-provider": "2.2.7-alpha.0",
"@onekeyfe/onekey-cardano-provider": "2.2.7-alpha.0",
"@onekeyfe/onekey-conflux-provider": "2.2.7-alpha.0",
"@onekeyfe/onekey-cosmos-provider": "2.2.7-alpha.0",
"@onekeyfe/onekey-near-provider": "2.2.7-alpha.0",
"@onekeyfe/onekey-solana-provider": "2.2.7-alpha.0",
"@onekeyfe/onekey-sui-provider": "2.2.7-alpha.0",
"@onekeyfe/onekey-tron-provider": "2.2.7-alpha.0",
"@onekeyfe/onekey-webln-provider": "2.2.7-alpha.0",
"@onekeyfe/cross-inpage-provider-core": "2.2.7-alpha.1",
"@onekeyfe/cross-inpage-provider-types": "2.2.7-alpha.1",
"@onekeyfe/onekey-aptos-provider": "2.2.7-alpha.1",
"@onekeyfe/onekey-cardano-provider": "2.2.7-alpha.1",
"@onekeyfe/onekey-conflux-provider": "2.2.7-alpha.1",
"@onekeyfe/onekey-cosmos-provider": "2.2.7-alpha.1",
"@onekeyfe/onekey-near-provider": "2.2.7-alpha.1",
"@onekeyfe/onekey-solana-provider": "2.2.7-alpha.1",
"@onekeyfe/onekey-sui-provider": "2.2.7-alpha.1",
"@onekeyfe/onekey-tron-provider": "2.2.7-alpha.1",
"@onekeyfe/onekey-webln-provider": "2.2.7-alpha.1",
"@polkadot/api": "^9.11.3",
"@polkadot/extension-dapp": "^0.47.5",
"@radix-ui/react-checkbox": "^1.1.2",
Expand Down
6 changes: 3 additions & 3 deletions packages/extension/extension-bridge-hosted/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onekeyfe/extension-bridge-hosted",
"version": "2.2.7-alpha.0",
"version": "2.2.7-alpha.1",
"keywords": [
"cross-inpage-provider"
],
Expand Down Expand Up @@ -28,8 +28,8 @@
"start": "tsc --watch"
},
"dependencies": {
"@onekeyfe/cross-inpage-provider-core": "2.2.7-alpha.0",
"@onekeyfe/cross-inpage-provider-types": "2.2.7-alpha.0",
"@onekeyfe/cross-inpage-provider-core": "2.2.7-alpha.1",
"@onekeyfe/cross-inpage-provider-types": "2.2.7-alpha.1",
"uuid": "^8.3.2"
},
"devDependencies": {
Expand Down
6 changes: 3 additions & 3 deletions packages/extension/extension-bridge-injected/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onekeyfe/extension-bridge-injected",
"version": "2.2.7-alpha.0",
"version": "2.2.7-alpha.1",
"keywords": [
"cross-inpage-provider"
],
Expand Down Expand Up @@ -28,7 +28,7 @@
"start": "tsc --watch"
},
"dependencies": {
"@onekeyfe/cross-inpage-provider-core": "2.2.7-alpha.0",
"@onekeyfe/cross-inpage-provider-types": "2.2.7-alpha.0"
"@onekeyfe/cross-inpage-provider-core": "2.2.7-alpha.1",
"@onekeyfe/cross-inpage-provider-types": "2.2.7-alpha.1"
}
}
14 changes: 7 additions & 7 deletions packages/injected/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onekeyfe/cross-inpage-provider-injected",
"version": "2.2.7-alpha.0",
"version": "2.2.7-alpha.1",
"keywords": [
"cross-inpage-provider"
],
Expand Down Expand Up @@ -43,12 +43,12 @@
"electron": "*"
},
"dependencies": {
"@onekeyfe/cross-inpage-provider-core": "2.2.7-alpha.0",
"@onekeyfe/cross-inpage-provider-types": "2.2.7-alpha.0",
"@onekeyfe/desktop-bridge-injected": "2.2.7-alpha.0",
"@onekeyfe/extension-bridge-injected": "2.2.7-alpha.0",
"@onekeyfe/inpage-providers-hub": "2.2.7-alpha.0",
"@onekeyfe/native-bridge-injected": "2.2.7-alpha.0",
"@onekeyfe/cross-inpage-provider-core": "2.2.7-alpha.1",
"@onekeyfe/cross-inpage-provider-types": "2.2.7-alpha.1",
"@onekeyfe/desktop-bridge-injected": "2.2.7-alpha.1",
"@onekeyfe/extension-bridge-injected": "2.2.7-alpha.1",
"@onekeyfe/inpage-providers-hub": "2.2.7-alpha.1",
"@onekeyfe/native-bridge-injected": "2.2.7-alpha.1",
"buffer": "^6.0.3",
"crypto-browserify": "^3.12.0"
}
Expand Down
6 changes: 3 additions & 3 deletions packages/native/native-bridge-injected/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onekeyfe/native-bridge-injected",
"version": "2.2.7-alpha.0",
"version": "2.2.7-alpha.1",
"keywords": [
"cross-inpage-provider"
],
Expand Down Expand Up @@ -28,7 +28,7 @@
"start": "tsc --watch"
},
"dependencies": {
"@onekeyfe/cross-inpage-provider-core": "2.2.7-alpha.0",
"@onekeyfe/cross-inpage-provider-types": "2.2.7-alpha.0"
"@onekeyfe/cross-inpage-provider-core": "2.2.7-alpha.1",
"@onekeyfe/cross-inpage-provider-types": "2.2.7-alpha.1"
}
}
42 changes: 21 additions & 21 deletions packages/providers/inpage-providers-hub/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onekeyfe/inpage-providers-hub",
"version": "2.2.7-alpha.0",
"version": "2.2.7-alpha.1",
"keywords": [
"cross-inpage-provider"
],
Expand Down Expand Up @@ -28,26 +28,26 @@
"start": "tsc --watch"
},
"dependencies": {
"@onekeyfe/cross-inpage-provider-core": "2.2.7-alpha.0",
"@onekeyfe/cross-inpage-provider-types": "2.2.7-alpha.0",
"@onekeyfe/onekey-algo-provider": "2.2.7-alpha.0",
"@onekeyfe/onekey-alph-provider": "2.2.7-alpha.0",
"@onekeyfe/onekey-aptos-provider": "2.2.7-alpha.0",
"@onekeyfe/onekey-bfc-provider": "2.2.7-alpha.0",
"@onekeyfe/onekey-btc-provider": "2.2.7-alpha.0",
"@onekeyfe/onekey-cardano-provider": "2.2.7-alpha.0",
"@onekeyfe/onekey-conflux-provider": "2.2.7-alpha.0",
"@onekeyfe/onekey-cosmos-provider": "2.2.7-alpha.0",
"@onekeyfe/onekey-eth-provider": "2.2.7-alpha.0",
"@onekeyfe/onekey-nostr-provider": "2.2.7-alpha.0",
"@onekeyfe/onekey-polkadot-provider": "2.2.7-alpha.0",
"@onekeyfe/onekey-private-provider": "2.2.7-alpha.0",
"@onekeyfe/onekey-scdo-provider": "2.2.7-alpha.0",
"@onekeyfe/onekey-solana-provider": "2.2.7-alpha.0",
"@onekeyfe/onekey-sui-provider": "2.2.7-alpha.0",
"@onekeyfe/onekey-ton-provider": "2.2.7-alpha.0",
"@onekeyfe/onekey-tron-provider": "2.2.7-alpha.0",
"@onekeyfe/onekey-webln-provider": "2.2.7-alpha.0",
"@onekeyfe/cross-inpage-provider-core": "2.2.7-alpha.1",
"@onekeyfe/cross-inpage-provider-types": "2.2.7-alpha.1",
"@onekeyfe/onekey-algo-provider": "2.2.7-alpha.1",
"@onekeyfe/onekey-alph-provider": "2.2.7-alpha.1",
"@onekeyfe/onekey-aptos-provider": "2.2.7-alpha.1",
"@onekeyfe/onekey-bfc-provider": "2.2.7-alpha.1",
"@onekeyfe/onekey-btc-provider": "2.2.7-alpha.1",
"@onekeyfe/onekey-cardano-provider": "2.2.7-alpha.1",
"@onekeyfe/onekey-conflux-provider": "2.2.7-alpha.1",
"@onekeyfe/onekey-cosmos-provider": "2.2.7-alpha.1",
"@onekeyfe/onekey-eth-provider": "2.2.7-alpha.1",
"@onekeyfe/onekey-nostr-provider": "2.2.7-alpha.1",
"@onekeyfe/onekey-polkadot-provider": "2.2.7-alpha.1",
"@onekeyfe/onekey-private-provider": "2.2.7-alpha.1",
"@onekeyfe/onekey-scdo-provider": "2.2.7-alpha.1",
"@onekeyfe/onekey-solana-provider": "2.2.7-alpha.1",
"@onekeyfe/onekey-sui-provider": "2.2.7-alpha.1",
"@onekeyfe/onekey-ton-provider": "2.2.7-alpha.1",
"@onekeyfe/onekey-tron-provider": "2.2.7-alpha.1",
"@onekeyfe/onekey-webln-provider": "2.2.7-alpha.1",
"lodash-es": "^4.17.21",
"preact": "^10.25.1",
"web3": "^1.7.3"
Expand Down
10 changes: 5 additions & 5 deletions packages/providers/onekey-algo-provider/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onekeyfe/onekey-algo-provider",
"version": "2.2.7-alpha.0",
"version": "2.2.7-alpha.1",
"keywords": [
"cross-inpage-provider"
],
Expand Down Expand Up @@ -28,9 +28,9 @@
"start": "tsc --watch"
},
"dependencies": {
"@onekeyfe/cross-inpage-provider-core": "2.2.7-alpha.0",
"@onekeyfe/cross-inpage-provider-errors": "2.2.7-alpha.0",
"@onekeyfe/cross-inpage-provider-types": "2.2.7-alpha.0",
"@onekeyfe/extension-bridge-injected": "2.2.7-alpha.0"
"@onekeyfe/cross-inpage-provider-core": "2.2.7-alpha.1",
"@onekeyfe/cross-inpage-provider-errors": "2.2.7-alpha.1",
"@onekeyfe/cross-inpage-provider-types": "2.2.7-alpha.1",
"@onekeyfe/extension-bridge-injected": "2.2.7-alpha.1"
}
}
10 changes: 5 additions & 5 deletions packages/providers/onekey-alph-provider/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onekeyfe/onekey-alph-provider",
"version": "2.2.7-alpha.0",
"version": "2.2.7-alpha.1",
"keywords": [
"cross-inpage-provider"
],
Expand Down Expand Up @@ -31,9 +31,9 @@
"@alephium/get-extension-wallet": "^1.5.2",
"@alephium/walletconnect-provider": "^1.5.2",
"@alephium/web3": "^1.5.2",
"@onekeyfe/cross-inpage-provider-core": "2.2.7-alpha.0",
"@onekeyfe/cross-inpage-provider-errors": "2.2.7-alpha.0",
"@onekeyfe/cross-inpage-provider-types": "2.2.7-alpha.0",
"@onekeyfe/extension-bridge-injected": "2.2.7-alpha.0"
"@onekeyfe/cross-inpage-provider-core": "2.2.7-alpha.1",
"@onekeyfe/cross-inpage-provider-errors": "2.2.7-alpha.1",
"@onekeyfe/cross-inpage-provider-types": "2.2.7-alpha.1",
"@onekeyfe/extension-bridge-injected": "2.2.7-alpha.1"
}
}
Loading

0 comments on commit fd45c5d

Please sign in to comment.