-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
69026bc
commit 411b7b2
Showing
23 changed files
with
1,886 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export const dapps = [ | ||
{ | ||
name: 'Magic Eden', | ||
url: 'https://magiceden.io/', | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
}), | ||
}, | ||
]; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/', | ||
}, | ||
]; |
Oops, something went wrong.