Skip to content

Commit

Permalink
chore: add scdo on
Browse files Browse the repository at this point in the history
  • Loading branch information
ByteZhang1024 committed Aug 7, 2024
1 parent 69026bc commit 411b7b2
Show file tree
Hide file tree
Showing 23 changed files with 1,886 additions and 43 deletions.
18 changes: 18 additions & 0 deletions packages/example/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ export const thirdPartyChains: IChainInfo[] = [
];

export const registeredChains: IChainInfo[] = [
{
id: uuid.v4(),
name: 'Alephium',
href: '/alephium',
icon: 'https://uni.onekey-asset.com/static/chain/alephium.png',
},
{
id: uuid.v4(),
name: 'Algo',
Expand Down Expand Up @@ -122,6 +128,12 @@ export const registeredChains: IChainInfo[] = [
href: '/solana',
icon: 'https://uni.onekey-asset.com/static/chain/sol.png',
},
{
id: uuid.v4(),
name: 'Scdo',
href: '/scdo',
icon: 'https://uni.onekey-asset.com/static/chain/scdo.png',
},
{
id: uuid.v4(),
name: 'Solana Standard',
Expand All @@ -140,6 +152,12 @@ export const registeredChains: IChainInfo[] = [
href: '/suiStandard',
icon: 'https://uni.onekey-asset.com/static/chain/sui.png',
},
{
id: uuid.v4(),
name: 'Ton',
href: '/ton',
icon: 'https://uni.onekey-asset.com/static/chain/ton.png',
},
{
id: uuid.v4(),
name: 'Tron',
Expand Down
6 changes: 6 additions & 0 deletions packages/example/components/chains/alephium/dapps.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export const dapps = [
{
name: 'Magic Eden',
url: 'https://magiceden.io/',
},
];
96 changes: 96 additions & 0 deletions packages/example/components/chains/alephium/example.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import { dapps } from './dapps.config';
import { ApiPayload, ApiGroup } from '../../ApiActuator';
import DappList from '../../DAppList';
import InfoLayout from '../../InfoLayout';
import params from './params';
import {
AlephiumWalletProvider,
AlephiumConnectButton,
useWallet,
useBalance,
} from '@alephium/web3-react';

export function Example() {
const wallet = useWallet();
const balance = useBalance();

return (
<>
<AlephiumConnectButton />

<InfoLayout title="Base Info">
{wallet && <p>address: {wallet?.account?.address}</p>}
</InfoLayout>

<ApiGroup title="Send Transaction">
<ApiPayload
title="signAndSubmitTransferTx"
description="转账普通 Native"
allowCallWithoutProvider={!!wallet}
presupposeParams={params.signAndSubmitTransferTx(
wallet?.account?.address ?? '',
wallet?.account?.address ?? '',
)}
onExecute={async (request: string) => {
return wallet.signer.signAndSubmitTransferTx(JSON.parse(request));
}}
/>
<ApiPayload
title="signAndSubmitDeployContractTx"
description=""
allowCallWithoutProvider={!!wallet}
presupposeParams={params.signAndSubmitDeployContractTx(wallet?.account?.address ?? '')}
onExecute={async (request: string) => {
return wallet.signer.signAndSubmitDeployContractTx(JSON.parse(request));
}}
/>
<ApiPayload
title="signAndSubmitExecuteScriptTx"
description=""
allowCallWithoutProvider={!!wallet}
presupposeParams={params.signAndSubmitExecuteScriptTx(wallet?.account?.address ?? '')}
onExecute={async (request: string) => {
return wallet.signer.signAndSubmitExecuteScriptTx(JSON.parse(request));
}}
/>
<ApiPayload
title="signAndSubmitUnsignedTx"
description=""
allowCallWithoutProvider={!!wallet}
presupposeParams={params.signAndSubmitUnsignedTx(wallet?.account?.address ?? '')}
onExecute={async (request: string) => {
return wallet.signer.signAndSubmitUnsignedTx(JSON.parse(request));
}}
/>
<ApiPayload
title="signUnsignedTx"
description=""
allowCallWithoutProvider={!!wallet}
presupposeParams={params.signUnsignedTx(wallet?.account?.address ?? '')}
onExecute={async (request: string) => {
return wallet.signer.signUnsignedTx(JSON.parse(request));
}}
/><ApiPayload
title="signMessage"
description=""
allowCallWithoutProvider={!!wallet}
presupposeParams={params.signMessage(wallet?.account?.address ?? '')}
onExecute={async (request: string) => {
return wallet.signer.signMessage(JSON.parse(request));
}}
/>
</ApiGroup>

<DappList dapps={dapps} />
</>
);
}

export default function App() {
return (
<AlephiumWalletProvider network="mainnet" theme="retro">
<Example />
</AlephiumWalletProvider>
);
}
165 changes: 165 additions & 0 deletions packages/example/components/chains/alephium/params.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
import { ONE_ALPH, DUST_AMOUNT } from '@alephium/web3'

export default {
signAndSubmitTransferTx: (from: string, to: string) => [
{
id: 'signAndSubmitTransferTx-native',
name: 'Native',
value: JSON.stringify({
signerAddress: from,
destinations: [
{
address: to,
amount: '20000000',
},
],
}),
},
{
id: 'signAndSubmitTransferTx-token',
name: 'Token',
value: JSON.stringify({
signerAddress: from,
destinations: [
{
address: to,
amount: DUST_AMOUNT,
tokens: [{ id: 'tokenId', amount: 10 }],
},
],
}),
},
],
signAndSubmitDeployContractTx: (from: string) => {
return [
{
id: 'signAndSubmitDeployContractTx-native',
name: 'Native with body',
value: JSON.stringify({
signerAddress: from,
bytecode: '010203',
}),
},
];
},
signAndSubmitExecuteScriptTx: (from: string) => {
return [
{
id: 'signAndSubmitExecuteScriptTx-native',
name: 'Native with body',
value: JSON.stringify({
signerAddress: from,
bytecode: '010203',
}),
},
];
},
signAndSubmitUnsignedTx: (from: string) => {
return [
{
id: 'signAndSubmitUnsignedTx-native',
name: 'Native with body',
value: JSON.stringify({
signerAddress: from,
unsignedTx: '010203',
}),
},
];
},
signUnsignedTx: (from: string) => {
return [
{
id: 'signUnsignedTx-native',
name: 'Native with body',
value: JSON.stringify({
signerAddress: from,
unsignedTx: '010203',
}),
},
];
},
signMessage: (from: string) => {
return [
{
id: 'signMessage-default-alephium',
name: 'Default with Alephium',
value: JSON.stringify({
signerAddress: from,
signerKeyType: 'default',
message: '010203',
messageHasher: 'alephium',
}),
},
{
id: 'signMessage-default-sha256',
name: 'Default with Sha256',
value: JSON.stringify({
signerAddress: from,
signerKeyType: 'default',
message: '010203',
messageHasher: 'sha256',
}),
},
{
id: 'signMessage-default-blake2b',
name: 'Default with Blake2b',
value: JSON.stringify({
signerAddress: from,
signerKeyType: 'default',
message: '010203',
messageHasher: 'blake2b',
}),
},
{
id: 'signMessage-default-identity',
name: 'Default with Identity',
value: JSON.stringify({
signerAddress: from,
signerKeyType: 'default',
message: '010203',
messageHasher: 'identity',
}),
},
{
id: 'signMessage-bip340-schnorr-alephium',
name: 'Bip340 Schnorr with Alephium',
value: JSON.stringify({
signerAddress: from,
signerKeyType: 'bip340-schnorr',
message: '010203',
messageHasher: 'alephium',
}),
},
{
id: 'signMessage-bip340-schnorr-sha256',
name: 'Bip340 Schnorr with Sha256',
value: JSON.stringify({
signerAddress: from,
signerKeyType: 'bip340-schnorr',
message: '010203',
messageHasher: 'sha256',
}),
},
{
id: 'signMessage-bip340-schnorr-blake2b',
name: 'Bip340 Schnorr with Blake2b',
value: JSON.stringify({
signerAddress: from,
signerKeyType: 'bip340-schnorr',
message: '010203',
messageHasher: 'blake2b',
}),
},
{
id: 'signMessage-bip340-schnorr-identity',
name: 'Bip340 Schnorr with Identity',
value: JSON.stringify({
signerAddress: from,
signerKeyType: 'bip340-schnorr',
message: '010203',
messageHasher: 'identity',
}),
},
];
},
};
21 changes: 21 additions & 0 deletions packages/example/components/chains/alephium/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { PublicKey } from '@solana/web3.js';

export interface IProviderApi {
isOneKey?: boolean;
connect(): Promise<{
publicKey: PublicKey;
}>;
signMessage(
data: Uint8Array,
display?: string,
): Promise<{
signature: Uint8Array;
publicKey: PublicKey;
}>;
}

export interface IProviderInfo {
uuid: string;
name: string;
inject?: string; // window.ethereum
}
2 changes: 1 addition & 1 deletion packages/example/components/chains/aptos/example.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export default function Example() {
const res = await provider?.getNetwork();
return JSON.stringify(res);
}}
/>{' '}
/>
<ApiPayload
title="getNetworkURL"
description="getNetworkURL"
Expand Down
2 changes: 1 addition & 1 deletion packages/example/components/chains/btcBabylon/example.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export default function BTCExample() {
const res = await provider?.getAccounts();
return JSON.stringify(res);
}}
/>{' '}
/>
<ApiPayload
title="getAddress"
description="获取当前账户地址"
Expand Down
2 changes: 1 addition & 1 deletion packages/example/components/chains/conflux/example.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ export default function BTCExample() {
});
return res as string;
}}
/>{' '}
/>
<ApiPayload
title="wallet_sendTransaction"
description="发送交易"
Expand Down
6 changes: 6 additions & 0 deletions packages/example/components/chains/scdo/dapps.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export const dapps = [
{
name: 'Scdo Demo',
url: 'https://demo.scdo.org/',
},
];
Loading

0 comments on commit 411b7b2

Please sign in to comment.