Skip to content

Commit

Permalink
Merge pull request #148 from OneKeyHQ/optimize/aptosInterface
Browse files Browse the repository at this point in the history
Optimize/aptos interface
  • Loading branch information
ByteZhang1024 authored Jan 15, 2024
2 parents 795ee2f + 7194470 commit 33ed7e1
Show file tree
Hide file tree
Showing 35 changed files with 546 additions and 149 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": "1.1.52",
"version": "1.1.53",
"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": "1.1.52",
"@onekeyfe/cross-inpage-provider-events": "1.1.52",
"@onekeyfe/cross-inpage-provider-types": "1.1.52",
"@onekeyfe/cross-inpage-provider-errors": "1.1.53",
"@onekeyfe/cross-inpage-provider-events": "1.1.53",
"@onekeyfe/cross-inpage-provider-types": "1.1.53",
"events": "^3.3.0",
"lodash": "^4.17.21",
"ms": "^2.1.3"
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/versionInfo.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

const version = '1.1.51';
const version = '1.1.53';
const versionBuild = '2020-0101-1';

export default {
Expand Down
10 changes: 8 additions & 2 deletions packages/core/src/walletProperty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,13 @@ export function checkEnableDefineProperty(property: string) {
return false;
}

export function defineWindowProperty(property: string, provider: unknown) {
export function defineWindowProperty(
property: string,
provider: unknown,
options?: {
enumerable?: boolean;
},
) {
if (!checkWalletSwitchEnable(property)) return;
const enable = checkEnableDefineProperty(property);
const proxyProvider = new Proxy(provider as object, {
Expand All @@ -61,7 +67,7 @@ export function defineWindowProperty(property: string, provider: unknown) {
((window as any)[property] ?? {})[key] = (proxyProvider as any)[key];
});
Object.defineProperty(window, property, {
enumerable: true, // Object.keys loop check inject
enumerable: options?.enumerable ?? false, // Object.keys loop check inject
configurable: false, // prevent redefined
get() {
return proxyProvider;
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": "1.1.52",
"version": "1.1.53",
"keywords": [
"cross-inpage-provider"
],
Expand Down Expand Up @@ -34,7 +34,7 @@
"electron": "^17.2.0"
},
"dependencies": {
"@onekeyfe/cross-inpage-provider-core": "1.1.52",
"@onekeyfe/cross-inpage-provider-types": "1.1.52"
"@onekeyfe/cross-inpage-provider-core": "1.1.53",
"@onekeyfe/cross-inpage-provider-types": "1.1.53"
}
}
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": "1.1.52",
"version": "1.1.53",
"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": "1.1.52",
"version": "1.1.53",
"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": "1.1.52",
"version": "1.1.53",
"keywords": [
"cross-inpage-provider"
],
Expand Down
4 changes: 2 additions & 2 deletions packages/example/components/cosmos/CosmosExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export default function App() {
{
"type": "cosmos-sdk/MsgSend",
"value": {
"from_address": "cosmos1l8va6sd7caxkgk4vsnazaxavqn644ayqcn9sst",
"from_address": address,
"to_address": "cosmos19c2m35cfae5lj89x9025plknhjlhe6raj3ma9t",
"amount": [
{
Expand Down Expand Up @@ -162,7 +162,7 @@ export default function App() {
{
"type": "cosmos-sdk/MsgSend",
"value": {
"from_address": "cosmos1l8va6sd7caxkgk4vsnazaxavqn644ayqcn9sst",
"from_address": address,
"to_address": "cosmos19c2m35cfae5lj89x9025plknhjlhe6raj3ma9t",
"amount": [
{
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": "1.1.52",
"version": "1.1.53",
"private": true,
"scripts": {
"postinstall": "patch-package",
Expand All @@ -16,17 +16,17 @@
"@ethersproject/bytes": "^5.0.6",
"@metamask/onboarding": "^1.0.1",
"@mysten/wallet-kit": "^0.7.2",
"@onekeyfe/cross-inpage-provider-core": "1.1.52",
"@onekeyfe/cross-inpage-provider-types": "1.1.52",
"@onekeyfe/onekey-aptos-provider": "1.1.52",
"@onekeyfe/onekey-cardano-provider": "1.1.52",
"@onekeyfe/onekey-conflux-provider": "1.1.52",
"@onekeyfe/onekey-cosmos-provider": "1.1.52",
"@onekeyfe/onekey-near-provider": "1.1.52",
"@onekeyfe/onekey-solana-provider": "1.1.52",
"@onekeyfe/onekey-sui-provider": "1.1.52",
"@onekeyfe/onekey-tron-provider": "1.1.52",
"@onekeyfe/onekey-webln-provider": "1.1.52",
"@onekeyfe/cross-inpage-provider-core": "1.1.53",
"@onekeyfe/cross-inpage-provider-types": "1.1.53",
"@onekeyfe/onekey-aptos-provider": "1.1.53",
"@onekeyfe/onekey-cardano-provider": "1.1.53",
"@onekeyfe/onekey-conflux-provider": "1.1.53",
"@onekeyfe/onekey-cosmos-provider": "1.1.53",
"@onekeyfe/onekey-near-provider": "1.1.53",
"@onekeyfe/onekey-solana-provider": "1.1.53",
"@onekeyfe/onekey-sui-provider": "1.1.53",
"@onekeyfe/onekey-tron-provider": "1.1.53",
"@onekeyfe/onekey-webln-provider": "1.1.53",
"@polkadot/api": "^9.11.3",
"@polkadot/extension-dapp": "^0.44.8",
"@solana/web3.js": "^1.41.3",
Expand Down
5 changes: 5 additions & 0 deletions packages/example/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@ const data: ITreeNodeData[] = [
name: 'Aptos',
href: '/aptos',
icon: 'https://onekey-asset.com/assets/apt/apt.png',
},{
id: uuid.v4(),
name: 'AptosWalletAdapter',
href: 'https://aptos-labs.github.io/aptos-wallet-adapter/',
icon: 'https://onekey-asset.com/assets/apt/apt.png',
},
{
id: uuid.v4(),
Expand Down
Loading

0 comments on commit 33ed7e1

Please sign in to comment.